🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2698

Re: On whether C has first-class composable functions

#2698
From: Stephen E. Witham
Date: Fri, 25 Jan 1991 17:21
56 lines
3611 bytes
In article <BBC.91Jan21120817@sicilia.rice.edu>, bbc@rice.edu (Benjamin Chase) writes:
> Long ago, I challenged:
> 
> >> Can a (reasonably efficient and portable) compose function for (all) C
> >> functions be written in C? ... I believe that it cannot be done. ...

I'm omitting most of his posting (about a response of mine to his challenge) 
here...
 
> I admit that my challenge for an implementation of function
> composition suited _my_ tastes of what would constitute a useful
> implementation of "function composition", and may bear no relation to
> anyone else's.  If that is what you mean by "changing the rules", then
> certainly I am guilty.  Nevertheless, my challenge remains unanswered.

Ben, it's true that your challenge hasn't been answered, at least by me, and
I want to explain my view of what HAS been going on in this thread.

First of all, note the "Subject" line, "Whether C has first-class" blah, blah.
I remember someone asking that question LONG, long ago.  The way I took that
original question (based on the phrase "first-class," which to me is relative to
how things are done in the rest of the language) was, "Can C compose functions 
as well as it can do other things?"  And the eventual answer was, "Well, 
almost as well."

Then you came in and said, "This doesn't answer the original question
because it's not polymorphic." (paraphrase).  That's what I meant by "changing
the rules."  It seemed to me that the ORIGINAL challenge HAD been answered,
but you were walking into the middle of a discussion with a harder challenge,
and then berating us for having not having answered it already.

Maybe what happened was, you were the original poster on this thread, but
your question got watered down (even in the Subject line) before I joined in.
If so, I'm sorry, but I wish you had explained that.

Now to your challenge.  I think you COULD whip up something,
using variable-argument functions, structures with type information in them,
a garbage collector, etc., that would meet the letter of your challenge.
It would be kind of painful, which I think is sort of your point.

BUT.  Composing functions is something really neat that you might actually
want to do in the context of a C program (I know because I've needed to
myself), and it's actually reasonable to do.  The sensible, less painful way
is not to try to imitate Lisp in every detail, but to do it the way you do
other things in C.  Meaning, partly, that functions have fixed numbers of
fixed-type arguments, functions with different numbers or types of arguments
are in turn of different types, and when you want to do the same operation on 
two incompatible data types, then you write two different functions.  Also,
complex entities that are created at run time go into dynamically-allocated
structures that have to be freed if you want the space back.  This is terrible?

I mean, Why pick on C?  Why talk about doing something in C if you don't like
the way things have to be done there?

--Steve Witham
Not-the-fault-of: SMDS, Concord, MA
Technical Details
Message-ID: <305@smds.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!bu.edu!m2c!jjmhome!smds!sw
References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <BBC.91Jan21120817@sicilia.rice.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!bu.edu!m2c!jjmhome!smds!sw
From: sw@smds.UUCP (Stephen E. Witham)
Newsgroups: comp.lang.misc
Subject: Re: On whether C has first-class composable functions
Summary: Two different challenges
Message-ID: <305@smds.UUCP>
Date: 25 Jan 91 17:21:18 GMT
References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <BBC.91Jan21120817@sicilia.rice.edu>
Organization: SMDS Inc., Concord, MA
Lines: 56