🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2671

Re: On whether C has first-class composable functions

#2671
From: Stephen E. Witham
Date: Thu, 17 Jan 1991 22:06
31 lines
2144 bytes
In article <BBC.91Jan12160209@sicilia.rice.edu>, bbc@rice.edu (Benjamin Chase) writes:
 
> Can a (reasonably efficient and portable) compose function for (all) C
> functions be written in C?* I'm still waiting for that existence
> proof...  :-) I believe that it cannot be done.  Actually, I'm not
> really waiting for the existence proof.  I don't really care to see
> such code.
 
Well, since you don't want to see it, I won't burdon you :-).  Actually, I
did think about it in my "purported" implementation of compose.

At first glance, you're asking for something against the way C works with data 
types: a function that works even though you feed it arguments of different 
types at different times.  For comparison, try writing a function that adds
two numbers and returns a long--only the arguments may be chars, unsigned
chars, shorts, unsigned shorts, ints, unsigneds or longs, or a combination.
The original question was about "first-class" composable functions.  I'm one
of those who thinks that "first-class" is relative to what you can do with
other things in the same language, so I think you're changing the rules here.

But...

Probably the most efficient way to do what you want would be to write 
different compose functions for different types of functions.

On the other hand, since we're faking functions with structures, we might
as well put declaration information into the structures.  This might slow
down the creation and composing of functions, but not their application.

--Steve Witham
Not-the-fault-of: SMDS, Concord, MA
Technical Details
Message-ID: <298@smds.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!bu.edu!m2c!jjmhome!smds!sw
References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <BBC.91Jan12160209@sicilia.rice.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!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: Super-flexible "compose" is getting beyond "first-class."
Message-ID: <298@smds.UUCP>
Date: 17 Jan 91 22:06:07 GMT
References: <442@data.UUCP> <4408:Jan421:44:3391@kramden.acf.nyu.edu> <BBC.91Jan12160209@sicilia.rice.edu>
Organization: SMDS Inc., Concord, MA
Lines: 31