Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site ccvaxa Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!inuxc!pur-ee!uiucdcs!ccvaxa!aglew From: aglew@ccvaxa.UUCP Newsgroups: net.lang.c Subject: Re: To dereference or not dereference, Message-ID: <2600040@ccvaxa> Date: Wed, 12-Mar-86 22:58:00 EST Article-I.D.: ccvaxa.2600040 Posted: Wed Mar 12 22:58:00 1986 Date-Received: Sat, 15-Mar-86 03:39:44 EST References: <196@aplvax.UUCP> Lines: 33 Nf-ID: #R:aplvax.UUCP:196:ccvaxa:2600040:000:1067 Nf-From: ccvaxa.UUCP!aglew Mar 12 21:58:00 1986 >/* Written 4:55 pm Mar 6, 1986 by kwh@bentley.UUCP in ccvaxa:net.lang.c */ >In article <44@umcp-cs.UUCP> umcp-cs!chris (Chris Torek) writes: >> int f(), (*p)(); >> p = f; >> p(1); >> (*p)(2); >> (**p)(3); >> (****************p)(4); > >Although there is no excuse for "p(1)", the other three examples are >in fact correct. Recall that there are only two things you can do >with a function (not a pointer): call it (as in f()) or take its >address (any other use of the name). Thus "p = f" takes the address >of function f and stores it in pointer p. According to what I've heard about the ANSI C standard, "p(1)" is permitted, with a half-decent reason behind it. C does not let you have segmented names for functions. This way you can get them: struct { int (*draw)(); } graph; graph.draw = my_favorite_draw_function; graph.draw(); /* is equivalent to */ (*graph.draw)(); graph.draw is slightly cleaner, although more confusing. Now, if we could just initialize a function pointer with the address of an in-line lambda function.