in reply to Re^8: Module Announcement: Perl-Critic-1.01 ("scalar")
in thread Module Announcement: Perl-Critic-1.01

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 ) { }