home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.fortran:3278 comp.std.c:2537
- Path: sparky!uunet!mcsun!Germany.EU.net!math.fu-berlin.de!Sirius.dfn.de!darwin.sura.net!wupost!cs.utexas.edu!swrinde!network.ucsd.edu!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
- Newsgroups: comp.lang.fortran,comp.std.c
- Subject: Re: Small Language Wanted
- Message-ID: <9224317.28165@mulga.cs.mu.OZ.AU>
- Date: 30 Aug 92 07:32:38 GMT
- References: <DAVIS.92Aug23010605@pacific.mps.ohio-state.edu> <H.3lvmyc56w&A@lionbbs.bs.open.de> <1992Aug27.181926.5677@alchemy.chem.utoronto.ca> <9224107.5975@mulga.cs.mu.OZ.AU> <DAVIS.92Aug27211418@pacific.mps.ohio-state.edu> <DAVIS.92Aug28015332@pacific.mps.oh <BURLEY.92Aug29143538@geech.gnu.ai.mit.edu>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- Lines: 46
-
- burley@geech.gnu.ai.mit.edu (Craig Burley) writes:
-
- >In article <1992Aug28.181327.25214@newshost.lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes:
- >
- > I apologise for posting this incorrect statement. In fact, all library
- > function names in ANSI standard C are reserved - the user can't define
- > his own. So the above comment only applies to old K&R implementations
- > which allow the user to do so. (It's what I get for remembering an old
- > public review copy of the C standard better than the final version.)
- >
- >Hmm, I don't remember this being true. I thought pow, for example, was
- >a reserved word only if one #include'd <math.h>, and so on. It's hard to
- >be sure without trying to grok the standard right now, but the (occasionally
- >inaccurate) "ANSI C: A Lexical Guide" seems to suggest that pow is not a
- >reserved word in the way if or for is, unless #include <math.h> is present.
- >And, okay I pulled out the standard, and it seems to agree with this; pow
- >is reserved only if you #include <math.h>.
-
- If you don't #include <math.h>, then "pow" is not a "reserved word";
- but I think that it *is* reserved as an external identifier.
- Thus something like
- static double pow(double x,double y) { ... }
- should be fine, but to omit the "static" as in
- double pow(double x,double y) { ... }
- could cause problems.
- [Maybe someone with copy of the standard in front of them can confirm this.]
-
- Note that it makes sense to prevent users from redefining standard library
- functions, because doing so could have all sorts of undesireable side-effects.
- For example, suppose you redefine pow as
- extern double exp(double), log(double);
- double pow(double x, double y) {
- return exp(y * log(x));
- }
- So far, so good. But what if exp happened to be implemented in the
- standard library as
- double exp(double x) {
- return pow(2.7182818284, x);
- }
- ? Now pow() will call exp() which will call pow() which will call exp()...
-
- --
- Fergus Henderson fjh@munta.cs.mu.OZ.AU
- This .signature virus is a self-referential statement that is true - but
- you will only be able to consistently believe it if you copy it to your own
- .signature file!
-