On Sat, 14 Dec 2002 19:09:43 -0500, [EMAIL PROTECTED] wrote:
>On 14 Dec 2002, at 21:45, Rafael Garcia-Suarez wrote:
>
>> What do you expect B::Deparse::coderef2text to do here ? Output
>> something equivalent to { 42 + shift } ? or produce an error ("can't
>> deparse a closure without complete lexical context") ?
>
>In fact, unless I'm misunderstanding how the closure works, "$constant"
>is exactly correct and '42' would be incorrect...  Isn't it the case that
>the subroutine could have as easily done:
>       sub { $constant++ + shift; }
>The fact that you *call* it "$constant" doesn't make it a constant, and
>the fact that it is a closure and its name is out of scope doesn't make
>it read only.  So I think that the deparse is as close to perfect as it
>could be, isn't it?

Yes.  It is the responsibility of the caller of coderef2text to make
sure any eval of the code occurs in the same lexical context as the
original code (if desired).  Given that this is, in general, possible,
Deparse should produce neither 42+shift or an error.

I certainly can't see any point in conditionally giving an error based
on where the "coderef2text" aktescalp e.

Reply via email to