Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site wjh12.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!decvax!genrad!wjh12!kendall From: kendall@wjh12.UUCP (Sam Kendall) Newsgroups: net.unix-wizards, net.lang.c Subject: (***f)(): PCC bug or legal C? Message-ID: <454@wjh12.UUCP> Date: Tue, 17-Apr-84 00:59:02 EST Article-I.D.: wjh12.454 Posted: Tue Apr 17 00:59:02 1984 Date-Received: Wed, 18-Apr-84 07:19:47 EST References: <264@basser.SUN> Organization: Delft Consulting Corp., New York Lines: 47 > So we take all of the bugs in PCC to be legal C? Try this [it works]: > > main() > { > int (*f)(); > > (*f)(); > (**f)(); > f(); > (******f)(); > } > > What piffle. Actually, although the last three calls are not legal according to the reference manual, it is only `f()' which is illogical. The principle (not quite in the reference manual) that makes `(***f)()' legal is: If a subexpression of function type appears in an expression not as the left operand of (), a pointer to the function which is the value of the subexpression is generated. Thus `*f' is of type "function", is converted to "pointer to function", can then be indirected again: `**f'. And so on. So `(***f)()' works. Unfortunately this principle is not quite in the ref man. What is there: If the name of a function appears in an expression not in the function-name position of a call, a pointer to the function is generated. This language has the unfortunate consequences that (1) a function name behaves differently than any other expression of function type, and (2) `f()' is legal but `(f)()' is not, so parentheses interfere with the semantics of the expression. If we fix up the ref man's language according to modern ideas of programming language semantics, in particular those from denotational semantics, we get something like my language above. The change does not make any practical difference; it just makes expression semantics simpler. They may not seem simpler, but they really are; I do not justify this statement, except to note that my change makes subexpressions of function type behave more like subexpressions of array type--and I do not justify this last statement either. Replies by mail, please. Sam Kendall {allegra,ihnp4,ima,amd70}!wjh12!kendall Delft Consulting Corp. decvax!genrad!wjh12!kendall