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] infix functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-05-27 (11:12)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] infix functions

Jonathan Roewen writes:
 > For instance, the Int32 (etc) modules are horrible to use cause of the
 > prefix functions. These are perfect candidates for being infix. And
 > being an OS project, there are a lot of instances where we need the
 > extra precision, and having to do things like add some_int32
 > another_int32 complex. Especially when you have to throw in
 > bitshifting, AND and OR, and other magic.

In some simple cases, it can help to insert

	let (+) = Int32.add
	let (-) = Int32.sub

at the  beginning of your files  (or better to  put these declarations
within  a small  module that  you open  only when  you need  the infix
notation).  You  can even  adopt  other  notations,  such as  +!,  -!,
etc.  Only the  first  character  is used  to  determine the  operator

Beware of the lexical issue with multiplication :-)

Hope this helps,