develooper Front page | perl.perl6.language | Postings from March 2005

identity tests and comparing two references

Thread Next
From:
Darren Duncan
Date:
March 31, 2005 23:46
Subject:
identity tests and comparing two references
Message ID:
p06210200be72a2d78369@[192.168.1.102]
As I continue porting code to Perl 6, I found something else that the 
synopsis don't seem to explain clearly.

What I want to be able to do is compare two references to see if they 
point to the same thing, in this case an object, but in other cases 
perhaps some other type of thing.

In synopsis 3, under the 'Binding' section, the =:= operator 
description is vague to the point that I don't know whether it 
applies to my problem or not.  All I know for sure is that '$x =:= 
$y' will return true if previously '$y := $x', and I think that is a 
different situation than my pair of references.

In Perl 5, a standard string compare just so happened to work for 
comparing two object refs, but that was inelegant.  In Perl 6 I need 
something better than comparing stringified ('eq') or numified ('==') 
versions of the objects.

The ref compare should have its own operator.

Now I seem to remember reading somewhere that '===' will do what I 
want, but I'm now having trouble finding any mention of it.

So, what is the operator for reference comparison?

Thank you. -- Darren Duncan

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