[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: another take on hackers and painters



At 8:24 AM -0700 5/22/03, Jasvir Nagra wrote:
>Paul Prescod <paul@prescod.net> writes:
>
>>  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
>
>What horrible rumors! :-) At the risk of setting myself up as an
>apologist for Perl, how pedantic/helpful a programmer would like the
>language to be is configurable.  Perl will only ever try to interpret
>a string as a number if it is provided with a string where it expects
>a number.  Further if you're running with "use warnings" (which is the
>recommended option with which to run perl programs) then perl *will*
>complain if it tries to autoconvert not-a-number into a number.

Right, and those warnings can be set to be errors as well if you want.

The big reason for this is the origins of perl--it started as a 
language for quick-n-dirty sysadmin and text processing tasks and 
grew out from there. Many of the programs lived only on the command 
line, and many more were thrown together in a dozen or two lines of 
code. The data they dealt with was dirty, but dirty in predictable 
ways, and perl's defaults are shaped to deal with that. When you're 
throwing together a quick program to tally up data from log files, 
you don't *care* about the error conditions--it's bad data, and you 
want to ignore it. (Which is, in this realm, the appropriate action)

If you're looking for more caution, that's when you turn it on, by 
enabling warnings, or even more by forcing warnings to errors. That's 
fine, works the way we want it.

Yes, it does mean that you have to explicitly turn things on for 
larger programs, but that's no big deal--it's a larger program, so a 
little more code is no big deal. It's off for the small programs 
because if you went the other way and required it to be turned off 
for little programs that's be an awful lot of annoyance per line of 
code.

You may not agree with this decision, but that's fine--it's the right 
one for perl's original primary problem domain, and you can change 
the behaviour if you move into a domain for which it isn't 
appropriate.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk