Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!oliveb!Ozona!chase From: chase@Ozona.orc.olivetti.com (David Chase) Newsgroups: comp.lang.c Subject: Re: Partial application in C Message-ID: <24501@oliveb.olivetti.com> Date: 27 Jun 88 23:00:25 GMT References: <3353@cognos.UUCP> <619@goofy.megatest.UUCP> <807@garth.UUCP> <18609@cornell.UUCP> Sender: news@oliveb.olivetti.com Reply-To: chase@Ozona.UUCP (David Chase) Organization: Olivetti Research Center, Menlo Park, CA Lines: 62 (Replies, in no particular order) > With rare exception, I think we can all say that self-modifying > code is horrid, and anyone who writes it should be left alone. You should look a little harder about the example I provided. I was implementing an interesting (to some people) abstraction; the use of executed data was just one way to make this happen. The code, once written, does not later modify itself. Partial application is certainly less horrid than static data. If nothing else, it is re-entrant (unlike the Unix library). > [comments on pipelines] As a practical matter, since the "make_p_app" subroutine is machine-dependent, one can always write code that does the appropriate number of nops before returning the partially applied function. > [comments on caches] The first time around you can count on that code NOT being in the instruction cache. One hopes, for the sake of dynamic loading of code and similar things, that it is possible to get some sort of handle on the caches. Assuming that this is in fact true, then the machine-dependent make_p_app flushes the appropriate caches in the appropriate ways. > [comments on split I&D] I was aware of this, but wanted to know how pervasive this technique is. I'm not a real big fan of the technique precisely because it makes this sort of thing difficult, but then that appears to be a matter of taste. So far it appears that the following machines use separate I and D segments: some PDP-11s some 68ks (not Suns) HP3000 some 80386s (depending on segment registers?) > It's nice to have one's code segment protected from out-of-control > writes. I agree, and that is not incompatible with my implementation of partial application (it can't be, since my code segment is protected from out-of-control writes). (In fact, I agree so much that I have become a fan of garbage collection. As I said before, this is possible in C, and though it is very easy to write code that breaks the collector it is also very easy to write useful programs that do not.). I hope this covers all the various questions. I was sort of hoping that somebody out there would get excited about the idea of partial application, or maybe send details on how to do it on their machine. Someone also proposed a special widget for doing the rest of a partial application--I'm sorry, but that is totally uninteresting. I want a result that looks exactly like any other function, so I can pass it around, assign it to pointer-to-function variables, etc. David