develooper Front page | perl.perl5.porters | Postings from January 2011

Re: Proposal: "$->" for implicit invocant

Thread Previous | Thread Next
From:
David Golden
Date:
January 16, 2011 16:12
Subject:
Re: Proposal: "$->" for implicit invocant
Message ID:
AANLkTin1mCCcYKnqKnwq8HJVa7M=BeopLHEWBaYjKkso@mail.gmail.com
On Sun, Jan 16, 2011 at 2:06 AM, Chia-liang Kao <clkao@bestpractical.com> wrote:
> "use feature 'invocant'" enables the $-> operator.  There are two
> variants:

If we're really pondering this sort of thing, why not think more
broadly and finally get around to dealing with method/object syntax?
(Like some of the syntax manglers on CPAN do.)

Hypothetically:

    use feature 'method';

    method foo {
        self->wibble($_) for @_;
    }

I.e. Given a "method" keyword, set up the invocant in some way and
leave it out of @_.  People can bikeshed the most efficient way to set
up the invocant -- in my example I have a bareword, but it could be
"$self" or "$*" (available now without a deprecation cycle) or
whatever else people dream up.

-- David

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