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

WTF? - Re: method calls on $self

Thread Previous | Thread Next
From:
Juerd
Date:
July 12, 2005 03:59
Subject:
WTF? - Re: method calls on $self
Message ID:
20050712105922.GH7720@c4.convolution.nl
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

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