Graham Barr <[EMAIL PROTECTED]>:
>On Wed, Jun 06, 2001 at 04:01:24PM -0700, Larry Wall wrote:
>> [EMAIL PROTECTED] writes:
>> : > What should $foo = (1,2,3) do now? Should it be the same as what
>> : > $foo = [1,2,3]; did in Perl 6? (This is assuming that $foo=@INC
does what
>> : > $foo = \@INC; does now.) Putting it another way: does a list in
scalar
>> : > context turn into a reference, or is it just arrays that do that?
>> :
>> : Just arrays, I believe.
>>
>> That hasn't actually been decided yet. There are good arguments on
>> both sides.
>
>Can someone post a few ? I am open to what are the pros/cons
>but right now my mind is thinking " Whats the benefit of making
>$a=(1,2,3); be the same as $a=[1,2,3]; when it could do something
>different, ie what it does in perl5"
I'm wondering if () should keep its functionality as a list composer at all.
Perhaps it should just be:
$foo=($a, $b); #$foo is equal to $b
$foo=[$a, $b]; #$foo is an array ref
$foo={$a, $b}; #$foo is a hash ref
@foo=($a, $b); #same as @foo=$b (what would that do?)
@foo=[$a, $b]; #@foo is an array containing $a and $b
@foo={$a, $b}; #@foo is an array containing $a, '', $b, '' (?)
%foo=($a, $b); #same as %foo=$b (what would that do?)
%foo=[$a, $b]; #%foo is a hash containing $a => $b (?)
%foo={$a, $b}; #%foo is a hash containg $a => '', $b => '' (?)
Thus,
($a, $b)=($c, $d); #$b=$d
[$a, $b]=[$c, $d]; #$a=$c; $b=$d; (except inline)
{$a, $b}={$c, $d}; # ???
This means that each of the wraparound things has exactly one meaning,
regardless of context. It also gives () back its C meaning, grouping stuff
together so it'll be evaluated first, instead of a meaning that can be
different in different contexts. (In general, I think that "syntactic
operators" like parenthesis and comma should behave the same regardless of
scalar/list context, while functions should behave differently. That's just
my bias, though. Feel free to laugh at me if I'm wrong here.)
--Brent Dax
[EMAIL PROTECTED]