develooper Front page | perl.perl6.language | Postings from December 2001

Re: Apropos of nothing...

Thread Previous | Thread Next
From:
Piers Cawley
Date:
December 20, 2001 09:52
Subject:
Re: Apropos of nothing...
Message ID:
m2n10dx0cz.fsf@bofh.org.uk
Aaron Sherman <ajs@ajs.com> writes:

> On Sun, Dec 16, 2001 at 03:55:10PM +1100, Damian Conway wrote:
>
> [...]
>
>>    > And, just for laughs:
>>    > 
>>    > $ref = [1,2];
>>    > @ary[$ref] = foo();      # probably a syntax error
>
> Ok, as far as I can recall, Larry hinted that arrays and references to
> arrays would be interchangable in many contexts in P6. In this case, I
> can't see any reason that subscripting would *want* to do a SvIV on
> a known reference, so I would expect it to obey that logic and treat
> the reference as an array. Thus, I expect this to be list context for
> the exact same reason that:
>
> 	@bar = (1,2);
> 	@ary[@bar] = foo();
>
> would be.
>
> Next question, though:
>
> 	$val = (foo())[0];
>
> List?

Scalar, obviously. With a possible runtime error if foo doesn't return
an arrayref. And that should probably written as:

    $val = foo().[0]

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About