Re: Bug converting numbers?

From: Markus Mottl (
Date: Mon Sep 14 1998 - 12:13:56 MET DST

From: Markus Mottl <>
Message-Id: <>
Subject: Re: Bug converting numbers?
To: (Pierre Weis)
Date: Mon, 14 Sep 1998 11:13:56 +0100 (MET DST)
In-Reply-To: <> from "Pierre Weis" at Sep 14, 98 09:41:21 am

Hello - Bonjour!

> The problem here is that you missed the right equality predicate: you
> must use = instead of ==. Remember that == means unicity of
> representation, not semantical equality of values. For instance:

> Remember that the == predicate is not for casual uses: you should know
> something about value representations in your Caml system to use it
> safely. In doubt, use the regular = predicate.

Ah, everything clear! Having programmed in other languages lately, where
'==' means semantical equality, I easily read over this bug, although
I knew that there exist two operators for testing semantic equality or
representational identity respectively in Ocaml.

Especially, because:

# 1 == 1;;
- : bool = true


# 1.0 == 1.0;;
- : bool = false

This is certainly not, what the casual Ocaml-user expects...

Since there are probably many Ocaml-users who also use languages where
'==' expresses semantic equality (C/C++ is not the only one - e.g. Haskell
also uses this operator), wouldn't it be a good idea to take a different
operator than '==' for checking representational identity? As I had to
realize, such bugs can be really hard to track down. And since this
operator is probably not so often in use in "normal" Ocaml-programs,
it would not really effect too many developers.

Best regards,
Markus Mottl


Beaucoup de programmeurs en Ocaml aussi écrivent aux langues ou '=='
exprime l'égalité sémantique. Ne serait-il pas une bonne idée de
prendre un operateur différent en place de "==" pour exprimer l'identité
de représentation en Ocaml? Comme je ai du voir, il peut être très
difficile de trouver des erreurs de cette sorte.
Parce-que ce n'est pas un operateur souvant utilisé, je ne crois pas
que ce changement aie un effet fort aux developeurs.

Markus Mottl

*  Markus Mottl              |  University of Economics and       *
*  Department of Applied     |  Business Administration           *
*  Computer Science          |  Vienna, Austria                   *
*  |  *

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:16 MET