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

Re: .method == $self.method or $_.method?

Thread Previous | Thread Next
From:
Adam Kennedy
Date:
March 23, 2005 02:48
Subject:
Re: .method == $self.method or $_.method?
Message ID:
20050323072554.27166.qmail@lists.develooper.com
> At the moment I'm trying to see if I could get used to ..method meaning
> $_.method, and whether it buys me anything psychologically. 

At some point, adding another thing people have to remember in order to 
save one character gets a bit self-defeating, surely.

The good thing about $_.method is that it is familiar, quite compact 
anyways by virtue of using $_, and nobody is going to be surprised by it.

Personally (and I'm admittedly leaning towards simplicity lately) I'd 
even throw a warning for using .method when there is an explicitly named 
invocant as well.

# Good
sub foo {
	.bar;
}

# Possibly confusing, throw a warning or forbid under strict?
sub foo ($self:) {
	.bar;
}

# More obvious
sub foo ($self:) {
	$self.bar;
}

of course, since it is still preferable to be symmetrical, if $.attr is 
legal (and no warning) with a named invocant, then so should .method be.

Adam K

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