🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2538

Re: Look, Ma, I can dynamically compose functions in C!

#2538
From: Lennart Augustsson
Date: Sat, 22 Dec 1990 00:14
51 lines
2374 bytes
In article <19468:Dec2100:23:0790@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>X-Original-Subject: Re: Complexity of syntax
>
>In article <1990Dec19.222059.6878@mathrt0.math.chalmers.se> augustss@cs.chalmers.se (Lennart Augustsson) writes:
>> To see the difference just try to write a function
>> that does function composition.
>
>Okay. (What follows isn't tested but you'll get the idea.)
>
>We'll work with a function descriptor type:
>
  [code for handling function stuff deleted]
>
>Of course, a more complete implementation would manage struct fun
>storage, possibly with garbage collection.
>
>A different strategy is to store basic functions as just pointers, and
>composed functions as a pointer to a special function, followed by the
>first and second pointers; then pointers to these ``objects'' would be
>passed in as arguments.
>
>Back to Lennart:
>
>> I claim that this is impossible to do in a portable way.
>
>You were saying?
>
I repeat what I was saying, you cannot write a function
int (*compose)(f, g) 
int (*f)();
int (*g)();

so that it can be used by

	(*compose(ff, gg))(x)

I did not claim that you cannot represent functions with some
suitable datastructures (which you have shown).  Of course you
can do what ever computable thing you want in C, but sometimes
you have to add a some extra stuff to represent what you want.
There is nothing strange about that since a language cannot
contain everything.

The second way you propose would be a way to solve the problem,
but how would you do it in a portable way?

I still make my old claim!


	-- Lennart Augustsson
Email:	augustss@cs.chalmers.se
Technical Details
Message-ID: <1990Dec22.001419.21222@mathrt0.math.chalmers.se>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!hsdndev!cmcl2!uupsi!sunic!chalmers.se!mathrt0.math.chalmers.se!augustss
References: <20@garth.UUCP> <27534.276e5bd3@kuhub.cc.ukans.edu> <1990Dec19.222059.6878@mathrt0.math.chalmers.se> <19468:Dec2100:23:0790@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!hsdndev!cmcl2!uupsi!sunic!chalmers.se!mathrt0.math.chalmers.se!augustss
From: augustss@cs.chalmers.se (Lennart Augustsson)
Newsgroups: comp.lang.misc
Subject: Re: Look, Ma, I can dynamically compose functions in C!
Message-ID: <1990Dec22.001419.21222@mathrt0.math.chalmers.se>
Date: 22 Dec 90 00:14:19 GMT
References: <20@garth.UUCP> <27534.276e5bd3@kuhub.cc.ukans.edu> <1990Dec19.222059.6878@mathrt0.math.chalmers.se> <19468:Dec2100:23:0790@kramden.acf.nyu.edu>
Sender: news@mathrt0.math.chalmers.se (Evald Nyhetsson)
Organization: Dept. of CS, Chalmers, Sweden
Lines: 51