home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Covariant Types in Derived Classes
- Message-ID: <1992Aug12.144539.9102@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Aug8.210716.14741@ucc.su.OZ.AU> <713504630snx@trmphrst.demon.co.uk>
- Date: Wed, 12 Aug 1992 14:45:39 GMT
- Lines: 54
-
- In article <713504630snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
- >
- >In article <1992Aug8.210716.14741@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >
- >> In article <713221684snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
- >> >
- >> >No - some casts are fine - e.g. ...
- >> >
- >> >Casting a built-in arithmetic type to a larger type to avoid arithmetic
- >> > overflow.
- >>
- >> This is NOT a cast (in my terminology), but a value producting
- >> conversion. I assume you mean
- >>
- >> int x,y;
- >> long z;
- >> z=(long)x*y; // conversion NOT cast
- >> *(long*)&x=z; // cast--bad news here :-)
- >Oh No, Humpty-Dumpty casts now :-)
- >
- >Sorry, I wasn't aware that the construct "(type)" was sometimes called a
- >cast, and sometimes a conversion. O.K., I want a compiler that warns me
- >about all casts, but not about conversions.
-
- Please excuse my prejudices. I think I'm being unnecessarily
- argumentative about terminology here. :-)
- >
- >By the way, what is
- > int x;
- > long z;
- >
- > x = (int)z;
- >
- >Is this a cast, or a conversion ? (I want a warning anyway, please).
-
- Its a conversion. An rvalue is converted to an rvalue of
- a different type. Not the same as looking at a bit pattern
- representing one type as another type that it actually isnt---thats
- a cast. Usually done through pointers.
-
- Upcasts aren't casts really because the derived type 'isA'
- base type (but I'm stretching it here :-)
- >
- >O.K. Max, old chum :-)
-
-
- I believe Bjarne has identified 5 different types of 'casts',
- and plans syntax to discriminate them. Mm.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-