> One temporary workaround that I considered for this problem > would be to have eval() use introspection on its caller to > create a "wrapper sub" that duplicates the lexical environment of > the caller, and then use that as the target of an :outer() > flag when it's passed to imcc. For example, the code > passed to imcc would end up looking something like:
That workaround will not solve the problem for an assignment to a lexical variable from evaluated code. Maybe it's not a problem for Perl6 tests, though. It would be good if there was an opcode C<set_outer inner_sub, outer_sub> to set the outer of a sub at runtime. I don't know if it's possible/straightforward to implement though. Just assigning a new value to C<sub->outer_sub> did not work for me before (segfault). Mehmet Soyturk