develooper Front page | perl.perl5.porters | Postings from May 2010

Featurewish: Context aware operator overloading

Thread Next
Steffen Schwigon
May 25, 2010 06:36
Featurewish: Context aware operator overloading
Message ID:

Forgive me this passive way of just wishing a feature. I can't provide
more than a user's perspective. Anyway:

Would it make sense to make operator overloading context aware?

Currently an overloaded operator only runs in scalar
context. Therefore I do nasty dereferencing like

  my @list = @{ $data ~~ dpath '//affe/zomtec' };

just because the overloaded '~~' cannot return an array.

What I would want is

  my @list = $data ~~ dpath '//affe/zomtec';
  my $head = $data ~~ dpath '//affe/zomtec';

with the sub behind the overloaded '~~' doing the usual wantarray

I have, however, no more knowledge about this, except that someone
once said the original author of overloading hadn't found it
neccessary, IIRC.

And yes, I know that this would probably introduce trouble on
backwards compat. Maybe it can be protected by some “use feature”

Thanks for listening.

Kind regards,
Steffen Schwigon <>
Dresden Perl Mongers <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About