[Mono-devel-list] Comparing against null

Jonathan Gilbert 2a5gjx302 at sneakemail.com
Fri Apr 8 19:07:53 EDT 2005

At 05:11 PM 08/04/2005 -0400, Ben Maurer wrote:
>On Fri, 2005-04-08 at 16:45 -0400, Ben Maurer wrote:
>> On Fri, 2005-04-08 at 01:37 -0400, Miguel de Icaza wrote:
>> > Hello,
>> > 
>> > > This usage lies somewhere in the gray, murkey watters between ugly and
>> > > wrong. I'd advise you find some other way to do what you want.
>> > 
>> > Is our compiler buggy, yes or no?
>> > 
>> > Independently of how ugly and wrong something is, if we have introduced
>> > a bug, it must be fixed.
>> It sounds like it is a bug. I guess I mistook the behavior that applied
>> to delegates as being representative of what happens with all
>> userdefined operators.
>Btw, see http://bugzilla.ximian.com/show_bug.cgi?id=67410

I just wanted to contribute to this thread (for all readers, not just Ben
:-), simply because nobody has mentioned it yet, that there IS an official
way to always do a reference check: ReferenceEquals(a, b). I do not know if
the JIT recognizes when this compares against null and simplifies it to
brtrue/brfalse, but it seems like an obvious -- and simple -- thing to do
(just need to be careful that the user hasn't created their own 'new'
static ReferenceEquals function).

Jonathan Gilbert

More information about the Mono-devel-list mailing list