Re: eval() and lexical introspection in Parrot
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 Cset_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 Csub-outer_sub did not work for me before (segfault). Mehmet Soyturk
Re: eval() and lexical introspection in Parrot
On Wed, Dec 19, 2007 at 11:15:46PM +0100, Mehmet Yavuz Selim Soyturk wrote: 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. Actually, it would. The evaluated code would set the (outer) lexical variable the same way that inner blocks currently do. Pm
Re: eval() and lexical introspection in Parrot
On Wed, Dec 19, 2007 at 10:57:27PM -0600, Patrick R. Michaud wrote: On Wed, Dec 19, 2007 at 11:15:46PM +0100, Mehmet Yavuz Selim Soyturk wrote: 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. Actually, it would. The evaluated code would set the (outer) lexical variable the same way that inner blocks currently do. On second thought, if you mean that evaluated code would not be able to rebind an outer lexical variable, then you're correct. Simple assignment would continue to work, however. Pm