[nem-en] Nemerle 0.2.0 released

Mark Friedman mark.friedman at gmail.com
Mon Sep 13 18:36:17 CEST 2004


I'm curious about the rationale for having the '==' operator not
fallback to reference equality?  I guess that it's not entirely clear
to me what the '==' operator actually means in Nemerle.  Is it
syntactic sugar for some method on System.Object (or its Nemerle
proxy)?  Is there some other method that returns true for reference
equality?  Is there an operator corresponding to that method?

-Mark

On Sun, 12 Sep 2004 18:44:33 +0200, Michal Moskal
<malekith at pld-linux.org> wrote:
>    * The `==' has no fallback to reference equality now. This means, that
>      if a class and its base classes have no overload for the `=='
>      operator, then using `==' on it is an error. There are two
>      exceptions: if (at least) one side of the `==' operator is
>      (exactly) of the System.Object type, or one side of the `=='
>      is the null literal, then reference equality is checked.
>      A few bugs in the compiler was pointed out by this (more restrictive
>      then in C#) feature. The same goes for the `!=' operator.
> 
>      All that means, that given:
> 
>        class A { }
>        class B : A {
>          public static @== (_ : B, _ : B) : bool { true }
>        }
> 
>      The following is OK:
> 
>        (A () : object) == (A () : object) // false
>        (A () : object) == A ()            // false
>        A () == null                       // false
>        (null : A) == null                 // true
>        B () == B ()                       // true
>        B () == null                       // true
>        (B () : object) == null            // false
>        (B () : object) == (B () : object) // false
> 
>      And the following are errors:
> 
>        A () == A ()
>        A () == (null : A) // (null : A) is not null literal
>        (B () : A) == (B () : A)
> ...




More information about the devel-en mailing list