caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@gmail.com>
To: Anil Madhavapeddy <anil@recoil.org>
Cc: Jeremy Yallop <yallop@gmail.com>, caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Strange camlp4 issue
Date: Tue, 2 Oct 2012 09:21:47 +0200	[thread overview]
Message-ID: <CAOOOohRQVq=havHBb-7cKWjEzJwOK-bL9F_K6VRh+33KO+-sqQ@mail.gmail.com> (raw)
In-Reply-To: <5149DC70-C455-4BA1-AE3F-8A8CC5B6111C@recoil.org>

[-- Attachment #1: Type: text/plain, Size: 3203 bytes --]

Dear Jeremy and Anil,

the problem is exactly the one you describe. My syntax extension largely
reuses the one in js_of_ocaml; at some place there was this twisted
construct in pa_js.ml:

let obj = <:expr< ($e$ : Js.t (< .. > as $obj_type$)) >> in

When adapting this code I carelessly simplified it in something like

<:expr< fun () -> let _ : $obj_type$ Rbase.compound = $lid:x$#compound in
...
>>

and indeed camlp4 permutes [$obj_type$] and [Rbase.compound] in the
generated code. At this point, the raison d'être of the afore mentionned
construct is clear: if I use it too, the generated code (with camlp4o) is
correct. It now looks like:

<:expr< fun () -> let (_ : Rbase.compound (< .. > as $obj_type$)) =
$lid:x$#compound in
...
>>

The fun part (which makes sense, of course) is that even if written in the
wrong order in the quotation, camlp4o sets it right in the generated code.

Thank you both for your very effective help!

Cheers,
  Philippe.

2012/10/2 Anil Madhavapeddy <anil@recoil.org>

> Another reason it might be going wrong is that your quotations are
> generating invalid ASTs. This can happen when using the original syntax
> quotations (which are more ambiguous than the revised syntax).
>
> To get around this sort of problem, I tend to use the 'camlp4orf' variant,
> which uses the original syntax as the host language, and revised syntax for
> quotations.  This will mean that you need to learn the revised syntax for
> the sole goal of writing quotations, but it is actually quite pleasant to
> use (and certainly more fun than staring at dumps of raw AST fragments).
>
> -anil
>
> On 1 Oct 2012, at 15:39, Jeremy Yallop <yallop@gmail.com> wrote:
>
> > Dear Philippe,
> >
> > On 1 October 2012 17:21, Philippe Veber <philippe.veber@gmail.com>
> wrote:
> >>                    let _ = (a7818b19c#compound : Rbase.compound
> 'abdf89974)
> >
> > This appears to be the line where things are going wrong.
> > Rbase.compound 'abdf89974 is not a valid type in original (i.e.
> > standard) OCaml syntax, but is valid in the revised syntax.  It may be
> > that you're using the wrong camlp4 executable somewhere along the
> > line: for example, using quotations for revised syntax in your
> > extension, but building the extension using an original-syntax based
> > executable such as camlp4o.  There's a handy guide to the various
> > camlp4 executables on the wiki:
> >
> >
> http://brion.inria.fr/gallium/index.php/Using_Camlp4#Camlp4_executables_functionalities
> >
> > You're seeing different error-reporting behaviour depending on whether
> > you redirect the file because camlp4 checks whether it's printing to a
> > terminal when deciding whether to print textual or binary output by
> > default:
> >
> >
> http://caml.inria.fr/svn/ocaml/trunk/camlp4/Camlp4Printers/Camlp4AutoPrinter.ml
> >
> > Hope that helps a bit,
> >
> > Jeremy.
> >
> > --
> > Caml-list mailing list.  Subscription management and archives:
> > https://sympa.inria.fr/sympa/arc/caml-list
> > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> > Bug reports: http://caml.inria.fr/bin/caml-bugs
> >
>
>

[-- Attachment #2: Type: text/html, Size: 4764 bytes --]

      reply	other threads:[~2012-10-02  7:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-01 16:21 Philippe Veber
2012-10-01 22:39 ` Jeremy Yallop
2012-10-01 22:45   ` Anil Madhavapeddy
2012-10-02  7:21     ` Philippe Veber [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='CAOOOohRQVq=havHBb-7cKWjEzJwOK-bL9F_K6VRh+33KO+-sqQ@mail.gmail.com' \
    --to=philippe.veber@gmail.com \
    --cc=anil@recoil.org \
    --cc=caml-list@inria.fr \
    --cc=yallop@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).