Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!yale!venus!yalevm!maine!reidmp From: REIDMP@MAINE.BITNET (Reid M. Pinchback) Newsgroups: comp.lang.c Subject: Re: function composition in C Message-ID: <91060.132635REIDMP@MAINE.BITNET> Date: 1 Mar 91 18:26:35 GMT References: <6873@munnari.oz.au> <1991Feb28.072757.1904@bingvaxu.cc.binghamton.edu> <15357@smoke.brl.mil> Organization: University of Maine System Lines: 28 gwyn@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.