home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18687 < prev    next >
Encoding:
Text File  |  1993-01-04  |  4.7 KB  |  85 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Standard library functions and macros
  5. Message-ID: <1993Jan04.231519.8704@microsoft.com>
  6. Date: 04 Jan 93 23:15:19 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec29.213548.5661@microsoft.com> <9300302.725@mulga.cs.mu.OZ.AU> <1993Jan2.191336.28542@taumet.com>
  9. Lines: 74
  10.  
  11. In article <1993Jan2.191336.28542@taumet.com> steve@taumet.com (Steve Clamage) writes:
  12. |If an implementation uses the same library for C and C++, which is
  13. |true for current implemenations, you can successfully do this:
  14. |    extern "C" int puts(const char *);
  15. |    int main() { puts("Hello world\n"); return 0; }
  16. |You are just not assured the code will work.
  17.  
  18. How about implementations and programmers that want to continue to
  19. share code between C and C++ implementations?  Let's say a program
  20. that it created from some "C" files and some "C++" files, and each of
  21. these files in turn calls some of the standard-C functions.  How are
  22. you going to make this work?  Seems to me you are requiring 
  23. "C++ calling convention" of the standard-C functions called by the
  24. C++ files, whereas the standard-C functions called from the "C" files
  25. would have to follow "C" calling convention.  At the very least this
  26. seems to me to be saying that you're requiring dual-entry stubs of
  27. all the library functions.  And then how do these things coexist in
  28. one library and get linked in correctly?  Can you point to even one
  29. existing implementation that implements your proposed changes, and
  30. which continues to allow mixed Cfile/C++file programs to be compiled and linked?
  31.  
  32. |Jim missing a point, I think.  Let's say, under his scenario, that I
  33. |create a class with a member function getchar.  I am careful not to
  34. |use <stdio.h>, and everything is fine.  A later programmer wants to use
  35. |stdio as well as my class library, and the code won't compile.
  36.  
  37. I think you're missing the point.  "getchar" is one of a very few function
  38. names in the ANSI-C library that has even a *plausible* use as a C++ function
  39. name.  "free" being possibly the most plausible name to return to the C++
  40. programmer name space.  Yet along with these few handful of functions that
  41. have even *plausible* uses as names for C++ programmers you are insisting
  42. that implementations change their implementation of some hundreds other
  43. ANSI-C function names that *don't* have plausible use to C++ programmers.
  44.  
  45. |We have (at least) two choices.  Jim wants to leave the C headers alone,
  46. |meaning that the names of all the C library functions are unavailable
  47. |for use as class member functions.  
  48.  
  49. Not what I said.  I said leave them alone except where you can show a very
  50. good motivation for requiring a change.  No such motivation has been shown.
  51. Rather, a plausible handful of function names out of the entirety of the 
  52. typically implausible ANSI-C function name set is being used erroneously
  53. to try to motivate changing the rules on ALL the functions.  These changes
  54. are not well motivated.  If you want to argue to change the implementation
  55. of "free" and "getchar" or one of a handful of other functions, then so
  56. argue, and we can debate whether the name-space "improvements" justify
  57. the implementation impact and the conforming program impact.  But don't
  58. try to argue that all should be forced to be non-macro just because you
  59. really want to use a few as non-macro.
  60.  
  61. | The choice which was adopted says
  62. |that some existing C code would have to be modified under some C++
  63. |implementations -- you might have to use standard headers instead of
  64. |homebrew declarations of standard functions.  I don't think you can make
  65. |a case that either choice is just plain wrong; it is a judgement call.
  66. |The C++ Committee made a judgement, and anyone is free to disagree.
  67.  
  68. My position as stated above was that the change was overreaching
  69. and un-motivated in being so over-reaching.  Change what you have
  70. good motivation to change, and leave the rest alone.
  71.  
  72. |A few weeks ago I asked for analyses of this situation, or of any other
  73. |problem associated with the change in C library rules for C++.  I did
  74. |not get any response.  I renew the request.  If the Committee has made
  75. |a bad decision, this is the time to correct it.
  76.  
  77. Consider my arguments here as a response to your request.  My position
  78. being that the committee made a bad proposed change decision by 
  79. over-generalizing from a few specific cases to all the ANSI-C functions.  
  80. If you look at the ANSI-C functions, only a tiny handful make plausible 
  81. sense to require as non-macros.  Change the ANSI-C base document in regards 
  82. those isolated few functions, if you insist.  Leave the rest of the ANSI-C 
  83. functions and base document alone.  Don't change the base document simply for
  84. the sake of change.
  85.