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

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

Thread Previous | Thread Next
From:
Larry Wall
Date:
July 14, 2005 13:39
Subject:
Re: WTF? - Re: method calls on $self
Message ID:
20050714203944.GF11335@wall.org
On Thu, Jul 14, 2005 at 12:55:26PM -0400, Nathan Gray wrote:
: So long as .foo (pretty please) means $_.foo 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
say

    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 $y.abc
	    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.

Larry

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