function composition in C

Reid M. Pinchback REIDMP at MAINE.BITNET
Sat Mar 2 05:26:35 AEST 1991


gwyn at smoke.brl.mil (Dough Gwyn) writes:
* >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; its not like the
original poster cross-posted to a large number of irrelevant groups.
 
Functions are statically defined in C, but we can consider ways to
circumvent this.  I can think of three ways we can attempt this:
 
   1. Use data abstraction techniques to pass around lists of pointers
      to functions and 'compose' them on the fly;
   2. Generate compiled code for the compositions at run time and
      have the OS change the relevant data 'segment' into code.
   3. For reasonable mathematical functions, describe the function
      as lists of operators and variables.  Compositions could be
      as simple as changing one item in the appropriate data structure.
      Evaluation would consist of a list traversal.  This need not be
      as involved as something like implementing scheme in C.
 
Still sounds like C to me.
 
 



More information about the Comp.lang.c mailing list