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

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

Thread Previous
From:
H.Merijn Brand
Date:
January 16, 2011 00:12
Subject:
Re: Proposal: "$->" for implicit invocant
Message ID:
20110116091207.2de6e314@pc09.procura.nl
On Sun, 16 Jan 2011 15:06:03 +0800, Chia-liang Kao
<clkao@bestpractical.com> wrote:

> Hi,
> 
> I just released the invoker module on cpan, and i'd like to
> propose the syntax to be included in future perls.
> 
> why: with the blooming modules providing the "method" keyword, we
> no longer need to have "my $self = shift" everywhere.  however
> this makes "$self" now the most repeated code.
> 
> Here's the idea:
> 
> "use feature 'invocant'" enables the $-> operator.  There are two
> variants:
> 
> - "use invocant '$self" looks for the specific lexical variable
>    named $self in the current context, and bails out in compile
>    time if not found.
> 
> - "use invocant 'auto'" looks for the first real pad entry in the
>    nearest scope as the default invocant.
> 
> I am not sure which one suites as better default behaviour.  the
> latter seems less intrusive on insisiting variable names by can
> be a bit confusing.
> 
> Conflicts:
> 
> $-> can be parsed as $- > ($- greater than .. ), so we need to
> deprecate the use of $- (and hopefully the whole format system by
> requiring use of formats to add additional "use format" line.)

This alone would cause me to try to issue a veto. Perl5 has format.
Period. And I use it. A lot.

> the feature can install a warning when accessing $- before such
> deprecation.
> 
> What do people think?
> 
> Cheers,
> CLK
> 


-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About