Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!mintaka!spdcc!ima!dirtydog!karl From: karl@ima.isc.com (Karl Heuer) Newsgroups: comp.lang.misc Subject: Re: On whether C has first-class composable functions Message-ID: <1991Jan05.222639.6387@dirtydog.ima.isc.com> Date: 5 Jan 91 22:26:39 GMT References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <1991Jan5.182428.615@mathrt0.math.chalmers.se> Sender: news@dirtydog.ima.isc.com (NEWS ADMIN) Organization: Interactive Systems Lines: 14 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. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint