function composition in C

Paul Broome broome at smoke.brl.mil
Fri Mar 8 07:01:23 AEST 1991


In article <347 at tslwat.UUCP> louk at tslwat.UUCP (Lou Kates) writes:
:
:In article <91060.132635REIDMP at MAINE.BITNET> REIDMP at MAINE.BITNET (Reid M. Pinchback) writes:
:>gwyn at smoke.brl.mil (Dough Gwyn) writes:
    >someone else wrote:
:>* >I don't think anyone was saying your method was not valid, but functional
:>* >composition returns a _function_ given two other functions.
:> 
:>* Which makes this topic unsuitable for discussion in the C newsgroup.
:>* In C, functions are always statically defined.
:> 
:>Isn't it a bit abrupt to forestall questions in this manner?  One of
:>the joys of reading newsgroups like this is to have the chance to
:>consider problems that we haven't thought of before; 
:
:Perhaps we need  to consider  what you   need to add to C to  get
:this with the minimal change to C.
:
:You should be able to do function composition in OO extensions to C...

True function composition is associative.  That is,
compose(f,compose(g,h)) = compose(compose(f,g),h).  A proposal for such 
extensions should consider whether this property will hold true.

Function composition is a very powerful concept as it's a good way to control
complexity.  But to be useful for programming in C you'd have to preclude
side effects.  This would completely change the character of the language.
Doug is right.  The topic is not appropriate (although it is interesting!).

One place to read more about it is in a recent book on Functional Programming
by Richard Bird and Phil Wadler or in the group comp.lang.functional.

-Paul
<broome at brl.mil>



More information about the Comp.lang.c mailing list