Browse thread
[Caml-list] infix functions
-
Jonathan Roewen
- Richard Jones
- Jean-Christophe Filliatre
- Vincenzo Ciancia
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-05-27 (11:14) |
From: | Vincenzo Ciancia <vincenzo_yahoo_addressguard-gmane@y...> |
Subject: | Re: infix functions |
Jonathan Roewen wrote: > Hi, > > I see some pervasive functions are infix, and I'm wondering if there's > any plan to support making any arbitrary infix functions? > > For instance, the Int32 (etc) modules are horrible to use cause of the > prefix functions. These are perfect candidates for being infix. Not arbitrary, but there are some "free" symbols that can be defined (I don't know exactly how many and what, but I guess it's on the manual or in the lexer :) ), and all the infix operators can be redefined. Example of redefining "+": ######## # module InfixInt32 = struct let (+) = Int32.add end;; module InfixInt32 : sig val ( + ) : int32 -> int32 -> int32 end # 3+3;; - : int = 6 # open InfixInt32;; # 3+3;; This expression has type int but is here used with type int32 ####### example of defining "+*" ####### # let (+*) = Int32.add;; val ( +* ) : int32 -> int32 -> int32 = <fun> # 30l +* 20l;; - : int32 = 50l ####### I don't know if there is a way to force inlining of "+*" though, but I suppose that you could finally resort to defining your operators in camlp4 http://pauillac.inria.fr/caml/camlp4/manual/manual006.html see section 5.3.1 Bye Vincenzo -- Please note that I do not read the e-mail address used in the from field but I read vincenzo_ml at yahoo dot it Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo vincenzo_ml at yahoo dot it