Juerd wrote:
No, again, please do not make the mistake of thinking VALUES have
identity. VARIABLES (containers) do. A reference points to a container,
never to a value directly.
I don't consider it a mistake. So, you dany identity to "fat" values
like database connections or GUI objects?
This is something that doesn't change from Perl 5 to Perl 6.
Why?
Try in perl (5) the following code:
my ($x, $y);
my ($xx, $yy) = \($x, $y);
Actually I still wonder how equal or different assignment
with = of a ref produced by \ is from binding with :=.
The second line above e.g. should produce a ref to a list
value (undef, undef), right? Then this value shall be used to
initializes the content of whatever the names $xx and $yy
refer to. So, why don't the references not just vanish and
we get to independent undef values stored in $xx and $yy?
I.e. do you expect $x = 5 have an effect on the value of $xx?
There are names, containers and values.
I agree.
Declaration and := bind names to containers.
I disagree. Names are a compile time concept and access to
the namepace level is restricted after compilation. Some
languages like C++ and Java actually compile the namespace
almost completely away. So Declaration is mostly a way to
talk to the compiler while := is a runtime operator.
Assignment copies values.
I agree.
Containers aren't copied.
I agree. Their content is retrieved and copied to a new container.
A reference points to a container.
Well, can we agree that a reference is a means to retrieve a value?
A name points to a container.
Yes, but see above for compile time.
A reference is a value.
I agree.
The reference isn't to $y's container's value, but to the container.
Regardless of its value. It is also not to the name $y.
I don't see much use in pointing to a container because the interest
is in the value unless to want to go in an explicit pointer arithmetic
scheme like C++. Does \$v + 1 mean something different than $v + 1?
To me it does at most create a level of indirection that is traced to
the value when the args for + are prepared.
How about the following idea to distinguish between read and write
refs? I would actually call the former View!
$x = 3;
$y = 5;
$rr = \$y; # read ref (or view)
$wr := $x; # write ref
say $rr; # prints 5
$rr = 7;
say $y; # prints 5 because $rr doesn't trace the view but discards it
# as any other non-referential value
say $wr; # prints 3
$wr = 9;
say $x; # prints 9 because $wr traces down to lowest container/ref and
# redirects it (my view) or exchanges the value (juerd's view)
Comments?
--
TSa (Thomas Sandlaß)