Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!kullmar!pkmab!ske From: ske@pkmab.se (Kristoffer Eriksson) Newsgroups: comp.lang.misc Subject: Re: On whether C has first-class composable functions Message-ID: <4766@pkmab.se> Date: 13 Jan 91 15:46:41 GMT References: <1991Jan5.182428.615@mathrt0.math.chalmers.se> <4762@pkmab.se> Organization: Peridot Konsult i Mellansverige AB, Oerebro, Sweden Lines: 41 In article Benjamin Chase writes: >There is an unfortunate limitation of Kristoffer Eriksson's code, and >of other purported+ implementations of a composition function for C >functions. These implementations of function composition have not >been for C functions, but rather for monadic C functions that map >"int"s to "int"s. > >+("purported" is perhaps too strong a word; they didn't claim, but >seemed to have merely overlooked) For myself I can tell you that I haven't overlooked it. I acknowledge that my routines have that limitation, it just didn't seem worth mentioning it, since nobody ever talked about anything else. From the very first beginning, it has all been about int-to-int-mapping functions. Whether it should have been so or not is another question, at least from my position. >Can a (reasonably efficient and portable) compose function for (all) C >functions be written in C?* That depends on your goals (for instance, ease of use of the composed funcions and how complete you need it to be). I agree that it would be harder, and for certain (rather obvious) combinations of goals impossible. Treating the composed functions as ordinary C functions would make it hard to legally declare the compose function, for instance, so you would always have to cast the results returned by it. It could probably be added as a non-portable library function, this time written in assembler not C, though. I still want to point out that there are two ways of extending C. One way is to change it's syntax and semantics, which requires changing the compiler. The other way is to add library functions, sometimes (but not always, which may be considerd one of the strengths of C) written in other languages. The latter method does not require changing the compiler, and so is obviously much easier to do for most of us. At least this means there is seldom a total stop-gap to extending the language, if there is something you really desire. I also want to point out that I am still not making any claims regarding the original question about first-classnes of C functions or function pointers, although I hope some of it may add to the total picture. -- Kristoffer Eriksson, Peridot Konsult AB, Hagagatan 6, S-703 40 Oerebro, Sweden Phone: +46 19-13 03 60 ! e-mail: ske@pkmab.se Fax: +46 19-11 51 03 ! or ...!{uunet,mcsun}!sunic.sunet.se!kullmar!pkmab!ske