caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: "Jérémie Dimino" <jeremie@dimino.org>
Cc: Jacques Le Normand <rathereasy@gmail.com>,
	caml-list caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] camlp4 infix let
Date: Wed, 07 Apr 2010 13:24:11 -0700	[thread overview]
Message-ID: <4BBCE9EB.6020704@ens-lyon.org> (raw)
In-Reply-To: <1270669515.22777.4.camel@aurora>

Jérémie Dimino wrote:
> Hi,
> 
> Le mercredi 07 avril 2010 à 15:05 -0400, Jacques Le Normand a écrit :
>> Dear List,
>> I'm writing a camlp4 syntax extension and I'd like to write 
>>
>>     <:expr< let ( >>= ) = Bar.( >>= ) in 5 >>
>> but camlp4 complains:
>>
>>       While expanding quotation "expr" in a position of "expr":
>>         Parse error: ")" or [ipatt] expected after "(" (in [ipatt])
>>
>> yet it seems to be valid revised syntax. Does anyone have any ideas?

The revised syntax of the old camlp4 or camlp5 requires a backslash in front
of the operator instead of parentheses:

$ cat foo.ml
let \>>= = Bar.\>>= in 5 ;

$ camlp5r pr_o.cmo foo.ml
let _ = let (>>=) = Bar.(>>=) in 5


I don't know how to make it work with the new camlp4:

$ camlp4r -printer o foo.ml
File "foo.ml", line 1, characters 4-8:
Parse error: "module" or [opt_rec] expected after "let" (in [expr])


> It is because the ">>" of the ">>=" operator is detected as the end of
> the camlp4 quotation. You can try something like that:
> 
>    let operator = ">>=" in <:expr< let ($lid:operator$) = Bar.($lid:operator$) in 5 >>

I would add it is simpler to just avoid << and >> in any ocaml source code
unless camlp5/camlp4 is not involved.


Martin

-- 
http://mjambon.com/


      reply	other threads:[~2010-04-07 20:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 19:05 Jacques Le Normand
2010-04-07 19:45 ` [Caml-list] " Jérémie Dimino
2010-04-07 20:24   ` Martin Jambon [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=4BBCE9EB.6020704@ens-lyon.org \
    --to=martin.jambon@ens-lyon.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=jeremie@dimino.org \
    --cc=rathereasy@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).