Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.misc Subject: Re: Call by string (was: B&D) Message-ID: <1316@goofy.megatest.UUCP> Date: 31 Jan 89 00:42:39 GMT References: <403@rpi.edu> Organization: Megatest Corporation, San Jose, Ca Lines: 41 From article <403@rpi.edu>, by jefu@pawl.rpi.edu (Jeffrey Putnam): ... > 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.) > Under BSD4.2 and Sun3, it is not even necessary to compile with debugging stuff. Just don't strip out the symbol-table. > The question is, "why do you want to do this?" ... The reason might be that the procedure you want to jump to was compiled after the main program was compiled, and was not, and could not be, known to the main program at the time of its compilation. I'll give you a real world example. Well, it's real world if you include manufacturing and testing computer parts as "real world". Let's suppose you have engineers all over the world who come up with designs for ASIC parts. Each of these part-specifications generates a procedure which tests the part. A program monitors loading chips or wafers by robot, interacting with the operator, etc., and it keeps timing calibration and other data concerning the tester itself. The program has to be able to call any of these part-specific procedures which had not even been written when the main program was written. But putting each part-specific procedure in its own process would be prohibitively expensive without some mechanism for shared data: It would take too long to initialize it with the calibration data, etc., and it would require too much memory, even with today's multimegabyte rams. So the program needs to read the part-specific procedure into memory, and then branch to it.