develooper Front page | perl.perl6.language | Postings from August 2001

Re: explicitly declare closures???

Thread Previous | Thread Next
John Porter
August 21, 2001 11:51
Re: explicitly declare closures???
Message ID:
Dave Mitchell wrote:
> foo() is a closure created at compile time. By the time the main {} block
> has been executed (but before foo() is called), the $outer:x is undef,
> and $foo:x is 'bar' (standard closure stuff). When foo() is executed,
> the anon sub is cloned, and at that time, $anon:x is set from from foo's pad,
> so it gets 'bar'.

That explains it.  I still don't like it. ;-)

> (I've changed 'closure' to 'outer' since John Porter's just pointed
> out to me privately that 'closure' is grammatical nonsense)
> So instead, I'd like
> "my outer $x" to be shorthand for

I guess you missed where I suggested that putting "my" on that
declaration is also counter-sensical, not to mention redundant.
"my" implies a brand-spanking-new lexical variable attached
to this very scope.  The semantics of "outer" (or "closed"...)
can be defined to imply a lexical variable.

John Porter

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About