Re: When is @_ undefined?
- From: "Peter J. Holzer" <hjp-usenet2@xxxxxx>
- Date: Sat, 21 Jan 2012 12:53:34 +0100
On 2012-01-19 22:57, Ben Morrow <ben@xxxxxxxxxxxx> wrote:
Quoth Shmuel (Seymour J.) Metz <spamtrap@xxxxxxxxxxxxxxxxxxxxxxxxxx>:
In <87ehuv3h8y.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>, on 01/19/2012
at 02:21 PM, Rainer Weikusat <rweikusat@xxxxxxxxxxx> said:
Because he has successfully been fooled into believing that Perl
variables don't start to exist in some well-defined state by the 'use
of uninitialized value!' warning.
Isn't undef a well defined state?
I think that was Rainer's point: Perl variables are never 'undefined' in
the sense of the C standard,
Nitpick: The C standard never talks about "undefined variables", only
about "undefined behaviour". The value of a variable which hasn't been
(explicitely or implicitely) initialized ist "indeterminate".
so the 'uninitialized value' warnings tend to be more noise than
useful. They certainly aren't equivalent to the 'variable used without
being assigned a value' warnings C compilers are so fond of, which
often do indicate genuine bugs.
The 'uninitialized' warnings are badly worded. The warning really means
"you are using the value «undef» in a context where a defined value is
In perl's defence, they were much more useful back before 'my' and
'strict' were invented. In Perl 4 it was terribly easy to misspell a
variable name, and the only notice you got was (if you were lucky) an
'uninitialized value' warning. IMHO in Perl 5 they are redundant.
I don't think they are redundant. They are useful in cases where the
programmer thinks that a value should be defined but for some reason it
isn't. This usually indicates a bug.
Of course there are also situations in which the programmer *does*
expect a value to be undef and wants to treat it as '' or 0 - then it's
not a bug and the warning should be turned off. The 'uninitialized'
warning is certainly the warning I turn off most frequently. (The second
one is 'recursion' - if there are any others that I turn off, I do that
so infrequently I don't remember them).
_ | Peter J. Holzer | Deprecating human carelessness and
|_|_) | Sysadmin WSR | ignorance has no successful track record.
| | | hjp@xxxxxx |
__/ | http://www.hjp.at/ | -- Bill Code on asrg@xxxxxxxx
- Prev by Date: Re: ssh tunnel
- Next by Date: Re: When is @_ undefined?
- Previous by thread: Re: When is @_ undefined?
- Next by thread: Re: When is @_ undefined?