Say I have this:
class A {
int k;
void B() {
write("foo %d\n", k);
}
void C() {
k = 3;
write("bar\n");
}
}
int main() {
A a = A();
a->C(); // Displays: bar
a->B(); // Displays: foo 3
// At this point I want to replace the function B
// in the running/compiled instance of A in a.
// I.e. I want to call compile() or similar
// on the following code:
// void B() { write("FOO %d\n", k); }
// such that I can subsequently run:
a->B(); // Should display: FOO 3
return 0;
}
Any way this can be accomplished?
An alternate way would be to compile the whole class of A again, but
then run method B() in it with a custom this argument pointing to the
old instance in a. Is that possible? I know javascript can do this,
but it seems like Pike does not allow/support it.
--
Stephen.