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

Re: WTF? - Re: method calls on $self

Thread Previous | Thread Next
Larry Wall
July 14, 2005 13:39
Re: WTF? - Re: method calls on $self
Message ID:
On Thu, Jul 14, 2005 at 12:55:26PM -0400, Nathan Gray wrote:
: So long as .foo (pretty please) means $ all the time (with sugar on
: top?).

It means that all the time, but only when unambiguous.  If you say

    use dot;

it'll always be construed as unambigous.  You could go so far as to

    method foo($x) {
	my $y = .bar;	# $_ is self call because $_ := $?SELF

	given $y { use dot;	# "yes I know what I'm doing"
	    when 1 { .abc }	# calls $
	    when 2 { .bcd }	# calls $y.bcd

	.baz;		# back to self.baz

It's a little klunky but does localize the override rather visibly.
Doubtless people will generally put the "use dot" at the front though.


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