On 23 February 2013 18:49, Mark H Weaver <m...@netris.org> wrote: > William ML Leslie <william.leslie....@gmail.com> writes: >> Recompiling every procedure that uses + when somebody binds it means >> compiling a lot of code that probably isn't going to be used. More >> likely, if + has been inlined here, the compiler will have to emit a >> guard that checks inlining assumptions as the start of the let body. > > I'm afraid this isn't good enough. Even if one ignores the possibility > of multiple threads, checks would have to be added not just at the start > of each let body, but also upon return from every procedure that might > rebind '+' or capture its continuation. This includes all procedures > accessed through toplevel/module bindings.
Not each let body, the let body in the example code. Specifically, a guard needs to be placed whenever code with undetermined effect happens-before a 'call' to an inlined function. That we are talking about happens-before means the possibility of runtime invalidation of code is limited not only by calls to functions of unknown effect, but also by usages of the variable. > Therefore, I repeat my initial assertion that this is a can of worms. Except that most dynamic compilers for imperative languages already do this (because it's a pretty common thing to need to do). -- William Leslie