On Thu, Jun 07, 2001 at 12:24:50AM +0100, Graham Barr wrote:
> 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"
A reason against making the behaviours ($foo=array vs. $foo=list)
different would be that you're then making lists and arrays more
distinct than necessary. Does this make $foo a reference, or the number
of elements:
$foo = (@bar=(1,2,3));
or this:
$foo = @bar = (1,2,3);
But on the other hand, what about?
$foo = (1,2,3);
@bar = (1,2,3); $foo = @bar; # Array in scalar context, so ref?
@bar = (1,2,3); $foo = (@bar); # "List" in scalar context, so number?
($foo) = @bar; # Array in list context, ...?
($foo) = (@bar); # List in list context, ...?
But then, what does this do?
$foo = (3, 4, @bar, 5);
Is the 2nd element treated as a "scalar context", so you get a reference to
@bar in there, or does list flattening still apply?
See, if you make $a=(1,2,3) take a reference just like $a=[1,2,3], this
frees up [] for something else. You could have () for flattening and []
for non-flattening lists. (Something somehow seems LISP-like about that
idea, but it's been too long...)
So that's an argument for, uh, something.... me going to sleep, I think.
Oh, one last thing: is
$a = @foo; # Perl 6
equivalent to
$a = [ @foo ]; # Makes a copy
or
$a = \@foo; # Takes a direct reference
?
The former extends to lists, the latter doesn't.
--
I don't understand how people can think SCSI is anything more quirky
than a genius with peculiar dietary requirements in a world where the
creators of Notes, and their new owners, are allowed to walk the streets
without fearing for their very lives. - Graham Reed, asr