Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site dg_rtp.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP Newsgroups: net.lang.c Subject: pointers to freshly minted functions. Message-ID: <204@dg_rtp.UUCP> Date: Thu, 6-Mar-86 18:48:33 EST Article-I.D.: dg_rtp.204 Posted: Thu Mar 6 18:48:33 1986 Date-Received: Sat, 8-Mar-86 21:25:07 EST References: <1700003@umn-cs.UUCP>, <1700004@umn-cs.UUCP> <6449@utzoo.UUCP> Lines: 40 > Some machines won't let you do what you want at all, in fact, > because on them, code is code and data is data and never the twain shall > meet. (Examples: a pdp11 running split-space; a segmented machine that > makes a distinction between code and data segments.) Taking "what you want" to be "creating an instruction stream, and then executing it", I think that what Henry says here is mildly misleading (though, not surprisingly, correct). Consider a C function which creates an instruction stream, and returns a pointer to a function which when invoked will execute this instruction stream. Here is a definition and an invocation of such a function (and an invocation of the function it returns a pointer to, for good measure). { void (*(make_callable_istream()))(); ... (*(make_callable_istream( &proto_istream )))(); ... } It must *always* be possible to implement this function, otherwise compilers would not be possible, since compilers are simply programs that treat code as data (though sometimes an implementation of the above function will have to start one or more new processes...) So, a machine where it is strictly true that "code is code and data is data and never the twain shall meet" makes compilers impossible. A more accurate phrasing of the restriction that Henry was thinking of might be "within a single process, code is code and data is data and never the twain shall meet". Now it may well be that the implementation of this function is so expensive to execute that it is impractical for some given application. This seems to be the case for the original query, which seemed to be about how to shave a few microseconds off of a "case" or "jump-table" construct. So it goes. > Henry Spencer {allegra,ihnp4,linus,decvax}!utzoo!henry -- (So I like to pick nits. What can I say?) -- Wayne Throop at Data General, RTP, NC !mcnc!rti-sel!dg_rtp!throopw