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

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

Joseph N. Hall
March 31, 2000 09:45
Re: [ID 20000330.052] Use of uninitialized value in concatenation (.)
Message ID:
I'll grant that it seems as if Perl's innards were designed with the sole
objective of making it hard to distinguish between an explicit use of dot and
a concatenation arising from interpolation.

The simple fix is just change the message.

  Use of uninitialized value in concatenation (.)


  Use of uninitialized value in concatenation (.) or string interpolation

which would mean changing a line in opcode.h.  I don't see any problem
with calling the concat op "concatenation (.) or string interpolation"
because that's an accurate description of what it is.  It's not just the
dot operator.

The only way to effect a fix that actually distinguishes between is to
introduce some change to an op or a new op, and it would be difficult.
I can see three basic options:

(1) split concatenation into different ops

(2) add something to the concatenation op that indicates what kind of
    concatenation it is

(3) add another type of marker op like COP that marks the begin/end of
    string interpolation (and indicates what sort of string it is etc.)

(1) seems like a Bad Idea, (2) seems unlikely to work because by the time
a concat op gets generated, the context of how it was generated is already
lost in the lexer.  But (3) might work.  

What are the negatives of (3)?  It adds bytecode bloat, probably a 
small but significant amount (1-5 percent?) because string interpolation 
is a common operation.  It probably has no significant effect on speed.
It's hard to implement and would add more obfuscation to the lexer.

So I vote for the one-liner fix.  I dispute the claim that the current
message is "accurate information" because, as I said above, the concat
op in the innards of perl is not just the dot operator, and therefore
characterizing it as such is inaccurate from both the perspective of the
naive user and from the perspective of what's really happening.

It's unfortunate that the design of the lexer and run-time innards don't
allow for a good error message, but that's how it is.

  -joseph Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About