note
vrk
<p>
They are. <code>funcall(<variable assignment>)</code> is a useful idiom in programming languages where assigment returns (an alias to) the value of the variable, but it is counter-intuitive at first. Even though I have been programming in Perl and curly brace block syntax languages for years, I still find it hard to read -- mostly because when you normally delimit <code>my</code> with braces, you create a new lexical scope. That's what <code>chomp(my $foo = bar)</code> still seems to be, even if I know better and use the idiom frequently.
</p>
<p>
Not only that, but it is not obvious that the value of <code>$var</code> in <code>chomp(my $var = <$fh>)</code> is being modified at all! After all, assignment, if used in other contexts, returns the value, not a reference to it. <code>my $foo = $bar = 1</code> doesn't create a reference in <code>$foo</code>, but sets the value of both variables to 1. In fact, I am not sure what the underlying mechanism is. Does it work because assignment returns an alias similar to aliased values in <code>@_</code> in function calls?
</p>
<p>
Side-effect free <code>chomp</code> has no similar conceptual problems.
</p>
<div class="pmsig">
<div class="pmsig-399589">
<p>
-- <br>
say "Just Another [href://http://prometheus.frii.com/~gnat/yapc/2000-stages/slide36.html|Perl Hacker]";
</p>
</div>
</div>
711531
711851