perl6-language  

Slurpy "is rw" arrays ([EMAIL PROTECTED] is rw)

Ingo Blechschmidt
Fri, 29 Jul 2005 03:22:45 -0700

Hi,

are the following assumptions correct?

    sub foo ([EMAIL PROTECTED])       { push @args, 42 }
    sub bar ([EMAIL PROTECTED] is rw) { push @args, 42 }

    foo @some_array;   # dies ("Can't modify constant array...")

    bar @some_array;
    # works, but does not change @some_array, as the * causes &bar to
    # receive a *new* array (which happens to contain @some_array's
    # elements), right?
    # @args is only an array constructed by the parameter binding code;
    # @args =:= @some_array is false (consider bar(@some_array, 42)).

    bar 1,2,3;         # works too

Or is @args always readonly and the declaration ([EMAIL PROTECTED] is rw) is an
error?


--Ingo

-- 
Linux, the choice of a GNU | Perfection is reached, not when there is no
generation on a dual AMD   | longer anything to add, but when there is
Athlon!                    | no longer anything to take away.