home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!laphroaig!cflatter
- From: cflatter@nrao.edu (Chris Flatters)
- Subject: Re: template disappointments ... (suggesti
- Message-ID: <1992Dec30.165154.25081@nrao.edu>
- Sender: news@nrao.edu
- Reply-To: cflatter@nrao.edu
- Organization: NRAO
- References: <MCGRANT.92Dec29191250@gomez.stanford.edu>
- Date: Wed, 30 Dec 1992 16:51:54 GMT
- Lines: 47
-
- In article 92Dec29191250@gomez.stanford.edu, mcgrant@gomez.stanford.edu (Michael C. Grant) writes:
- >
- >In article <1992Dec29.204431.13413@nrao.edu>
- >cflatter@nrao.edu (Chris Flatters) writes:
- > In article 92Dec29133556@muse.cv.nrao.edu,
- > dschieb@muse.cv.nrao.edu (Darrell Schiebel) writes:
- > > (1) The inability to derive templated classes from a non-templated
- > > base class of the same name:
- > > class typeinfo {};
- > > template<class t> class typeinfo : public typeinfo {};
- >Yeah, that's a bummer. I see no reason why typeinfo and typeinfo<T>
- >can't be distinguished by any reasonable compiler.
-
- I can.
-
- The declaration of a class introduces a new keyword into the language. After
- encountering the declaration "class typeinfo { ... };" the lexical analyser will
- recognize "typeinfo" as a class name. This means that "template<class T>
- class typeinfo: public typeinfo {};" looks like:
-
- 1) a second definition of typeinfo; and
-
- 2) a definition of a class that inherits from itself.
-
- In principle it is possible to envision a template name space that is separate
- from the class name space but this would require the decision of whether an
- identifier is a class name or a template name to be made with some awareness
- of the context in which it appears. This would rule out the use of LR(k)
- parsers (such as those generated by yacc) since syntactic elements are not
- recognized until all of their components have been scanned. This is a fairly
- hefty price to pay.
-
- >
- > This is according to the ARM:
- >
- > A class template name must be unique in the program and may not
- > be declared to refer to any other template, class, function,
- > object, value, or type in the same scope.
- > [p343]
- >What's yer point? That's why this is called 'template disappointments.'
-
- The point is that cfront will reject "template <class T> class foo: public foo {}"
- because it is forbidden by the language definition and not because of a compiler
- deficiency.
-
- Chris Flatters
- cflatter@nrao.edu
-