home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 1981 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  2.0 KB

  1. Xref: sparky comp.std.c++:1981 comp.lang.c++:18760
  2. Path: sparky!uunet!racerx!rodb
  3. From: rodb@racerx.bridge.COM (Rod Burman)
  4. Newsgroups: comp.std.c++,comp.lang.c++
  5. Subject: Extra COntant definitions
  6. Summary: Suggestions for Extending C++ types
  7. Message-ID: <1224@racerx.bridge.COM>
  8. Date: 6 Jan 93 17:30:44 GMT
  9. Followup-To: comp.std.c++
  10. Organization: Bridge Information Systems
  11. Lines: 49
  12.  
  13. It has just occured to me that since C++ is a strongly typed language
  14. it should provide intrinsic support for constants of all intrinsic types
  15. that is currently we have:
  16.  
  17.         1    // int
  18.         1U    // unsigned int
  19.         1L    // long
  20.         1UL    // unsigned long
  21.         '\1'    // unsigned char -- it is unsigned since only
  22.             // octal and hex bit patterns are allowed and
  23.             // by default they are unsigned -- this may be
  24.             // shakey logic, it may be implimentation dependent
  25.             // on whether char is signed/unsigned, I admit
  26.         '\1'L    // wide unsigned char -- see above comment
  27.         "\1"    // unsigned char[]
  28.         "\1"L    // unsigned wide char -- w_chart is scheduled to
  29.             // be an intrinsic type in ANSI/ISO C++
  30.  
  31. This as I see it leaves room for:
  32.  
  33.         1S    // short
  34.         1US    // unsigned short
  35.         1I    // int -- this may not be really neccessary!
  36.         1UI    // unsigned int
  37.         '\1'S    // signed char -- see I'm following the spirit of C
  38.             // and confusing programmers nicely by using S for both
  39.             // short and signed!
  40.         '\1'U    // unsigned char
  41.         '\1'SL    // signed wide char
  42.         '\1'UL    // unsigned wide char
  43.         "\1"S    // signed char[]
  44.         "\1"U    // unsigned char[]
  45.         "\1"SL    // signed wide char[]
  46.         "\1"UL    // unsigned wide cahr[]
  47.  
  48. Ofcourse you can always have:
  49.  
  50.     (short) 1;    // etc
  51.  
  52. and this may be more portable since you can then have:
  53.  
  54.     (int16) 1;    // etc
  55.  
  56. where you typedef int16, etc to the correct type in some header somewhere which takes
  57. care of compiler/OS/machine dependecies, but shouldn't you be able to do the other way
  58. if you want? (Can any one send me the appropriate #define macro to convert 1INT32; to
  59. 1L or 1 depending on wether long is 32 or 64 bits?)
  60.     Well just a though for the standards committee after all it shouldn't break any
  61. existing code should it?
  62.