www.digitalmars.com         C & C++   DMDScript  

D - Dernel: !== operator documentation missing

reply "=?iso-8859-1?Q?Robert_M._M=FCnch?=" <robert.muench robertmuench.de> writes:
Hi, I just found out (by pure chance) that there exists an !== operator,  
which seems to be for comparing objects or so. I couldn't find any  
documentation about this operator. Using != to compare objects bombs the  
kernel... Would be nice if this operator is added to the documentation.

-- 
Robert M. Münch
Management & IT Freelancer
http://www.robertmuench.de
Feb 24 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Robert M. Münch wrote:
 Hi, I just found out (by pure chance) that there exists an !== 
 operator,  which seems to be for comparing objects or so. I couldn't 
 find any  documentation about this operator. Using != to compare objects 
 bombs the  kernel... Would be nice if this operator is added to the 
 documentation.
When I first read you message, I though you were asking how these operators work. Now, I think I misunderstood the nature of your request, but I've included some information that might be helpful if someone wants to see an example regarding this issue. [Comparing Objects] I included an example that demonstrates some valid syntaxes for comparing objects. The recent addition of the "is" operator may explain any lack of mention of the older "===" operator. It's important to remember that these operators compare *references*, so that even if the values of the object properties are identical, false is returned as long as the references are different. void main() { Object o, p; /* o and p are instantiated as separate (different) objects. */ o = new Object(); p = new Object(); if(o is p) printf("o and p are references to the same object.\n"); else printf("o and p are different objects.\n"); if(!(o is p)) printf("They're not the same.\n"); else printf("Yes, o is the same reference as p!\n"); if(o === p) printf("o and p are references to the same object.\n"); else printf("o and p are different objects.\n"); if(!(o === p)) printf("They're not the same.\n"); else printf("Yes, o is the same reference as p!\n"); if(o !== p) printf("They're not the same.\n"); else printf("Yes, o is the same reference as p!\n"); printf("\nNow I'm gong to make them the same...\n"); delete p; o = p; /* Now they're the same. */ if(o is p) printf("o and p are references to the same object.\n"); else printf("o and p are different objects.\n"); if(!(o is p)) printf("They're not the same.\n"); else printf("Yes, o is the same referenceas p!\n"); if(o === p) printf("o and p are references to the same object.\n"); else printf("o and p are different objects.\n"); if(!(o === p)) printf("They're not the same.\n"); else printf("Yes, o is the same reference as p!\n"); if(o !== p) printf("They're not the same.\n"); else printf("Yes, o is the same reference as p!\n"); } -- Justin http://jcc_7.tripod.com/d/
Feb 24 2004
parent "=?iso-8859-1?Q?Robert_M._M=FCnch?=" <robert.muench robertmuench.de> writes:
On Tue, 24 Feb 2004 17:45:12 -0600, J C Calvarese <jcc7 cox.net> wrote:

 When I first read you message, I though you were asking how these  
 operators work.
Hi, I just searched for them at some other D code and reverse engineered the semantic.
 I included an example that demonstrates some valid syntaxes for  
 comparing objects. The recent addition of the "is" operator may explain  
 any lack of mention of the older "===" operator.
Thanks a lot for this info. I must have missed this, even I scanned thru the docs yesterday... BTW: The === operator is still used in some Phobos code. Robert
Feb 25 2004