Not possible in the general case to the best of my knowledge. The only in-built object identifier is the address - so AFAIK there is no way of avoiding the (unlikely) situation of both objects getting the same address without adding some form of unique ID to the class.
It will also fail if either object overloads +, etc. to return something that is not the address - use refaddr if this is a concern.
If the reason you want this is to test that an object is being DESTROYed because it falls out of scope you can always use weaken like this.
I suppose you could do something totally evil, like overriding bless to store a UID somewhere for each object blessed. However this seems excessive :-)
Can you give us an idea of why you need to do this? I can't think of a situation where it would be necessary (although this is probably just a lack of imagination on my part).
Of course, if this is only an issue for one class it would be simplest to just add a UID slot to each object.
In reply to Re: Object identity?
by adrianh
in thread Object identity?
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |