On 6 February 2013 19:14, Junio C Hamano <gitster@xxxxxxxxx> wrote: > demerphq <demerphq@xxxxxxxxx> writes: > >> As you mention below statement modifiers have their place. For instance >> >> next if $whatever; >> >> Is considered preferable to >> >> if ($whatever) { >> next; >> } >> >> Similarly >> >> open my $fh, ">", $filename >> or die "Failed to open '$filename': $!"; >> >> Is considered preferable by most Perl programmers to: >> >> my $fh; >> if ( not open $fh, ">", $filename ) { >> die "Failed to open '$filename': $!"; >> } > > Yeah, and that is for the same reason. When you are trying to get a > birds-eye view of the codeflow, the former makes it clear that "we > do something, and then we open, and then we ...", without letting > the error handling (which also is rare case) distract us. perldoc perlstyle has language which explains this well if you want to crib a description from somewhere. >> "unless" often leads to maintenance errors as the expression gets more >> complicated over time,... > > That might also be true, but my comment was not an endorsement for > (or suggestion against) use of unless. I was commenting on > statement modifiers, which some people tend to overuse (or abuse) > and make the resulting code harder to follow. That's also my point about unless. They tend to get abused and then lead to maint devs making errors, and people misunderstanding the code. The only time that unless IMO is "ok" (ish) is when it really is a very simple statement. As soon as it mentions more than one var it should be converted to an if. This applies even more so to the modifier form. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/" -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html