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

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

Thread Previous | Thread Next
From:
Yuval Kogman
Date:
July 12, 2005 04:12
Subject:
Re: WTF? - Re: method calls on $self
Message ID:
20050712111147.GC5565@woobling.org
I feel a "me too" post is in order.


I've written code that is 2-3 levels of nested given/when in a
method of an object that wasn't the topic.

I did not feel confused at all, juggling .foo and ./foo, which are
visually distinct, and different to type. They convey a big
difference of meaning, even if it's only 1 char apart.

I think a solution to the problem of being able to use those two
well, is not a solution, because there isn't a problem.

On Tue, Jul 12, 2005 at 12:59:22 +0200, Juerd wrote:
> Larry Wall skribis 2005-07-11 18:29 (-0700):
> >     is that we simply outlaw .foo notation at *compile* time in those
> >     scopes where we know (at compile time) that $_ and $?SELF diverge.
> >     In such a scope you *must* specify $_ or $?SELF (or equivalent).
> 
> What?
> 
> That makes having a default at all useless, it makes moving code without
> breaking it impossible again, it requires a lot of extra typing with
> shifted keys, it adds an arbitrary looking exception, and it is wildly
> undwimmy and impractical, and thus unperlish by every definition I know.
> 
> This is, by far, the silliest solution for this problem that I have seen
> proposed, because it is a combination of almost all the cons, and comes
> at a time in which all the pros and cons of other solutions are already
> known and discussed.
> 
> >     That's the default, and I'm not changing my mind ever again, at least
> >     till next week.
> 
> I can wait till next week.
> 
> > 	use self "this";
> > 	use self "self";
> > 	use self "o";
> > 	use self "./";
> > 	use self "";
> 
> Any of these must be the default, and frankly I do not care much which
> one it is, if that means the current non-solution goes away.
> 
> Obviously, use self "" is the least attractive of these, but I would
> still prefer it to outlawing .foo.
> 
> If the default isn't sane, the language isn't sane. That there is a
> pragma to change things, should never be a reason to stop picking good
> defaults.
> 
> >     Yes, this is possibly a hazard for cut-n-pasters.  But then,
> >     you weren't supposed to be cutting-n-pasting anymore, were you?
> 
> No, but I do refactor. I do add loops and methods around existing code.
> I do use for (or given in p6) to topicalize, to be able to type LESS.
> 
> In Perl 5, I really hate
> 
>     for ($object) {
>         $_->method(...);
>         $_->method(...);
>         $_->method(...);
>     }
> 
> And the Perl 6 equivalent until your revelation,
> 
>     given $object {
>         .method(...);
>         .method(...);
>         .method(...);
>     }
> 
> was the perfect solution. Killing off a useful and much used idiom even
> before the first release is quite an accomplishment.
> 
> Disallowing .method here means a huge step back in time. Back to
> $_.method or $object.method.
> 
> 
> Juerd
> -- 
> http://convolution.nl/maak_juerd_blij.html
> http://convolution.nl/make_juerd_happy.html 
> http://convolution.nl/gajigu_juerd_n.html

-- 
 ()  Yuval Kogman <nothingmuch@woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: uhm, no, I think I'll sit this one out..: neeyah!


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