Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!sdrc!scjones From: scjones@sdrc.UUCP (Larry Jones) Newsgroups: comp.lang.c Subject: Re: indirect reference/use of procedures Message-ID: <1205@sdrc.UUCP> Date: 18 Mar 90 22:23:08 GMT References: <16702.25FE80FA@urchin.fidonet.org> Organization: SDRC, Cincinnati Lines: 33 In article , peter@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@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