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

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

Thread Previous | Thread Next
From:
=?ISO-8859-1?Q?=22TSa_=28Thomas_Sandla=DF=29=22?=
Date:
July 12, 2005 09:55
Subject:
Re: How to write a self.pm (Re: method calls on $self)
Message ID:
42D3F5ED.3090708@orthogon.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About