Austin Schutz wrote:

        This is not related to the original topic, but I've always
wondered this: In math a number divided by 0 is "undefined". Why is it
that in a language which has an undefined value does the interpreter
poop out rather than just having the intuitively obvious behavior of
returning undef? Is that really by design, or just a legacy quirk they're
afraid to fix?

Austin



Which would you prefer?

$ perl -le '$x=1/0; print $x+1' Illegal division by zero at -e line 1.

or

$ perl -le '$x=1/0; print $x+1' 1

It only makes sense if "undef" in any arithmetic operation always gives "undef", which means that all variables have to be explicitly initialized to zero before you can perform any arithmetic on them. That breaks tons of useful idioms and generally adds programming overhead.

You shouldn't confuse "undefined" meaning "not definable" (math) with "not yet defined" (Perl).

David




Reply via email to