develooper Front page | perl.perl6.language | Postings from August 2006

Re: === and array-refs

Thread Previous | Thread Next
From:
Markus Laire
Date:
August 16, 2006 06:57
Subject:
Re: === and array-refs
Message ID:
67d53e40608160656o4a9228c2qe8631c51a14d9f9a@mail.gmail.com
On 8/16/06, Darren Duncan <darren@darrenduncan.net> wrote:
> 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.
>
> The idea is that, the degree to which === examines 2 variables to
> consider them equal or not is only so far as they are immutable.  So
> if you say "$foo = $bar", and then "$baz === $foo" returns true, then
> a subsequent assignment to or type-allowed mutation of $bar won't
> invalidate that $baz === $foo, but an assignment to $foo would.

IMHO the text "a subsequent assignment to or" is useless here because
I don't think any subsequent assignment to $bar could ever affect
$foo, even if they were mutable types:
    $bar = [1,2];
    $foo = $bar;
    ...
    $bar = 123; # This doesn't affect $foo

Of course, type-allowed mutation of $bar will affect $foo if $bar is
mutable type.

Still, thanks for clarification - I misunderstood what you meant with
"someone else holding another symbol".

-- 
Markus Laire

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About