home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18045 < prev    next >
Encoding:
Text File  |  1992-12-16  |  3.3 KB  |  84 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: The fate of my exponentiation operator proposal
  5. Message-ID: <BzCFyM.2r5@frumious.uucp>
  6. Date: Wed, 16 Dec 1992 08:37:33 GMT
  7. References: <1992Dec05.002934.13043@microsoft.com> <1992Dec5.063533.1787@frumious.uucp> <1992Dec07.195917.14566@microsoft.com>
  8. Organization: None
  9. Lines: 73
  10.  
  11. jimad@microsoft.com (Jim Adcock) writes:
  12. |In article <1992Dec5.063533.1787@frumious.uucp> uunet.ca!frumious!pat writes:
  13. ||jimad@microsoft.com (Jim Adcock) writes:
  14. |||Where is the offsetting benefit in *requiring* implementations to make this
  15. |||change breaking conforming programs?  ANSI-C *already* requires that
  16. |||macro implementations only perform one evaluations of the macro parameters,
  17. |||so what are you gaining by forcing implementations to now use inline
  18. |||functions instead of macros for these things?
  19. ||
  20. ||If these functions may be implemented as macros, then their names may not
  21. ||be used in other ways (not by programmers who aspire to write portable
  22. ||code, anyway).  For example, consider
  23. ||
  24. ||   class Prisoner {
  25. ||   public:
  26. ||      // ...
  27. ||      void free();   // Let him out on parole; not related to malloc()
  28. ||   };
  29. |
  30. |Agreed.  You give an excellent example of why ANSI-C functions should
  31. |continue to be implemented as macros not as inlines.
  32.  
  33.  
  34. I take it you consider the above to be an unreasonable use of the
  35. name free.  Perhaps it is and perhaps it isn't; people often have
  36. different opinions as to what's reasonable.  In the absence of a
  37. strong concensus that something is unreasonable, I would prefer to
  38. allow those who believe it to be reasonable to do it.
  39.  
  40.  
  41. Here are a few other examples you might find more convincing.
  42.  
  43. Consider the above in the context of a project where malloc() and the
  44. normal free() are never used; all memory allocation is done through
  45. new and delete.
  46.  
  47. Steve Clamage mentioned the possibility of using sin to refer to
  48. immoral acts, instead of the sine function.
  49.  
  50. In some cases, an existing name from the standard library can
  51. be quite intuitive as a name for a new function.  For example,
  52.  
  53.    class String {
  54.       // A sequence of characters, possibly including null characters
  55.       // in arbitrary positions.
  56.    public:
  57.       size_t length() const;
  58.          // Length of the sequence, including the nulls (if any).
  59.       size_t strlen() const;
  60.          // The number of characters before the first null character
  61.          // (not including the null); the same as length() if there
  62.          // aren't any nulls in the string.
  63.    };
  64.  
  65. Stepping to another language for a moment, there's a problem with
  66. this C code, if memory serves me correctly:
  67.  
  68.    typedef whatever Razor;
  69.    void strop(Razor r);
  70.  
  71. The problem?  The C standard reserves names beginning with str for
  72. use in future versions of the standard.  So this code might not
  73. compile a few years down the road.  If one takes this restriction
  74. seriously, there are quite a few normal English words one shouldn't
  75. use in C programs (strong, straight, stress, strict, etc., etc.).
  76. It would be nice to be able to use these words in C++ programs
  77. without having to worry about future versions of the standard,
  78. even if only in some contexts (eg. as member function names).
  79.  
  80. -- 
  81. Patrick Smith
  82. uunet.ca!frumious!pat
  83. pat%frumious.uucp@uunet.ca
  84.