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

Binding scalars to aggregates

Thread Next
Ingo Blechschmidt
July 30, 2005 05:33
Binding scalars to aggregates
Message ID:

    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.)


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

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About