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

RFC: &CORE::keyword

Thread Next
From:
Father Chrysostomos
Date:
July 10, 2011 13:53
Subject:
RFC: &CORE::keyword
Message ID:
CB518059-3E05-44E2-BB30-88A7BF2B1D5C@cpan.org
This has been brought up a couple of times and no-one objected. But it was only mentioned in passing, so I thought maybe I should ask this directly:

Is this a feature we want?

I think so, as it allows core functions to be renamed:

*peruse = \&CORE::read;

And it allows one to write some things more concisely:

select undef, undef, undef, $interval;
&CORE::select((undef)x3, $interval);

OK, that only saved 2 chars, but you get the idea. :-)

Here’s a better example:

# Old style (I actually have code like this):
sub mytied(\[%@*$]) {
   ... do something special ...
   use Scalar::Util 'reftype';
   my $arg = shift;
   my $reftype = reftype $arg;
   if($reftype eq 'GLOB') {
       return tied *$arg;
   }
   elsif($reftype eq 'ARRAY') {
       return tied @$arg;
   }
   elsif(...) {
   ...
}

# New style:
sub mytied(\[%@$*]) {
   ... do something special ...
   return &CORE::tied($_[0]);
}

I’ve already started working on this.


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