On 8/16/06, Darren Duncan <[EMAIL PROTECTED]> wrote:
At 11:42 AM +0300 8/16/06, Markus Laire wrote:
>On 8/16/06, Darren Duncan <[EMAIL PROTECTED]> wrote:
>>The difference between === and eqv is that, if you have 2 symbols, $a
>>and $b, and $a === $b returns true, then that result is guaranteed to
>>be eternal if you don't assign to either symbol afterwards.
>
>So do you mean that this code
> $a = "One";
> $b = "One";
> $aa := $a;
> say "Same before" if $a === $b;
> $aa = "Two";
> say "Same after" if $a === $b;
>would print
> Same before
> Same after
>because here I have "2 symbols, $a and $b, and $a === $b returns true"
>and I don't assign to either symbol afterwards - and you seem to be
>saying that only with mutable types like Array can you change the
>contents via another symbol ($aa here).
Thanks for catching that typo.
What you are saying with your above example is correct, and I knew
about that before, but it slipped my mind when I wrote my explanation
before.
I'll try saying what I meant differently here:
The difference between === and eqv is that, if you have 2 symbols, $a
and $b, and $a === $b returns true, then that result is guaranteed to
be eternal if you don't assign to either symbol [or other symbols
aliased to either] afterwards.
This is where the "eternal" part starts to confuse me (not picking on
your wording, but on the semantics). For example, suppose I say
<0> $a = "One";
<1> $b = "One";
<2> $aa := $a;
<3> say "Immutidentical" if $a === $b;
As I understand it, I'll see "Immutidentical".
If I insert the C<$aa = "Two"> before line 3, then I won't see "Immutidentical".
What happens if I insert the C<$aa = "Two"> before line 255? In other
words, can I rely on P6 to know at line 3 that there's an alias out
there by which C<$a> _might_ change without assignment later (i.e. the
guarantee that "$a and $b will remain the same unless you assign to
one" might be violated)?
What happens if the C<$aa = "Two"> is in an eval-equivalent, so the
compiler can't see it before runtime? Does the fact that the alias
exists violate the guarantee of immutability, or does the guarantee
just mean that at the instant the test is executed, both the contents
and container are the same? (If the latter, I'm not sure in what
practical situations I'd use it.)
If I've -- once again -- totally missed the boat, please be patient.
--
Regards,
Charles Bailey
Lists: bailey _dot_ charles _at_ gmail _dot_ com
Other: bailey _at_ newman _dot_ upenn _dot_ edu