in reply to Re: Re: Re: dumb question
in thread post-increment and post-decrement behavior (was: dumb question)

Obviously wrong. ;-) This is kind of apple and orange thing. The analogy you drew here is misleading ;-)

  1. In the case you given, there is no space left for prediction, as the value for $a is SET, CLEARLY SET. What kind of prediction is needed? why any prediction is needed? Why any kind of prediction is allowed?
  2. In the case I gave, i.e. the case which this thread is all about, the value of $a is undef, NOT SET, so there is this wild space left for perl to predict. And as I pointed out Perl does this kind of prediction all the time, when it is reasonable, not when it is obviously unreasonable.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: dumb question
by jand (Friar) on Mar 16, 2003 at 06:30 UTC
    No, you are wrong. :)

    Seriously, in your example $a is undef, which already has a meaning. If you look into perlsyn.pod, you'll find:

    A variable holds the undefined value (C<undef>) until it has been assigned a defined value, which is anything other than C<undef>. When used as a number, C<undef> is treated as C<0>; when used as a string, it is treated the empty string, C<"">; and when used as a reference that isn't being assigned to, it is treated as an error. If you enable warnings, you'll be notified of an uninitialized value whenever you treat C<undef> as a string or a number. Well, usually.

    Printing provides a string context, so $a must be treated as the empty string, and not as 0. That $a becomes a number after the print statement has completed is totally irrelevant in this discussion.