Browse thread
[Caml-list] Associativity precedence for the user-defined operator.
-
Claudio Trento
- Richard Jones
- Jean-Baptiste Rouquier
[
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: | -- (:) |
| From: | Jean-Baptiste Rouquier <jrouquiethearchivesshouldaddafewantispamtricks@e...> |
| Subject: | Re: [Caml-list] Associativity precedence for the user-defined operator. |
Claudio Trento wrote:
>Hi,
>
>I've defined a set of new operetors, for instance:
>
>let ( /+/ ) = add_num (where add_num is a function that added two sometype
> elements.)
>
>but I don't know if I can set associativity precedence for this operator,
>writing: el1 ( /+/ ) el2 ( /+/ ) el3 without parenthesis, what happens?
>
The manual says that here you have left associativity. See
http://caml.inria.fr/ocaml/htmlman/manual015.html.
# let ( /+/ ) a b =
Printf.printf "a=%i, b=%i\n%!" a b;
a + b;;
val ( /+/ ) : int -> int -> int = <fun>
# let _ = 1 /+/ 2 /+/ 39;;
a=1, b=2
a=3, b=39
- : int = 42
Cheers,
Jean-Baptiste.
-------------------
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