Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!pawl23.pawl.rpi.edu!jefu From: jefu@pawl.rpi.edu (Jeffrey Putnam) Newsgroups: comp.lang.misc Subject: Re: Call by string (was: B&D) Message-ID: <403@rpi.edu> Date: 29 Jan 89 11:10:12 GMT References: <4261@enea.se> <51300013@uxe.cso.uiuc.edu> Sender: usenet@rpi.edu Organization: Rensselaer Polytechnic Institute, Troy, NY Lines: 36 In article <51300013@uxe.cso.uiuc.edu> mcdonald@uxe.cso.uiuc.edu writes: >>Some while ago I asked the following: >>But to throw some new wood on the fire, consider the following: Assume >>you have routine you want to call but whose name you don't know until >>run-time, thus you have the name in a string. Now in which langauges >>can you easily do this? Interpreting langauges like Lisp and Basic, >>support this I guess. But compiled langauges? >I think that you are asking the wrong question, or maybe only a subset >of the full question. There are lots of languages (most?) where you >could find a way of getting to any routine known at original >compile-time. The real problem comes in getting at routines COMPILED >at run time. This often becomes an operating system question: it appears >that there are operating systems where it is impossible without >logging in from the operator's console. I have been following this discussion for a while and just realized this morning that it is possible that everyone has been asking the wrong question. (Parenthetically, i worked out a scheme whereby a C program compiled with debugging stuff on could read its symbol table and then jump to the address of the appropriate subroutine. Cute.) The question is, "why do you want to do this?" Im sure that there are valid reasons for wanting to do something like this, (i can think of many) but in most cases, what is wanted is not to be able to jump to just any subroutine, but only to some specific subset of the subroutines. In that case, there is no reason not to use a compiled table of "name -> address" as has been previously suggested. (But, as mentioned above, this compiled table might be produced by the C compiler (ick!).) jeff putnam -- "Sometimes one must attempt the impossible if only to jefu@pawl.rpi.edu -- show it is merely inadvisable."