On 2008-May-3, at 5:12 pm, John M. Dlugosz wrote:
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote:
My own understanding of it is that "snapshot semantics" involves
looking at an immutable copy of an object (a "snapshot" of it)
instead of looking at the object itself. That said, my
understanding may be flawed.
Yes. How is a snapshot different from the object?
I would explain it as: "eqv" compares the "value" of two objects --
"snapshot" meaning the value at a specific time, since of course the
value might changes at different times while the object remains the
same. It's what other languages would call "==" (however they spell
"=="); in P6 "==" was already taken for numeric equivalence. So "$a==
$b" means "+$a eqv +$b" and "$a eq $b" means "~$a eqv ~$b".
Of course, for numbers and strings, the value/snapshot isn't different
from the object; but suppose I create two date-objects, $d1 and $d2,
both set to 2008-05-04. $d1 eqv $d2 would be true, but $d1===$d2 will
be false, because $d1 and $d2 are different objects (probably -- of
course, the implementation could be designed to notice that the dates
are the same and thus re-use the same object; it could also override
the object's identity (aka its .WHICH) to make it look like both
objects were really the same object). I believe the default identity
for objects will be something like P5's unique memory address.
Presumably the snapshot then takes whatever an object claims to be its
"value" and reduces any mutable parts into immutable values, until it
end up with something that consists wholly of immutable values.
-David