develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)

Thread Previous | Thread Next
From:
Joseph N. Hall
Date:
March 31, 2000 11:26
Subject:
Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)
Message ID:
MailDrop1.2d7j-PPC.1000331122605@perlfaq.com
> Are there other warnings, besides "Use of uninitialized value", that
> specify an operator?  Perhaps a patch to perldiag that explains this issue
> would be preferred?

There are many, but I don't know of a simple way to find them all.  For
example:

Perl_croak(aTHX_ "Can't coerce %s to integer in %s", sv_reftype(sv,0),
  PL_op_desc[PL_op->op_type]);

Perl_warner(aTHX_ WARN_NUMERIC,
  "Argument \"%s\" isn't numeric in %s", tmpbuf,
  PL_op_desc[PL_op->op_type]);

Perl_croak(aTHX_ "Can't coerce %s to string in %s", sv_reftype(sv,0),
  PL_op_name[PL_op->op_type]);

I don't know that there are many (or any?) that are as inherently
confusing as the issue with concat, though.

The classic example of "bad error message that probably seemed like a
good idea at the time" of course:

/usr/local/bin/perl5.003 -we '"@foo"'
Literal @foo now requires backslash at -e line 1, within string
Execution of -e aborted due to compilation errors.

perl -we '"@foo"'
In string, @foo now must be written as \@foo at -e line 1, near "@foo"
Execution of -e aborted due to compilation errors.

The first message seems quite reasonable to someone who knows the
history of "foo@bar.com" but as anyone who read clpm in those days knows,
it totally baffled newbies, who rightfully were unable to draw any
parallels between the behavior of "$undefined_thingy" and 
"@undefined_thingy" or understand what the meaning of "Literal @foo"
was or where the "required" backslash should go.  The current message
doesn't explain the crux of the problem but at least it leaves the
user at the station rather than putting him on the wrong train out of
town -- AND if he reads perldiag he'll get some reasonable clues.

I'm not completely convinced that adding markers to the bytecode
stream to indicate when run-time interpolation is in effect is such
a bad idea.  It might allow finer-grained control over interpolation
(with overload?  or?) as well as more accurate Deparse, both of which
might turn out to be quite valuable.  Just to resolve the problem 
with the warning message, though, it's way too much work.

  -joseph

--
Joseph N. Hall, 5 Sigma Productions        mailto:" <joseph> "@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perlfaq Prime  . . . . . . . . . . . . . . . . . . http://www.perlfaq.com


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About