On Mon, 2002-09-23 at 15:48, Luke Palmer wrote:
> On 23 Sep 2002, Simon Cozens wrote:
> 
> > [EMAIL PROTECTED] (Luke Palmer) writes:
> > > Since we now have an explicit flattening operator (unary *), there's no 
> > > need to differentiate between a "real" list and a reference to one.
> > 
> > What context does "push" impute on its operands?
> > 
> > If
> >      push @a, [1,2,3,4];
> > and
> >      push @a, 1,2,3,4;
> > are going to be the same, you'll have real problems. I don't fancy doing
> >      push @a, [[1,2,3,4]];
> > 
> > And if you get around that by special-casing push to take an list of scalar
> > contexts, then, well, urgh.
> 
> 
> Aha!  Kudos, Simon, this (alongside Aaron's message) was a stumper.  But I 
> think I've got it!
> 
>       push @a: [1,2,3,4];
> 
> pushes an array ref onto @a.
> 
>       push @a: *[1,2,3,4];
> 
> pushes 1, 2, 3, and 4 onto @a (as it would without the * and []).

Grrr... I want that to work, really I do, but since, as Larry has
pointed out, there's no functional difference between an array ref and
an array in Perl 6, they would be the same. This is because push is
almost certainly defined as:

        sub push(@target, *@list) { ... }

Regardless of this entire conversation, that problem exists in Perl 6 as
described in the apocalypses, doesn't it? The way to avoid this is to
say that array refs behave the same as arrays in every way *except* as
pertains to list flattening, and in that case, explicit flattening is
required, otherwise the ref is kept in the flattened array.

Does this make sense?
 
-- 
Aaron Sherman <[EMAIL PROTECTED]>

Reply via email to