[nem-en] Nemerle 0.2.0 released
Michal Moskal
malekith at pld-linux.org
Mon Sep 13 22:34:50 CEST 2004
On Mon, Sep 13, 2004 at 08:44:46PM +0200, Marcin 'Qrczak' Kowalczyk wrote:
> Ricardo Fernández Pascual <r.fernandez at ditec.um.es> writes:
>
> > Maybe it would be a good idea having another operator for reference
> > equality? Like '===' or something similar.
>
> I believe that in languages where important types like strings and
> lists are immutable, there exists a single relation which is the
> appropriate meaning of equality most of the time.
>
> It's defined as identity if arguments are mutable, and as
> componentwise equality when they are immutable (and specially
> for builtin types like numbers).
>
> http://home.pipeline.com/~hbaker1/ObjectIdentity.html
>
> This would imply that a fallback to identity is not bad, as long as
> immutable "pure compound value" types are compared field by field by
> default.
Unfortunately there is a problem with operator overloading in .NET --
it's purely static :/ Which means that in our current compilation model,
the == operator will work as reference equality, when used on
polymorphic types. This AFAIK won't change when we switch to .NET
generics.
We could have make == be an alias to System.Object.Equals virtual call,
(which is unlike all mainstream .NET languages (*)) which would at least
allow user defined equality to be used for polymorphic types. Maybe it
is to be reconsidered, but we're not likely to do it, since (*).
Anyway, to allow field-by-field equality, we would have to use either
System.Reflection tricks (require pretty high .net permissions, are not
efficient), or generate proper Equals() methods. The second approach is
partially taken -- there is macro to generate it automatically.
> I wonder what types have had the mentioned equality bug in Nemerle
> compiler?
This was System.Type type. It is runtime type, probably mutable, but
conceptually immutable (there is no way to change it), except for
subclasses of System.Type, like TypeBuilder, used for runtime type
construction. So this is probably more complicated.
There were another example, but I cannot remember.
--
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: ::: Logic is a nice contrast to the Real World. :: UL++++$ C++ E--- a?
More information about the devel-en
mailing list