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

[perl #74098] overload Pragma Should Warn About Unrecognized Overload Categories

Thread Next
From:
James E Keenan via RT
Date:
January 14, 2012 17:56
Subject:
[perl #74098] overload Pragma Should Warn About Unrecognized Overload Categories
Message ID:
rt-3.6.HEAD-14510-1326592596-1694.74098-15-0@perl.org
On Tue Apr 06 15:56:36 2010, chromatic@wgz.org wrote:
> This is a bug report for perl from chromatic@tamu.lohutok.net,
> generated with the help of perlbug 1.39 running under perl 5.12.0.

> When passed an invalid name of an overload category (due to a typo),
> overload.pm silently does nothing useful.  A warning about an
>    unrecognized
> overload category would be nice.
> 
> The text of such a message is up for bikeshedding, as well as the
>    possibility
> that future developments in the core may make new overload categories
> available.  Even so, the ease of making typos when using this module
>    argues
> for a warning.
> 
>     use 5.012;
> 
>     package Null;
> 
>     use overload 'bol' => sub { 0 };
> 
>     package main;
> 
>     my $nonnull = bless {}, 'Foo';
>     my $null    = bless {}, 'Null';
> 
>     for my $o ($null, $nonnull)
>     {
>         say $o ? 'Not null' : 'null';
>     }
> 

Am I correct in thinking that the operator spellings we would deem
correct are all found on the value side of this hash from overload.pm
(version 1.13, shipped with Perl 5.14.2)?

#####
%ops = ( with_assign      => "+ - * / % ** << >> x .",
     assign       => "+= -= *= /= %= **= <<= >>= x= .=",
     num_comparison   => "< <= >  >= == !=",
     '3way_comparison'=> "<=> cmp",
     str_comparison   => "lt le gt ge eq ne",
     binary       => '& &= | |= ^ ^=',
     unary        => "neg ! ~",
     mutators     => '++ --',
     func         => "atan2 cos sin exp abs log sqrt int",
     conversion   => 'bool "" 0+ qr',
     iterators    => '<>',
         filetest         => "-X",
     dereferencing    => '${} @{} %{} &{} *{}',
     matching     => '~~',
     special      => 'nomethod fallback =');
#####

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=74098

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