# New Ticket Created by Bram
# Please include the string: [perl #53550]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=53550 >
(Continued playing with | - see #53482)
Consider:
#!/usr/bin/perl -l
use strict;
use warnings;
use overload
'""' => sub { $_[0]->{n}; },
'0+' => sub { die; },
fallback => 1;
my $x = bless { n => 4 }, "main";
my $y = bless { n => 8 }, "main";
for (1 .. 2) { print $x | $y }
__END__
This prints '<' twice.
Not using the fallback:
#!/usr/bin/perl -l
use strict;
use warnings;
use overload
'""' => sub { $_[0]->{n}; },
'0+' => sub { die; },
'|' => sub {
$_[0]->{n} | $_[1]->{n}
},
fallback => 0;
my $x = bless { n => 4 }, "main";
my $y = bless { n => 8 }, "main";
for (1 .. 2) { print $x | $y }
__END__
This prints 12 twice
(Tested on 5.8.8, 5.10.0 and blead)
Shouldn't the fallback of the binary or use the overloaded 0+ instead
of the overloaded ""?
Any thoughts?
Kind regards,
Bram
Thread Next