Timo Paulssen via RT wrote:
>Well, assignment is implemented by calling .STORE on the scalar.
That's not usable in the way I'd expect:
> my $a = 3
3
> my $b = $a.VAR
3
> $b.STORE(5)
Cannot modify an immutable Int
in block <unit> at <unknown file> line 1
>The assignment operator is the operator to store into a Scalar.
The assignment operator requires an lvalue on its lhs. Where I have a
Scalar as an rvalue, I don't know how to make an lvalue from it.
>I'm getting the feeling we're not getting through to each other :)
Yeah. Let me try to make it clearer. In the above situation, with
a reference to $a's Scalar container in $b, I'd like to achieve what
the assignment "$a = 5" would, but by an operation using $b and not
directly mentioning $a. The result should be that $b is unchanged
(still referencing $a's container) and $a subsequently has the value 5.
Equivalent Perl 5:
$ perl -lwe '$a = 3; $b = \$a; $$b = 5; print $a'
5
"$b = 5", unsurprisingly, doesn't achieve it: that leaves $a untouched,
and changes $b so that it no longer references $a's container. Using the
code from my initial message on this ticket, "ss0($b, 5)" achieves what
I want, but apparently that's only due to the parameter handling bug
that you identified. I'd like a way that doesn't depend on exploiting
a bug. The answer could well look somewhat like either "$b.STORE(5)"
(a method on the Scalar object) or "$b.<> = 5" (making an lvalue from
the Scalar object), though as we've seen neither of these is correct.
-zefram