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

WHAT MAKES YOU THINK IT DOES NOT AGREE WITH MY CONCLUSION THAT $a IS SIMPLY IGNORED, AND A WARNING IS PRINTED?
Well, we can rely on the declared principle that warnings do not change anything about the execution of the program. Other than additional output to STDERR (and in the absence of a $SIG{__WARN__}, which this program clearly does not have), a program will always run identically whether warnings are on or off. Warnings do not change program execution flow. They merely turn on additional debugging output.

Second, we can test whether print actually "printed" in two ways. First, it'll return a true value indicating a "successful" print to an open filehandle with no I/O error. Second, we can alter something like $\ to add additional text to the print. I'm sure if you do either of those, you'll see that the undef was treated as the empty string, a warning was sent to STDERR, and the print completed its task. The print was not aborted.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Re: Re: Re: Re: dumb question
by pg (Canon) on Mar 16, 2003 at 16:31 UTC
    Did I say that was my last post in the thread. (Hm... remember I had some little discussion with the other merlyn last time, but this merlyn is not that hot tempered one ;-)

    First I never said that print was aborted, instead I said "ignored". Also I never said what being ignored is the print statement as a whole, instead, what being ignored is that $a.

    Now afetr had a good sleep, I am now thinking this side tracked doscussion is meaningless (so what I am saying is that the discussion started by the thread owner is absolutely meaningful and interesting, but not this sub thread.)

    Why do I say this sub-thread is meaningless? Because, in fact, there is actually no way to distinguish the differences of the two concolusions by observation from outside, i.e. any example makes conclusion 1 sounds right, would also make conclusion 2 sounds right.

    Conclusion 1:

    print treats undef as empty string and issues a waring.

    Conclusion 2:

    print ignores undef, and issues a warning.

    We would realize that, those two conclusions are actually identical, if we are willing to put aside our eagerness to disapprove the other side.

    merlyn, I would be more interested in discuss with you/fight against you about the strength and weakness of POE and thread, see you.

      Conclusion 1:

      print treats undef as empty string and issues a waring.

      Conclusion 2:

      print ignores undef, and issues a warning.

      Yes, we can distinguish between those. If print was merely ignoring the undef, then wouldn't
      $, = ", "; print "hello", undef, "goodbye";
      print only one comma? In fact, it prints two. So undef is not being ignored. It's considered an active member of the list, and being printed as an empty string, except that we get a warning if warnings are enabled.

      OK, it's the scientist in me, coming up with experiments to test the underlying model. {grin}

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.