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

pragmas [Was: Re: another take on hackers and painters]




Good to know ;-)

I think much of the prejudice against perl has to do with people (like me)
who only used it way back when there weren't a lot of the current options.

Perl seems to win the prize as the language with the most pragmas, by which
I mean language-altering special statements (maybe there is a better word
for this).  You got yer "use strict", "use warnings", etc. etc.
How do people feel about this feature in general?  I personally
like the idea of pragmas if there is no other way to get the same
flexibility, although I would probably have set the defaults differently
than perl's are set ;-)

Mike

> From: Piers Cawley <pdcawley@bofh.org.uk>
> Date: Fri, 23 May 2003 20:43:52 +0100
> 
> 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
>