Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

A further annoyance with the experimental features is that "use 5.018;" only enables some of them (e.g. 'smartmatch' is enabled while 'lexical_subs' is not). In addition, it would be useful if the error or warning messages actually stated what the related feature was (or vice versa).

Here's some examples.

This produces warnings about given and when (you need to know that the feature is smartmatch) and an error about "my" subs (you need to know that the feature is lexical_subs):

$ perl -Mstrict -Mwarnings -e ' use 5.018; my ($x, $y) = (1, undef); given ($x) { when (1) { say "\$x == 1" } default { say "\$x != 1" } } given ($y) { when (1) { say "\$y == 1" } default { say "\$y != 1" } } my sub z { say "In z()" } z(); ' given is experimental at -e line 4. when is experimental at -e line 5. given is experimental at -e line 8. when is experimental at -e line 9. Experimental "my" subs not enabled at -e line 12.

Also potentially confusing, is that the warnings are not emitted if the error is emitted first:

$ perl -Mstrict -Mwarnings -e ' use 5.018; my sub z { say "In z()" } my ($x, $y) = (1, undef); given ($x) { when (1) { say "\$x == 1" } default { say "\$x != 1" } } given ($y) { when (1) { say "\$y == 1" } default { say "\$y != 1" } } z(); ' Experimental "my" subs not enabled at -e line 3.

Enabling lexical_subs in the first example, the code runs but with lots of warnings. Note the warnings inconsistency of given/when mentioning the code but not the feature and lexical_subs mentioning the feature but not the code (which, in itself, is inconsistent with the lexical_subs error mentioning the code but not the feature):

$ perl -Mstrict -Mwarnings -e ' use 5.018; use feature "lexical_subs"; my ($x, $y) = (1, undef); given ($x) { when (1) { say "\$x == 1" } default { say "\$x != 1" } } given ($y) { when (1) { say "\$y == 1" } default { say "\$y != 1" } } my sub z { say "In z()" } z(); ' given is experimental at -e line 5. when is experimental at -e line 6. given is experimental at -e line 9. when is experimental at -e line 10. The lexical_subs feature is experimental at -e line 13. $x == 1 $y != 1 In z()

Adding 2 more lines of code to get rid of the warnings:

$ perl -Mstrict -Mwarnings -e ' use 5.018; use feature "lexical_subs"; no if $] >= 5.018, warnings => "experimental::smartmatch"; no if $] >= 5.018, warnings => "experimental::lexical_subs"; my ($x, $y) = (1, undef); given ($x) { when (1) { say "\$x == 1" } default { say "\$x != 1" } } given ($y) { when (1) { say "\$y == 1" } default { say "\$y != 1" } } my sub z { say "In z()" } z(); ' $x == 1 $y != 1 In z()

[In the above examples, replacing -e with -E and removing use 5.018; produces the same result.]

While something of a contrived point, I do note that the additional code I had to add in order to remove all of the warnings is of an equivalent size to the warnings themselves.

-- Ken


In reply to Re: What is the impact of 5.18.0? by kcott
in thread What is the impact of 5.18.0? by Tux

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (12)
    As of 2014-09-18 19:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (123 votes), past polls