The closest I could see is to not really have the functions directly, I guess, but an mapping of functions, and overload `() so that it pulls the function from the mapping, then you could easily replace the function by replacing the reference in the mapping.
On Sun, May 2, 2021 at 12:32 PM, Stephen R. van den Berg<srb@cuci.nl> wrote:Chris Angelico wrote:
>trying to do won't work with injection. But perhaps subclassing can do
>what you want - instead of compiling the entire class again, create a
>subclass that replaces that one function.
Yes, well, that won't cut it, I'm afraid, because I specifically want
that function to be able to pretend that he is living inside the
already live/running older object of the old class (needs access to
those variables/members).
I'm trying to see how close I can get to rapid development where you
actually replace methods inside live classes during runtime.
On a related question then, if I do this:
class D {
class E {
void F() {
}
}
function G() {
E e = E();
return e->F;
}
}
int main() {
D d = D();
function ref = d->G();
d = 0;
gc();
// At this point, does object d still
// have references?
// Or is it gone because from F
// we do not refrence D?
return 0;
}
--
Stephen.