English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
on objects, equality and playing nicely with the stdlib
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-05-29 (04:50)
From: Peng Zang <peng.zang@g...>
Subject: on objects, equality and playing nicely with the stdlib
Hash: SHA1

Hello list,

Recently, in building some toy games, I've started using objects.  I've been 
pleased with them and often find the subtyping convenient.

However, I've run into some issues with the standard physical equality of 
objects that the (=) operator performs.  Namely, it makes several stdlib 
modules difficult to use.  Modules that provides a polymorphic (generic) 
interface such as Hashtbl, List, Stack, etc.. rely on the (=) operator.  This 
is fine as long as it happens to be what I need.  The minute I introduce my 
own equality however, things break down.

What is the best way to go about using the stdlib (or similar) when you have 
your own equality function?  This problem almost never shows up if you just 
stick with basic data types, but with objects you quickly run into it.

Thanks in advance,

Version: GnuPG v2.0.7 (GNU/Linux)