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 15:16

On this subject, is it at all possible to call a function with a non-hard-coded arity given a dlsym?

That is:

#include <stdio.h>
#include <dlfcn.h>
#include <stdarg.h>
typedef int fp(void*,...);
void apply(void *h, char *f, ...) {
    void *s = dlsym(h, f);
    va_list a;
    va_start(a, f);
    (*((fp*)s))(a);
    va_end(a);
}
int main(int argc, char **argv) {
    void *h = dlopen(NULL, RTLD_NOW);
    apply(h, "vprintf", "%d %d %d\n", 1, 2, 3);
}


This obviously doesn't work; but is there some trick to working around having to prototype every function separately?

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