[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: another take on hackers and painters
Michael Vanier <mvanier@cs.caltech.edu> writes:
>> Date: Thu, 22 May 2003 14:12:35 -0700
>> From: Paul Prescod <paul@prescod.net>
>>
>> I think that the real problem reported by (ex-) Perl users is that Perl
>> sometimes sees string values that do not have reasonable integer
>> representations and rather than telling you that it just guesses that
>> you meant for the value to be 0. Often that will mask error conditions
>> (not just potential logic bugs, but errors that have been triggered). I
>> have a hard time believing that this is the behaviour you want often
>> enough for it to be the default. For the rare cases where you want
>> "convert the number if it is a number otherwise give me 0" I'd rather
>> say so explicitly. 0 is not necessarily the best fallback value anyhow.
>>
>
> It seems to me that the Right Thing, given that you want string->number
> autoconversion, is to try to do the conversion and raise an exception if
> the string cannot be reasonably converted to a number. Why doesn't perl do
> that?
use warnings FATAL => 'numeric';
There you go, job done for the current lexical scope.
--
Piers