Newsgroups: comp.lang.c
Path: utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
From: flaps@dgp.toronto.edu (Alan J Rosenthal)
Subject: Re: procedure pointer question
Message-ID: <1988Jan16.202255.19152@jarvis.csri.toronto.edu>
Keywords: C function pointer
Organization: University of Toronto
References: <861@xn.LL.MIT.EDU> <7108@brl-smoke.ARPA> <4002@june.cs.washington.edu>
Date: Sat, 16-Jan-88 20:22:53 EST


In article <4002@june.cs.washington.edu> pardo@uw-june.UUCP (David Keppel) writes:
>
>[ (***sin)(x) <=> (**sin)(x) <=> (*sin)(x) <=> (&sin)(x) <=> sin(x) ]
>
>Bleah!  How do I tell the difference between a pointer to a function,
>a pointer to a pointer to a function, etc.?

Nowadays, a function used in an rvalue context (including as in "f(x)") is
converted to a pointer to that function, much like the array conversion to
a pointer to its zeroth element.  So the () operator takes a pointer to
function, not a function, despite appearances.

If 'f' is a function and appears in an rvalue context, it becomes a pointer
to function.  If it is then dereferenced, it becomes a function, which,
appearing in an rvalue context, is converted to a pointer to function.  This
can therefore be iterated any number of times.

Of course, I still consider it good style to write "(*pf)();" even though
it's not necessary.

ajr

-- 
"noalias considered sailaon"
