On Mon, Nov 26, 2007 at 04:01:37PM +0200, Allison Randal wrote:
> Patrick R.Michaud (via RT) wrote:
> >
> >This isn't a super-huge priority at the moment... for the
> >time being we can simply have PCT not attach any :outer
> >flags to methods. But eventually we'll probably want to
> >have this working.
>
> Can you give me an HLL use case, so we get the implementation right? A
> .sub marked with :outer is one that's lexically scoped inside another
> .sub. So, a method marked with :outer is a method that's defined within
> another method/sub. Something like:
>
> method foo ($a, $b, $c) {
> ...
> method bar ($x, $y, $z) {
> ...
> }
> ...
> }
>
> Is that what you're looking for?
In Perl 6:
class ABC {
my $x = 0;
method foo() {
$x = $x + 1;
}
method bar() {
say $x;
}
}
$x is lexically scoped, which means that methods foo and bar
need to be marked with the class block as their :outer scopes.
Similar considerations may apply for inner classes, where we
end up with methods (of an inner class) inside of other blocks.
Pm