"is" operator for structures?

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Wed May 9 09:54:31 PDT 2012


Yeah, that's what I did. I replaced it with opEquals(typeof(null)).

On Wed, May 9, 2012 at 8:45 PM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Wed, 09 May 2012 12:17:30 -0400, Gor Gyolchanyan
> <gor.f.gyolchanyan at gmail.com> wrote:
>
>> I didn't know structs actually have an "is" operator. Good to know,
>> there's a way to memcmp them this way.
>> But being able to overload it wouldn't do any damage. The overloader
>> of "is" should clearly know, that "is" is an identity check and not an
>> arbitrary domain-specific equality check.
>> Overloading "is" gives a syntax sugar for nullable structures and an
>> optimization opportunity for large ones (for example a CRC checksum
>> comparison).
>
>
> The fact that it's not overloadable is useful in many situations.  There are
> certain cases you are truly looking for physical equality, and not logical
> equality.
>
> Generally, if you want logical equality, use opEquals.
>
> -Steve



-- 
Bye,
Gor Gyolchanyan.


More information about the Digitalmars-d mailing list