[redirected to perl6-language] Tom Christiansen wrote: > > Note the difference between > > my $var = func(); > > and > > my($var) = func(); > > Those are completely different in that they call func() in scalar > and list contexts. Why? Because of hte presence or absence of (), > of course. If they can't learn that adding () to the LHS of an > assignment makes it list context, then they will be forever miserable. > > Perl does context. Perl does *IMPLICIT* context. Cope. What bothers me is that () is used both for list context and grouping, so: % perl -le 'sub w { print wantarray ? "list" : "scalar" }; ($y=$x) = w' list and this doesn't work: % perl -le 'sub w { print wantarray ? "list" : "scalar" }; scalar($y=$x) = w' Can't modify scalar in scalar assignment at -e line 1, at EOF (Which isn't that big of a deal, since you can say ($y=$x)=scalar(w).) I don't have perl5.6, so I'm not sure what context sub f : lvalue; (f=$x)=1 would call f() in. List, I'd guess. But those parens do seem to be annoyingly overloaded (yes, I have run into this in actual code.) I wonder if it would be a good idea to make another way of grouping that only did grouping and not provide list context. Or to be more extreme, if () should be changed to do one or the other. The proposed list() would be much too verbose for such a common task, though. And nobody wants to lose either behavior of () anyway. (I hope.) How about making {BLOCK} lvaluable by default? Then it would be {$x=$y}=w. But that seems dangerously close to {}'s other overloaded meaning of anonymous hash ref construction. Or is it?