home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18408 < prev    next >
Encoding:
Text File  |  1992-12-24  |  3.4 KB  |  75 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
  3. From: jss@lucid.com (Jerry Schwarz)
  4. Subject: Re: Standard library functions and macros
  5. Message-ID: <1992Dec25.014646.9364@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References: <BzCFyM.2r5@frumious.uucp> <1992Dec16.185914.664@microsoft.com> <BzFM01.CD@frumious.uucp> <1992Dec23.214139.24948@microsoft.com>
  10. Date: Fri, 25 Dec 92 01:46:46 GMT
  11. Lines: 62
  12.  
  13. In article <1992Dec23.214139.24948@microsoft.com>, jimad@microsoft.com (Jim Adcock) writes:
  14.  
  15. |> Yes, assuming by "the meaning" of a C program you mean "the intent
  16. |> of the original C author."  For example, the original author can
  17. |> do a '#undef putchar' with "the meaning" that in this compilation his/her
  18. |> intent is that putchar be implemented out-of-line.  Under the proposed
  19. |> required changes to C++ implementations, "the meaning" of the original
  20. |> C author would be silently changed.  Thus someone porting this C program
  21. |> to C++ finds [or worse, DOESN'T FIND!] that C++ silently changes the 
  22. |> intent of the original author.
  23. |> 
  24.  
  25. There is no such guarantee in standard C.  If there is a #include <stdio.h>
  26. present, a compiler is free to inline putchar whether or not the user
  27. does #undef putchar.  The constraint is in the other direction.  A
  28. programmer can't use "putchar" in specific ways unless an #undef appears.
  29.  
  30. If Jim is saying that in a particular implementation the #undef has
  31. this effect and believes that effect should be preserved, then nothing
  32. stops an implementation from giving the #undef the same effect in C++,
  33. although I suspect he will have to lobby his vendors very hard to
  34. convince them to implement such a feature.
  35.  
  36. |> Also, note that a conforming C implementation of these standard library
  37. |> functions using macros can accept a superset of the parm types that a
  38. |> C++ extern implementation or inline implementation can accept.  A macro
  39. |> implementation is somewhat analogous to the C++ situation where a 
  40. |> templated function is used.  Thus, requiring that a macro *not* be
  41. |> used for implementation requires that some possible conforming programs
  42. |> will no longer be accepted.  Still, breaking such a program is a MUCH better
  43. |> situation that silently accepting a program while changing "the meaning" 
  44. |> of that program.
  45. |> 
  46.  
  47. I'm not sure I understand this.  Is the intented example that 
  48. there might be something like
  49.  
  50.     #define putchar __myputchar
  51.  
  52. And __myputchar would then be callable in different ways?   Are there
  53. any such implementations?  In that case the equivalent C++ would be
  54. to declare putchar variants in the header.   Under the currently
  55. proposed rules this wouldn't be allowed either, but I would be more
  56. willing to relax the rules in this direction if there is
  57. a real need for alternative "putchars" or any other C library function.
  58. Is anything like this actually done by existing implementations.
  59.  
  60. |> 
  61. |> The other side of the coin is that it then becomes impossible for
  62. |> programmers to specify *whether or not* they want an inline implementation,
  63. |> which is a stated intent of the original ANSI-C standard library 
  64. |> macro/function implementations.
  65. |> 
  66.  
  67. I've never seen such an intent expressed.  Where is it stated?
  68.  
  69. Contrary to the way Jim uses the word, I don't consider
  70. whether a compiler inlines calls to a library function
  71. part of the "meaning" of that function.  And neither
  72. as far as I can tell does the standard.
  73.  
  74.   -- Jerry Schwarz
  75.