On Tue, Nov 26, 2002 at 08:38:55AM -0600, Garrett Goebel wrote:
: James Mastros wrote:
: > On 11/17/2002 1:11 AM, Dave Storrs wrote:
: > > Arrays know how to manage their own size; they will grow 
: > > and shrink as needed when you add or remove elements.  You
: > > never need to worry about whether an array has enough space
: > > to hold the number of elements you are about to insert.
: > 
: > Reference to fixed-size lists, where this isn't true?
: 
: Do we have such a thing? In Perl5:
:  
:   use constant foo => [1,2,3];
:   print foo()->[0]++;
:   print " @{foo()}";
: 
: results in:
: 
:   1 2 2 3
: 
: 
: Does Perl6 have fixed size lists? Do we have fixed size lists with fixed
: elements? I.e., literal arrays?

You can declare an array to be constant, in which case it behaves as
a literal array of literals.

: >   In purticuar, /there is no such thing as a list in scalar
: > context/. There is mearly an application of the scalar comma
: > operator, and spacing that makes it look like a list.  The
: > context propigation rules say that there is no way for a
: > list in scalar context to happen. 
: 
: 
: Here I believe you are wrong.
: 
: Larry Wall, A2, RFC 175:
: >
: > the explicit list composer:
: > 
: >     [1,2,3]
: > 
: > is syntactic sugar for something like:
: > 
: >     scalar(list(1,2,3));
: 
: 
: > The documentation shouldn't
: > say things like a list returns it's last element whereas an
: > array returns it's size, because it simply ain't so, and 
: > causes confusion.  (I'd write an RFC suggesting that the 
: > scalar comma op dies, but it's too late, and I'm sure
: > somebody already did.  Anyway, that's a p6l thing too.)
: 
: This was covered in Apoc2. An explict list in scalar context returns a list
: reference. An array in scalar context returns an array reference. Or as
: 
: Larry (A2, RFC 009) wrote:
: > 
: > it has to be possible to assign array references to array
: > variables without accidentally invoking list context and 
: > copying the list instead of the reference to the list. We 
: > could invent another assignment operator to distinguish 
: > the two cases, but at the moment it looks as though bare 
: > variables and slices will behave as lvalues just as they 
: > do in Perl 5, while lists in parentheses will change to 
: > a binding of the right-hand arguments more closely 
: > resembling the way Perl 6 will bind formal arguments to 
: > actual arguments for function calls. That is to say,
: > 
: >     @foo = (1,2,3);
: > 
: > will supply an unbounded list context to the right side, but
: > 
: >     (@foo, @bar) = (@bar, @foo)
: > 
: > will supply a context to the right side that requests two 
: > scalar values that are array references. 

Except that we did end up going with the second operator to do binding.
But it's still the case that a comma list in scalar context assumes
[...] around it.

Larry

Reply via email to