[
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: | Michel Mauny <Michel.Mauny@i...> |
| Subject: | Re: [Caml-list] infix operator for the revised syntax |
Hello,
Arturo Borquez wrote/écrivait (Tue, Nov 30, 2004 at 01:50:55PM -0500):
> Dear Camlers,
>
> I've failed do do a syntax extention to the
> revised syntax
> [...]
> let ( $ ) f g = g (f);; (* provided by normal syntax works fine *)
Please note that using `$' as an operator is explicitely discouraged
in the OCaml manual: http://caml.inria.fr/ocaml/htmlman/manual009.html
Furthermore, there is a bug in Camlp4 3.08.2 that prevents using `$'
as anything else than the antiquotation delimiter in the
Camlp4-preprocessed syntaxes. This is fixed in the CVS (see
http://caml.inria.fr/bin/caml-bugs/fixed?id=3310 foran explanation and
a patch).
> [...] in order to get a *real* infix operator for function
> concatenation in order to avoid excessive parenthesis.
> example with lists (silly)
>
> let ( $ ) f g = g (f);; (* provided by normal syntax works fine *)
> let r = List.map ... a_list $ List.sort ... $ List.fold_left ... in ..
> (* that's i whant to write with the revised syntax *)
>
> let r = List_fold_left ... ((List.sort ...) List.map ... a_list) in ..
As far as I understand, what you want is to extend the revised syntax
with a new construct/operator. The Camlp4 documentation is your friend
here (http://caml.inria.fr/camlp4/manual/manual006.html#toc16,
http://caml.inria.fr/camlp4/tutorial/tutorial007.html#toc49, etc.).
For instance (using the revised syntax), the following could help
you. (Change AFTER ":=" with the precedence level you want.)
open Pcaml;
(* Reversed application *)
value send_to x f = f x;
EXTEND
expr: AFTER ":="
[[ e1 = expr; "sentto"; e2 = expr -> <:expr< send_to $e1$ $e2$ >> ]];
END;
Hope this helps,
-- Michel Mauny