Article View: comp.lang.misc
Article #2353Re: Pointers
From: Mike Meyer
Date: Tue, 10 Nov 1992 23:28
Date: Tue, 10 Nov 1992 23:28
41 lines
1717 bytes
1717 bytes
In <BxIoDv.72J@mentor.cc.purdue.edu>, hrubin@pop.stat.purdue.edu (Herman Rubin) wrote:
> In article <92Nov10.125426est.47525@neat.cs.toronto.edu> tlai@cs.toronto.edu (Tony Wen Hsun Lai) writes:
> >ALGOL 68 and SIMULA 67 have user-defined types, dynamic memory, and
> >free-form syntax, no? And why do you need explicit pointers to functions
> >when you can have procedure types, like Modula-2?
>
> You need explicit pointers to functions when the caller does not know
> the name of the function being called, but the caller has received a
> pointer to the function.
No, you don't need *explicit* pointers to functions. It's perfectly
reasonable (and I would argue, preferable) to allow function names
in argument lists. In C-oid style, this would be:
static char
hook_returning_char(void) {
return 'a' ;
}
int
main(void) {
extern void function_expecting_a_hook(char (void)) ;
function_expecting_a_hook(hook_returning_char) ;
}
And, in another file, have:
void
function_expecting_a_hook(char hook(void)) ;
blah() ;
foo() ;
bar() ;
hook() ; /* Note: invocation of function of unkown name */
bletch() ;
}
<mike
Technical Details
Message-ID:
<mwm.2lit@contessa.palo-alto.ca.us>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!decwrl!decwrl!contessa!mwmReferences:
<1992Nov7.115620.29967@syacus.acus.oz.au> <1992Nov10.024021.8724@linus.mitre.org> <92Nov10.125426est.47525@neat.cs.toronto.edu> <BxIoDv.72J@mentor.cc.purdue.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!decwrl!decwrl!contessa!mwm From: mwm@contessa.palo-alto.ca.us (Mike Meyer) Subject: Re: Pointers Newsgroups: comp.lang.misc Distribution: world References: <1992Nov7.115620.29967@syacus.acus.oz.au> <1992Nov10.024021.8724@linus.mitre.org> <92Nov10.125426est.47525@neat.cs.toronto.edu> <BxIoDv.72J@mentor.cc.purdue.edu> X-NewsSoftware: Amiga Yarn 3.4, 1992/08/12 15:49:52 Message-ID: <mwm.2lit@contessa.palo-alto.ca.us> Date: 10 Nov 92 15:28:39 PST Organization: Missionaria Phonibalonica Lines: 41