Python vs. Perl
nikander at mindspring.com
Wed May 23 05:26:01 CEST 2001
In article <slrn9gluo4.8icv.dek at socrates.cgl.ucsf.edu>, "David Konerding"
<dek at cgl.ucsf.edu> wrote:
>> I haven't used much Perl, but there is a huge difference from C/C++
>> because you can do dynamic stuff like:
>> str = getCommandFromSomewhere()
>> exec str
> Eh, you could always add some code to your app which inserts the code
> into a text file, compiles it, and dlopen's it, but I've never actually
> seen somebody do that :-)
I thought of a hack like that too... but I am not too familiar with dlopen...
Question: The code in the exec can make reference to variables that are "local"
to the place where "exec str" is. It inherits the local symbols. That is not
going to happen with the dlopen(), right? The "symbols" that were part
of a C program aren't around when it is compiled and running.
It would be pretty cool if there was a way to do a similar thing in C (without
reinventing Python/Lisp/etc). Maybe adding debug info to the executable
keeps enough symbol information around to pull this off?
More information about the Python-list