Article View: comp.lang.misc
Article #2541Re: Look, Ma, I can dynamically compose functions in C!
From: David Chase
Date: Fri, 21 Dec 1990 19:12
Date: Fri, 21 Dec 1990 19:12
29 lines
1768 bytes
1768 bytes
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>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:
>
> struct basicfun { int (*f)(); } ;
> struct twofun { struct fun *first; struct fun *second; }
> struct fun { int type;
> union { struct basicfun b; struct twofun t; } u;
> } ;
Ah, but that is not a C "function", but something else (a struct).
You have to call it in a different way than ordinary C functions or
pointers to functions. You have not contradicted Lennart's assertion,
which is that functions in C are not first class objects. Try to pass
one of your "struct twofun" functions as a comparison function to
qsort, for example. And no, you don't get to redefine "function", or
rewrite qsort (much as it deserves it).
Ugh. Please read and think before posting, ok? It says here that
your message cost the net hundreds if not thousands of dollars to send
everywhere.
David Chase
Sun Microsystems
Technical Details
Message-ID:
<4978@exodus.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!rbbb.Eng.Sun.COM!chasedReferences:
<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!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!rbbb.Eng.Sun.COM!chased From: chased@rbbb.Eng.Sun.COM (David Chase) Newsgroups: comp.lang.misc Subject: Re: Look, Ma, I can dynamically compose functions in C! Summary: No, you can't Message-ID: <4978@exodus.Eng.Sun.COM> Date: 21 Dec 90 19:12:50 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@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 29