develooper Front page | perl.perl5.porters | Postings from August 2001

Re: Where should a test for pp_divide behaviour go?

Thread Previous | Thread Next
August 21, 2001 13:49
Re: Where should a test for pp_divide behaviour go?
Message ID:
On Sun, Aug 19, 2001 at 11:03:18PM +0100, Nicholas Clark wrote:
> Currently pp_divide reads both operands from the stack before testing
> the right operand to see if it is zero. This results in the following
> behaviour:
> perl -wle 'print undef()/0'
> Use of uninitialized value at -e line 1.
> Illegal division by zero at -e line 1.
> Do we wish to preserve this?
> Or is it fair to read the top argument from the stack, and if it is zero
> die with "Illegal division" before even inspecting the second argument?

I prefer to preserve this. The LHS being undefined will usually be 
unrelated to the RHS being 0, so this would indicate two problems
with the code. 

I'd see it as a service to the programmer when they can be reported 
at the same time, instead first reporting one issue, and then (after
a presumed fix of the problem) report the second issue.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About