On Wednesday 09 July 2008 15:37:51 Bob Rogers wrote:
> I suspect the motivation for the bizarreness of the specification is the
> desire to make code like this work in Parrot:
>
> {
> my $x;
>
> sub set_x { $x = shift }
> sub get_x { return $x }
> }
>
> ... except that there's no real way in Parrot right now to create an
> enclosing lexical block, activate it, and attach it as the outer to
> one or more Closures.
>
> -- c
>
> FWIW, I don't consider this bizarre; I've seen production code that does
> just this in order to share internal state between API functions. What
> would be bizarre is expecting set_x or get_x to be able to do anything
> meaningful before the outer block is executed.
That's what I meant by "bizarre".
> And it does work now, albeit with a little indirection; see
> bank-account.pir, attached. Or do you not consider this a "real way"?
That example is fine with me. I almost deleted all of the hijinks necessary
in Closure PMC to attach to a never-initialized outer lexical scope before I
read the lexical spec again and realized that someone designed it that way.
> At any rate, Leo said [1] that "autoclose" was something Audrey
> wanted, so I assumed it was here to stay. I'd just like to keep it from
> spreading. ;-}
Given the simplicity of the workaround (which actually works) and the
difficulty of making the broken-as-designed feature work partially, I vote
for removing the brokenness.
-- c