Version française
Home     About     Download     Resources     Contact us    
Browse thread
Camlp4 3.10.0+beta: lists without $list:...$
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Camlp4 3.10.0+beta: lists without $list:...$
On 3/23/07, Martin Jambon <martin.jambon@ens-lyon.org> wrote:
> On Fri, 23 Mar 2007, Nicolas Pouillard wrote:
>
> > On 3/23/07, Martin Jambon <martin.jambon@ens-lyon.org> wrote:

[...]

> >
> > BTW, have you read these slides
> > http://gallium.inria.fr/~pouillar/pub/camlp4/renovation-camlp4-longue.pdf

Oops I don't remember that was in French (sorry for those that can't read it)

> OK, I am trying to convert my syntax extensions and everyday I hit a new
> problem, which by default I report as a bug because if it's not documented
> as an intentional incompatiblity, it must be a bug.

Yes I understand your point, but that's why I pointed out these slides
that talk about many of these features, even if it's from a
presentation point of view.

> I started with pa_json_static.ml
> (from http://martin.jambon.free.fr/json-static.html)
> because it's fairly complete and doesn't use any dirty trick.
> It manipulates all kinds of types, each of them as exprs, patts and ctyps.
> So I guess once this works, it would be a big progress toward upgrading
> all my stuff.
>
> I'll publish the commented diffs as soon as I get a version that works,
> but it would be much faster if you could do it for me. The thing is I
> don't really know how I can help.

If I start traducing all camlp4 extensions (or the first of everyone),
I'm not done!

<just kidding>
Perhaps there is a need for some consulting services on camlp4 :)
</just kidding>

> For now I am stuck with record type definitions:
> With quotations in the revised syntax (command camlp4orf), how to create a
> record field with an optional mutable flag?
>
>   <:ctyp< $name$ : $opt:is_mutable$ $t1$ >>

Generally all flags: private, mutable, virtual, rec, .., to/downto now
have their own antiquotation.

<:expr< let $rec:is_rec$ f f = f in f >>
<:class_str_item< value $mutable:is_mutable$ x = 42 >>
<:ctyp< < meth1 : int ; meth2 : float $..:raw_variable$ > >>
...

However there is some exceptions to that rule.

A private type is a type surrounded by a node "private".
That's now the same thing for mutable types.

You can define this function if you want:

let mkmutable is_mutable = if is_mutable then <:ctyp< mutable $t$ >> else t

Or rewrite a little the code to take a better profit of this change.

BTW: camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml contains many of
your answers.

Best regards,

-- 
Nicolas Pouillard