home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!uwm.edu!caen!destroyer!gumby!wupost!darwin.sura.net!max.fiu.edu!serss0!feathers
- From: feathers@serss0 (Michael Feathers)
- Subject: Re: Two things: typeof() and exceptions
- Organization: Florida International University, Miami
- Date: Mon, 16 Nov 1992 23:34:00 GMT
- Message-ID: <Bxu1Gp.M9o@fiu.edu>
- References: <MCGRANT.92Nov15134127@rascals.stanford.edu> <1992Nov16.202036.1@vax1.bham.ac.uk>
- Sender: news@fiu.edu (Usenet Administrator)
- Lines: 45
-
- In article <1992Nov16.202036.1@vax1.bham.ac.uk> mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
- >
- >IMHO we should always think carefully before adding a new token to
- >the language after all some poor sod will have used it as a symbol.
- >It would not detract from the readability to use class() instead.
- >
- >There is a presedent for using the token `class' in this way:
- > `template<class T>' "class" meaning "T is a symbol of type class"
- > `class(xxx)' "class" meaning "Convert xxx to a value of type class"
- >
-
-
- This is a great point of departure for another question:
-
- Why does the syntax for a template require the class keyword when templates
- are instantiable to the predefined types of C++ (int, double, etc.,.)?
-
- I suspect the reason is to disambiguate expressions and class/type names
- as parameters to templates. However, it is a wonderful start towards
- perhaps making the predefined types of C++ behave as classes. It would
- be nice to be able to inherit from int or float, for instance. Anyone
- who would want to do something like this today needs to make a class
- with an int or float member. Most compilers that I've run into still
- generate code which accesses the single member like a struct even though
- it is at offset zero in the struct.
-
- What would we do for syntax? How about this:
-
- class Integer : public int
- {
- public:
- operator int () { return *this; }
- };
-
- *this would be the access for the int portion of an Integer. Note that
- if there were additional members in class Integer, an int cast would have
- the effect of "object-slicing" *this to only the int portion.
-
- I'm not sure if such lvalue casting is now allowed. All of this is off
- the top of my head, but I think that making the predefined types into
- classes would certainly help the orthogonality of the language.
-
- The syntax of templates certainly suggests that predefined types are
- sort of like classes, doesn't it?
-
-