develooper Front page | perl.perl6.language | Postings from July 2005

Re: How to write a (Re: method calls on $self)

Thread Previous | Thread Next
July 12, 2005 09:55
Re: How to write a (Re: method calls on $self)
Message ID:
Autrijus Tang wrote:
> The compiler, in turn inspect whether there's an bound $_ in scope
> with $?SELF set.  It is not trivial, because this should work:
>     sub baz (&c) { c() }
>     method foo { baz { .bar } }	    # $_ is free in inner closure
> But this needs to fail:
>     sub baz (&c) { c(1) }
>     method foo { baz { .bar } }	    # $_ is bound in inner closure

I might still not understand topic, $_ or lexical vars in general.
But why does the fact that &c is called with a parameter
in the second case and without one in the first example make a
difference? Isn't $_ always coming in out of band? So .bar is always
invoked on the invocant of &foo if we think that there is an implicit
$_ := $?SELF before the call to &baz in &foo.  And I hope the binding
of $_ to $?SELF is a read-only binding!
TSa (Thomas SandlaƟ)

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