I see no reason why it should

Well, (a) because nobody has offered any other workable semantics for it, and (b) because it's what some programmers expect it to mean anyway.

Well...

  1. there's the noop semantics which at least has the advantage of being consistent;
  2. this is a non sequitur: I would accept the reasoning if the vast majority of them did, but do they?

As far as the first point is concerned... why should that have a semantics at all? That is, why should it be valid syntax? (Exactly my point!) Really, quite a lot of things are not. One that springs to mind and may be somewhat related is the ability to define an aggregate and populate a slice of it in a single statement. Indeed the question why

my @foo{@bar}=@baz;

"does not work" is sometimes asked, even if not terribly often. The semantics is intuitive here:

my %foo; @foo{@bar}=@baz;

But then again, you never declare a slice, only scalars and aggregates as a whole. There's a logic in this. Parsing issues apart and however appealing it may seem to have another way to save some keystrokes, implementing that syntax would go by and large against any logic. Similarly in the situation we're discussing.

As for the second point: before reading your post, I wouldn't have imagined it. Maybe that's just me, but I'm sure it wouldn't be intuitively obvious to all. To me, it's just ugly: I wouldn't struggle to have valid syntax with that semantics for a construct that is not particularly useful anyway.

when STATEMENT is equivalent to STATEMENT1; STATEMENT2;

But that will always break down with statement modifiers, even in cases not involving a combination of compile-time and run-time actions.

Indeed. But then why should the behaviour be different in cases involving such a combination?!? I would just say: one more reason for not wanting to mess with it.


In reply to Re^7: Curious result of using "my ... if ..." by blazar
in thread Curious result of using "my ... if ..." by jrw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.