indirect reference/use of procedures

Larry Jones scjones at sdrc.UUCP
Mon Mar 19 08:23:08 AEST 1990


In article <A392C67xds13 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes:
> > void (* myfunc)();
> 
> > myfunc ();
> 
> I realise this is a valid syntax as of X3J11 (or whatever it is now that
> it's complete), but it's confusing. If nothing else, it breaks the symmetry
> between usage and declaration. C declaration syntax is confusing enough
> as it is, and declarations of pointers to functions particularly so. It's
> better to blow the extra three characters and call "(* myfunc) ();".
> 
> What did the committee have in mind when they decided to make this syntax
> part of the standard?

Would you believe => printf("Hello, world\n"); ?

Since "everyone knows" that you really use the address of a
function to call it (not the function itself), and since function
names usually turn into function pointers, it was far simpler to
specify that function "objects" "always" turn into function
pointers and that the function call operator requires a function
pointer.  It does make the call more readable, but it breaks the
declaration/use symmetry as you noted.

("Object" because functions are not, strictly speaking, objects,
and "always" because there is an exemption for sizeof.)
----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones at SDRC.UU.NET
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
"You know how Einstein got bad grades as a kid?  Well MINE are even WORSE!"
-Calvin



More information about the Comp.lang.c mailing list