* ObPerl: How to explain to a class of complete novices why parens are needed
* in my ($x, $y); but if you follow a general rule of "put parens in
* everywhere until you figure out where you can leave them out" you get
* benign warnings "foo(...) interpreted as function"...
Because my acts as a "list modifier." The semantics are the same whether
or not you have the my:
$a, $b = $x, $y; # not too good
my $a, $b = $x, $y; # not too good either
($a, $b) = ($x, $y);
my ($a, $b) = ($x, $y);
No matter what you do, the = operator always has higher precedence
than the comma operator. Whether there's a my involved doesn't affect
that.
myterm : '(' expr ')'
{ $$ = sawparens($2); }
| '(' ')'
{ $$ = sawparens(newNULLLIST()); }
| scalar %prec '('
{ $$ = $1; }
| hsh %prec '('
{ $$ = $1; }
| ary %prec '('
{ $$ = $1; }
;
-joseph
--
Joseph N. Hall, 5 Sigma Productions mailto:" <joseph> "@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com