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
[Caml-list] xor on booleans
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-02-03 (15:14)
From: Frederic De Jaeger <Frederic.De.Jaeger@e...>
Subject: Re: [Caml-list] xor on booleans

>> For type safety, it would be better to have 
>> let (^^) (x:bool) (y:bool) = x <> y

FLF> Type safety is not lost, since (^^) is just equivalent to (<>), which
FLF> is polymorph. The polymorphic (^^) is better if I want to define my
FLF> own boolean type: type bool = True | False, and use (^^) with it.

That's the point, it is polymorph.
Personally, I rarely need to define my own boolean type.  
On the contrary, I like that such code is refused  (I mistakenly  have
typed two '^' instead of one. That  happens)

let s = "hello " ^^ "word" in ...

That's why I suggested to restrict the allowed type of (^^).
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners