in reply to Perl6 - value vs. reference issues

I think you're missing the distinction between $a = $b and $a = %b. The first assigns the value of $b to $a, the second sets $a to be a reference to %b. If you to set $a to be a references to $b then you'd do $a = \$b (or possibly $a := $b).

As I understand it, the 'automatic taking of references' thing only applies when you're dealing with an array/hash/sub in a scalar context.

Judging by the work that's going on in parrot, $a = $b won't copy the value of $b immediately, but will create a 'copy on write reference'. A copy will only be made if either of $a or $b is modified.

Replies are listed 'Best First'.
Re: Re: Perl6 - value vs. reference issues
by jryan (Vicar) on Sep 14, 2002 at 19:30 UTC

    $a = \$b should set $a to be a reference of $b (a reference being an actual separate object), and $a := $b should set $a to be an alias of $b (an alias being only a name reference that is resolved at compile-time). I think thats the case, at least :)


    :^) # Fear the wrath of the hyper smiley!