Rafael Garcia-Suarez via RT wrote:
>According to our records, your request regarding
> "overload "0+" doesn't handle integer
results"
>has been resolved.
I looked up the patch that was posted to perl5-porters, and
it solves
this issue only for int(). There's an equivalent bug still
there for
other operations:
$ perl -lwe '{ package t0; sub mynum
use overload "0+" => &mynum, fallback
=> 1; } printf "%dn", 0+t0::mynum; printf
"%dn", 0+bless({}, "t0")'
It works OK for plain printf "%d", but not for
addition. Also doesn't
work for subtraction, negation, multiplication, division,
remainder.
Does work for bit shift and bitwise OR. Perhaps some code
factoring is
called for.
-zefram
|