🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2596

Re: On whether C has first-class composable functions

#2596
From: Lennart Augustsson
Date: Sun, 06 Jan 1991 20:50
28 lines
1881 bytes
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))) };
>>	}
>>...the point is that you cannot add unnamed functions in a natural way
>>without getting the additional semantic power.
>
>I disagree.  Since the return value of the function references objects that go
>out of scope before the value would be used, I would expect this to analogous
>to   int *h(int i) { return &i; }   , which is undefined.
>
Do you think that 
	int f(int x, int y) { return x+y; }
is illegal just because the return statement contains variables that
goes out of scope when you return?
Returning an unnamed function is analogous (but I can imagine that an
implementer would like to make exactly your restriction since that would
make it much easier to implement).





	-- Lennart Augustsson
[This signature is intentionally left blank.]
Technical Details
Message-ID: <1991Jan6.205005.4579@mathrt0.math.chalmers.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!julius.cs.uiuc.edu!rpi!uupsi!sunic!chalmers.se!mathrt0.math.chalmers.se!augustss
References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <1991Jan5.182428.615@mathrt0.math.chalmers.se> <1991Jan05.222639.6387@dirtydog.ima.isc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!julius.cs.uiuc.edu!rpi!uupsi!sunic!chalmers.se!mathrt0.math.chalmers.se!augustss
From: augustss@cs.chalmers.se (Lennart Augustsson)
Newsgroups: comp.lang.misc
Subject: Re: On whether C has first-class composable functions
Message-ID: <1991Jan6.205005.4579@mathrt0.math.chalmers.se>
Date: 6 Jan 91 20:50:05 GMT
References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <1991Jan5.182428.615@mathrt0.math.chalmers.se> <1991Jan05.222639.6387@dirtydog.ima.isc.com>
Sender: news@mathrt0.math.chalmers.se (Evald Nyhetsson)
Organization: Dept. of CS, Chalmers, Sweden
Lines: 28