On 14 Dec 2002, at 21:45, Rafael Garcia-Suarez wrote:
> Randal L. Schwartz wrote in perl.fwp :
> >
> > sub black_adder {
> > my $constant = shift;
> > sub { $constant + shift; }
> > }
> >
> > my $to_deparse = black_adder(42);
> > use B::Deparse;
> > print "\n", B::Deparse->new->coderef2text($to_deparse), "\n";
> >==>
> >
> > {
> > $constant + shift(@_);
> > }
> >
> > Ayup. That's the one. *What* constant? :)
> 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?
Now, whether that's useful/interesting or ought to have generated an
error is a philosohpical question but I don't think the deparse, as it
stood, is really incorrect...
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
mailto:[EMAIL PROTECTED] Pearisburg, VA
--> Too many people, too few sheep <--