home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12291 < prev    next >
Encoding:
Text File  |  1992-08-12  |  2.3 KB  |  67 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Covariant Types in Derived Classes
  5. Message-ID: <1992Aug12.144539.9102@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Aug8.210716.14741@ucc.su.OZ.AU> <713504630snx@trmphrst.demon.co.uk>
  10. Date: Wed, 12 Aug 1992 14:45:39 GMT
  11. Lines: 54
  12.  
  13. In article <713504630snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
  14. >
  15. >In article <1992Aug8.210716.14741@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  16. >
  17. >> In article <713221684snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
  18. >> >
  19. >> >No - some casts are fine - e.g. ...
  20. >> >
  21. >> >Casting a built-in arithmetic type to a larger type to avoid arithmetic 
  22. >> >  overflow.
  23. >> 
  24. >>     This is NOT a cast (in my terminology), but a value producting
  25. >> conversion. I assume you mean
  26. >> 
  27. >>     int x,y;
  28. >>     long z;
  29. >>     z=(long)x*y; // conversion NOT cast
  30. >>     *(long*)&x=z; // cast--bad news here :-)
  31. >Oh No, Humpty-Dumpty casts now :-)
  32. >
  33. >Sorry, I wasn't aware that the construct "(type)" was sometimes called a 
  34. >cast, and sometimes a conversion. O.K., I want a compiler that warns me 
  35. >about all casts, but not about conversions.
  36.  
  37.     Please excuse my prejudices. I think I'm being unnecessarily
  38. argumentative about terminology here. :-)
  39. >
  40. >By the way, what is 
  41. >    int x;
  42. >    long z;
  43. >    
  44. >    x = (int)z;
  45. >
  46. >Is this a cast, or a conversion ? (I want a warning anyway, please).
  47.  
  48.     Its a conversion. An rvalue is converted to an rvalue of
  49. a different type. Not the same as looking at a bit pattern
  50. representing one type as another type that it actually isnt---thats
  51. a cast. Usually done through pointers.
  52.  
  53.     Upcasts aren't casts really because the derived type 'isA'
  54. base type (but I'm stretching it here :-)
  55. >
  56. >O.K. Max, old chum :-)
  57.  
  58.  
  59.     I believe Bjarne has identified 5 different types of 'casts',
  60. and plans syntax to discriminate them. Mm.
  61.  
  62. -- 
  63. ;----------------------------------------------------------------------
  64.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  65.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  66. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  67.