🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2603

Re: On whether C has first-class composable functions

#2603
From: Dan Bernstein
Date: Mon, 07 Jan 1991 03:32
16 lines
1503 bytes
In article <1991Jan6.205005.4579@mathrt0.math.chalmers.se> augustss@cs.chalmers.se (Lennart Augustsson) writes:
> In article <1991Jan05.222639.6387@dirtydog.ima.isc.com> karl@ima.isc.com (Karl Heuer) writes:
> >In article <1991Jan5.182428.615@mathrt0.math.chalmers.se> augustss@cs.chalmers.se (Lennart Augustsson) writes:
> >>[In C extended with anonymous functions, we could write compose():]
> >>	typedef int (*intintfun)(int);
> >>	intintfun compose(intintfun f, intintfun g) {
> >>	    return (int ANONYMOUS(int x) { return f(g(x))) };
> >>	}

Your definition of unnamed functions did not magically turn them into
function pointers. Either you are trying to return a function by value,
which is impossible in C without a *semantic* extension; or you are
returning a pointer to that function, in which case, as Karl said, the
pointer is useless after the return.

---Dan
Technical Details
Message-ID: <1988:Jan703:32:5191@kramden.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!sdd.hp.com!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd
References: <1991Jan5.182428.615@mathrt0.math.chalmers.se> <1991Jan05.222639.6387@dirtydog.ima.isc.com> <1991Jan6.205005.4579@mathrt0.math.chalmers.se>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!sdd.hp.com!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd
From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
Newsgroups: comp.lang.misc
Subject: Re: On whether C has first-class composable functions
Message-ID: <1988:Jan703:32:5191@kramden.acf.nyu.edu>
Date: 7 Jan 91 03:32:51 GMT
References: <1991Jan5.182428.615@mathrt0.math.chalmers.se> <1991Jan05.222639.6387@dirtydog.ima.isc.com> <1991Jan6.205005.4579@mathrt0.math.chalmers.se>
Organization: IR
Lines: 16