Version française
Home     About     Download     Resources     Contact us    
Browse thread
Type abstraction and (polymorphic) equality
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: padiolea@i...
Subject: Re: [Caml-list] Type abstraction and (polymorphic) equality
> Christophe TROESTLER wrote:
>> I'll be glad to hear similar experiences and comments about the above
>> ideas.
>
> In my opinion, it is a good idea to always define one's own comparison
> (and hash) function.

I know many people who have "defunctorized" the Map and Set modules
and hardcoded a call to the generic compare  to be able to use
Set and Map as easily as you use List.
Even with this generic compare those Set and Map seems quite good
enough (and far better of course that using List for representing
sets and associations).

> You know better than the compiler and the runtime
> system how your data is to be compared,

Well then you are perhaps agree with the C++ folks who think
that they better know how to manage memory than the compiler and runtime
system.

> which details should be ignored,
> how to deal with cycles, and so on. In addition, your custom functions
> will be more efficient than the generic ones.
> There are several tools to
> generate automatically comparison functions from type declarations.

Which one ? I know Tywith but it is not in the standard distribution
and it requires camlp4 and there is sometimes some annoying
behaviour when you use camlp4 (such as backtraces that points
to wrong information)

> I often redefine the comparison operators (=), (<=), ... with dummy
> types at the beginning of modules to avoid using them by inadvertence
> (this does not catch uses of List.mem-like functions, though).
>
> -- Alain
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>