This reference about flexibility of English that are common in Perl advocacy circles is somewhat problematic. Programming language are limited by the capabilities of syntax parser. Idea of post-fix statements in Perl is not bad per se as in this case if/unless/while/for, etc serves as a proxy for semicolon and terminate the statement in a special way and such things are within the capabilities of LR 1 parser.

But there is no free lunch. More often than not it leads to additional complications.

For example, it allows enough rope to lead to troubles with the debugger. As you can see below, in v5.26.3 the debugger accepts the statement {$i=5; $j=20) } if( $new_cycle ); which is clearly a violation of the Perl grammar.

Why it is accepted?

DB<100> $new_cycle=1 DB<101> { $i=5; $j=10 } if( $new_cycle ); DB<102> p "i=$i,j=$j" i=,j=
And now even more interesting:
DB<104> { $i=5; $j=10 ) } if( $new_cycle );
No syntax error detected.

Interpreter catches those errors as it should:

perl minitest.pl syntax error at minitest.pl line 2, near ");" syntax error at minitest.pl line 4, near "10 ) " syntax error at minitest.pl line 4, near ");" Execution of minitest.pl aborted due to compilation errors. /cygdrive/f/_Scripts/Pl2py [255] # cat -n minitest.pl 1 $new_cycle=1; 2 { $i=5; $j=10; } if( $new_cycle ); 3 print "i=$i,j=$j\n"; 4 { $i=5; $j=10 ) } if( $new_cycle );
But even $i=5, $j=10 if( 1 ); which is legit, is a a little but too much rope; enough to hang yourself. Again, I would limit postfix statements to loop control statements, return/exit/die and a couple of others. But this is just me.

In reply to Re^8: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff by likbez
in thread What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff by likbez

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.