develooper Front page | perl.perl6.language | Postings from July 2005

Binding scalars to aggregates

Thread Next
From:
Ingo Blechschmidt
Date:
July 30, 2005 05:33
Subject:
Binding scalars to aggregates
Message ID:
dcfs2b$sk9$1@sea.gmane.org
Hi,

    my @array     = <a b c>;
    my $arrayref := @array;

    push $arrayref, "c";
    say ~@array;               # a b c d, no problem

    $arrayref = [<d e f>];
    say ~@array;               # d e f, still no problem

    $arrayref = 42;            # !!! 42 is not a Ref of Array

Should the last line be treated as
    $arrayref = (42,);
which, as the LHS is in scalar context, would auto-referize to
    $arrayref = [42];
which would work?

Or should that be an error?

(FWIW, I favour option 2.)


--Ingo

-- 
Linux, the choice of a GNU | Row, row, row your bits, gently down the
generation on a dual AMD   | stream...  
Athlon!                    | 


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