* infix operator for the revised syntax
@ 2004-11-30 18:50 Arturo Borquez
2004-12-01 11:43 ` [Caml-list] " Michel Mauny
0 siblings, 1 reply; 2+ messages in thread
From: Arturo Borquez @ 2004-11-30 18:50 UTC (permalink / raw)
To: caml-list
Dear Camlers,
I've failed do do a syntax extention to the
revised syntax 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 ..
thanks in advance
--
Arturo Borquez
__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register
Netscape. Just the Net You Need.
New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] infix operator for the revised syntax
2004-11-30 18:50 infix operator for the revised syntax Arturo Borquez
@ 2004-12-01 11:43 ` Michel Mauny
0 siblings, 0 replies; 2+ messages in thread
From: Michel Mauny @ 2004-12-01 11:43 UTC (permalink / raw)
To: Arturo Borquez; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-01 11:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-30 18:50 infix operator for the revised syntax Arturo Borquez
2004-12-01 11:43 ` [Caml-list] " Michel Mauny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox