Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: A few random type questions. Message-ID: <8390@smoke.ARPA> Date: 28 Aug 88 05:32:46 GMT References: <530@accelerator.eng.ohio-state.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 41 In article <530@accelerator.eng.ohio-state.edu> mills@baloo.eng.ohio-state.edu (Christopher Mills) writes: >... if I say > foo; >outside of a block, I'll get a static int foo, right? No, you're supposed to get an extern int foo (which has static storage duration), initialized with value 0. > bar() { foo; } >obviously, the compiler can't determine if I mean auto int foo, or compute >the expression foo (I assume it assumes the latter). This is an ambiguity >in the grammar, yes? Sure, the compiler can determine what to do. You're asking it to evaluate the expression "foo" and discard the result. I don't know what you mean by "ambiguity"; the reason C has lots of rules is to determine the meaning of all valid constructs. If you want a private variable (with scope confined to the block that is the body of the bar() function), you must declare one. "foo;" is not a declaration inside a block. The reason it works as one at the file level is that there can be no executable code at that level. It is not good style in any case. >is there any real reason for the 'auto' keyword? Has anyone ever >used it for anything? "auto" is not necessary, and I don't know anyone who uses it, but I have seen code that did, presumably to emphasize the storage class, >is 'register int baz()' legal and if so would it make any difference anywhere. No, a function is not in general allowed to be put into a register. A pointer to a function is a different matter. >What (if ever) was 'entry' used for? It was intended for an alternate entry point to a function, as one sees occasionally in Fortran (the canonical example being SIN and COS). So far as I know it was never implemented anywhere. In fact I don't know what syntax could possibly have been intended for this.