Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The forced execution of souce code

Name: Anonymous 2009-11-19 5:27

How's called the ability of a language to interpret new code at runtime (the keyword/function that does this is typically called eval)?

For example Perl, Python, JavaScript and most shell languages have this. C and C++ haven't it.

Does Haskell have it? What about C#?

Note that shit like manually invoking the compiler doesn't count.

Name: Anonymous 2009-11-20 11:34

It's not just about executing "new" code, it's obvious you can do that in almost any language (however IMO it's an important distinction whether the language supports it natively or whether you have to manually supply an entire compiler implementation to do it).

What's interesting is
char buffa[9999];
i = 5;
gets(buffa);
eval(buffa);
printf("%d\n", i);

and then supporting an input like i += 1;

Obviously you're very fucked in C with normal compiled code, as the code itself has no notion of variable names, just to name the least of the problems.

So yeah, maybe you could call one type "dynamic" and the other "static", but I'm not sure this distinction and nomenclature are 100% right.

Name: Anonymous 2009-11-20 12:04

>>19
>Obviously you're very fucked in C with normal compiled code, as the code itself has no notion of variable names, just to name the least of the problems.
Not really... your eval function could just export i to the evalled program using plain old dynamic linking. Eval would prepend its input with "extern int i;" and everything would work great.

Name: Anonymous 2009-11-20 12:06

>>20
Only works for globals, can't do that for lexicals.

Name: Anonymous 2009-11-20 12:20

>>21
Why not? It isn't as automatic of course - you'd have to eval like eval(buffa, {{&i, "i", "int"}, {&j, "j", "long"}});, which is kind of ugly, but so is eval itself ;)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List