I don't have any significant disagreement since you modified your assertion that using bare returns is a bad practice. And thanks--I found your other examples after my post.

Regarding:

   my %hash= ( key1 => genValue1(), key2 => genValue2() };

I did not find assigning a list to a hash artificial; just the naming indicated a made-up example. I didn't mean to imply that your code is outlandish or stretched beyond reason. If I understood how I implied that, I would try to avoid doing so in the future.

List to list assignments are expressive, but they can increase the complexity of error checking.

The bare return convention can be seen as filling arrays without useless elements and as promoting early validation.

I don't find your arguments about the convention breaking code convincing, because if the convention were in use the code would just be written differently. We are coming at this issue from very different places; I would not have said that I was talking about bare returns improving code in all cases. You are arguing from the bottom up, presuming the author's knowledge of what genValue1() can return; I see the value of these conventions in helping a reader to avoid the need to look up genValue1(). From that perspective, your example with scalar lc is beside the point because it is a builtin and so should be known.

If I were running a large team and only one of these conventions was lintable, I would find lintability to be a compelling argument. The readability-in-the-small aspect becomes less significant.

Be well,
rir

# bare return push @premiums, get_value( $_ ) for ( @xactions ); if ( @premiums ) { } # return undef for ( @xactions ) { push @premiums, defined( my $val=get_value($_) ? $val : (); } if ( @premiums ) { } ### # bare return my %hash; $hash{name} = get_name(); $hash{tag} = get_tag(); # return undef my %hash = ( name => get_name(), tag => get_tag() ); ### # bare return ( $second, $first ) = ( seconding(), firsting() ); if ( $first ) { } # return undef ( $first, $second ) = ( firsting(), seconding() ); if ( $first ) { }

In reply to Re^9: Module Announcement: Perl-Critic-1.01 ("scalar") by rir
in thread Module Announcement: Perl-Critic-1.01 by jthalhammer

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.