From: Michel Mauny <Michel.Mauny@inria.fr>
To: Arturo Borquez <artboreb@netscape.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] infix operator for the revised syntax
Date: Wed, 1 Dec 2004 12:43:39 +0100 [thread overview]
Message-ID: <20041201114339.GG4582@quincy.inria.fr> (raw)
In-Reply-To: <29C8881F.307FAC54.00958B05@netscape.net>
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
prev parent reply other threads:[~2004-12-01 11:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-30 18:50 Arturo Borquez
2004-12-01 11:43 ` Michel Mauny [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041201114339.GG4582@quincy.inria.fr \
--to=michel.mauny@inria.fr \
--cc=artboreb@netscape.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox