http://qs1969.pair.com?node_id=369192


in reply to Re^3: Surviving 'Illegal division by zero'
in thread Surviving 'Illegal division by zero'

And, this is the way to "directly re-open the method definitions". In fact, it's safer to do it this way than it is to redefine it for the whole program. That kind of "action-at-a-distance" is the source of more maintenance nightmares than anything else.

Totally agree. Before Abigail's post I hadn't really thought of it in OO (obj-oriented and op-overloading) terms. To put what you're saying in, uh, ahem, pseudocode, it's the difference between globally redefining a core method

class Float alias :old_divide :/ def / (other) other == 0 ? nil : old_divide(other) end end

and subclassing, which is all good

class MyFloat < Float def MyFloat.new(from) from.to_f() end def / (other) other == 0 ? nil : super(other) end end MyFloat.new(4) / 0 # nil
A last concept to leave you with - if someone were to take your code and wrap it in something else, which is the politer way to handle things?

Sure, it's a library. I was wondering if there was something scoped lexically analogous to:

use warnings; { no warnings qw/once/; $foo = 5 - $bar; } { no warnings qw/uninitialized/; $foo = 5 - $qux; }

Thanks