Front page | perl.perl6.language |
Postings from May 2005
Re: single element lists
Thread Previous
|
Thread Next
From:
Autrijus Tang
Date:
May 11, 2005 14:18
Subject:
Re: single element lists
Message ID:
20050511211911.GB18511@aut.dyndns.org
On Wed, May 11, 2005 at 02:12:41PM -0700, Larry Wall wrote:
> On Thu, May 12, 2005 at 04:19:02AM +0800, Autrijus Tang wrote:
> : Hm? Under #2, no matter whether @foo is (1) or (1,2), the construct
> : (@foo)[0] would always means @foo.[0]. Not sure how the length of @foo
> : matters here.
>
> Tell you what, let's require P5's (...)[] to be translated to [...][],
> so (...)[] should assume scalar context that will return some kind of
> array reference. (What Luke said about (1,(2,3),4)[] still holds, though.
> Commas create lists, and lists by default impose list context, and
> parens are only for grouping in lists, not scalarifiying.)
Sure (and done). Now that #1 is eliminated, the question is now
whether a simple scalar can be treated as a small (one-element) array
reference, much like a simple pair can be treated as a small
(one-element) hash reference.
1.[0]; # evaluates to 1?
If yes, then (1)[0] means the same as 1.[0] and 1.[0][0][0]. If no,
(1)[0] is a runtime error just like 1.[0] -- i.e. unable to find the
matching .[] multisub under Int or its superclasses.
Thanks,
/Autrijus/
Thread Previous
|
Thread Next