home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / fortran / 3276 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  3.5 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!burley
  2. From: burley@geech.gnu.ai.mit.edu (Craig Burley)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Small Language Wanted
  5. Message-ID: <BURLEY.92Aug29143538@geech.gnu.ai.mit.edu>
  6. Date: 29 Aug 92 18:35:38 GMT
  7. References: <DAVIS.92Aug23010605@pacific.mps.ohio-state.edu>
  8.     <H.3lvmyc56w&A@lionbbs.bs.open.de>
  9.     <1992Aug27.181926.5677@alchemy.chem.utoronto.ca>
  10.     <9224107.5975@mulga.cs.mu.OZ.AU>
  11.     <DAVIS.92Aug27211418@pacific.mps.ohio-state.edu>
  12.     <DAVIS.92Aug28015332@pacific.mps.oh
  13. Sender: news@ai.mit.edu
  14. Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139
  15. Lines: 51
  16. In-reply-to: jlg@cochiti.lanl.gov's message of 28 Aug 92 18:13:27 GMT
  17.  
  18. In article <1992Aug28.181327.25214@newshost.lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes:
  19.  
  20.    I apologise for posting this incorrect statement.  In fact, all library
  21.    function names in ANSI standard C are reserved - the user can't define
  22.    his own.  So the above comment only applies to old K&R implementations
  23.    which allow the user to do so.  (It's what I get for remembering an old
  24.    public review copy of the C standard better than the final version.)
  25.  
  26. Hmm, I don't remember this being true.  I thought pow, for example, was
  27. a reserved word only if one #include'd <math.h>, and so on.  It's hard to
  28. be sure without trying to grok the standard right now, but the (occasionally
  29. inaccurate) "ANSI C: A Lexical Guide" seems to suggest that pow is not a
  30. reserved word in the way if or for is, unless #include <math.h> is present.
  31. And, okay I pulled out the standard, and it seems to agree with this; pow
  32. is reserved only if you #include <math.h>.
  33.  
  34.    This policy of C will probably come back to haunt them: suppose the next
  35.    standard wants to add new functions to the standard library?  Reserving
  36.    the names will result in breaking any user codes which happen to have
  37.    functions with those new names.
  38.  
  39. Interestingly, the standard reserves _sets_ of names for various libraries.
  40. (See Section 14.3 of the Dec 7, 1988 draft; I doubt this has changed in the
  41. official standard.)
  42.  
  43. So, if you #include <math.h>, not only are the existing names like pow
  44. reserved, but so are all of them suffixed with "f" or "l" (which the lexical
  45. guide gives incorrect examples of, IMHO, since it gives examples like "lpow",
  46. while I think the wording means "powl").
  47.  
  48. And, if you #include <ctype.h>, not only are names like isspace reserved, but
  49. so are all names beginning with "is" or "to" etc.  (I'd give the grep patterns
  50. of reserved names as "(is\|to)[a-z][a-zA-Z0-9_]*", but I might be getting
  51. the first part wrong, as I don't recall the exact form of an "or" in grep.)
  52.  
  53. So, C programs _can_ avoid most problems with future versions or enhancements
  54. of C by avoiding the larger sets of reserved names (and, fortunately, it's
  55. quite easy to build tools that check your programs for you; actually, this
  56. seems likely to be easy using existing UNIX tools).
  57.  
  58. However, I think Fortran programmers have it a bit easier in that they can
  59. avoid the equivalent problem in Fortran just by saying "EXTERNAL FOO" anyplace
  60. they want to refer to FOO as something other than an intrinsic.  It's hard
  61. to really jump up and down over either approach -- the separated "intrinsic"
  62. reserved namespaces of ANSI C or the monolithic namespace with individual
  63. exceptions of Fortran -- but neither of them seems fatal to small or large
  64. applications.
  65. --
  66.  
  67. James Craig Burley, Software Craftsperson    burley@gnu.ai.mit.edu
  68. Member of the League for Programming Freedom (LPF)
  69.