NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Re: (Score:1)
What silly complaints.
for ( @foo ){ print "$_\n" }is fine butprint "$_\n" for @foo;is not? The obfuscatory bit, if there is one, is Perl’s strange attractor, the$_.I never followed the argument that trailing control flow constructs are somehow obfuscatory. What kind of retard does someone have to be if they understand
if( $foo ) { bar( $baz ) }but is totally lost as soon as it’s writtenbar( $baz ) if $foo? I’m not using “retard” in the name-calling sense either; I meanThe Mark of a Great Programming Language (Score:1)
Clearly the mark of a great programming language (if you're not a Lisp hacker anyway) is when a complete idiot who's never programmed before could maintain your code, not that that's pretty much the anti-pattern or anything.
(You should name your default variable
$itso everyone knows it's a pronoun.)Re: (Score:1)
An entire paragraph written using “it” as the subject in every sentence isn’t very readable. There are good reasons to want to use a named iterator variable. Mind, I don’t think
$_is inherently obfuscatory and I have no qualms about using it, though I do consider each case carefully. If you’re iterating over a list returned directly from a somewhat complex expression, then a well-named iterator helps document intent. And there’s only one$_, so in those cases where need access to outer iterators in nested constructs, being able to name iterators allows you to get the job done directly. These are some examples off the top of my head.The difference I’m claiming is that modifiers are obvious even if you don’t know Perl at all, whereas
$_needs introduction. Now, the non-modifierforform allows naming the iterator; but since that opportunity was passed up in the snippet in question, there is really no difference between either form.It baffles me what it is about modifiers that makes them so dangerous-looking. I bet if you ran a survey with 100 programmers who have never seen any Perl code and showed them a simple statement with a modifier, not one of them would have trouble understanding it, and I further bet that every single one of them would express concern that that looks obfuscated. Heck if I know why that’s so, though.
Reply to This
Parent
Re: (Score:1)
I agree. That also falls under my rule of "don't hire people who don't know what they're doing".
Re: (Score:1)