Browse thread
Camlp4 3.10.0+beta: lists without $list:...$
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-03-23 (19:02) |
From: | Martin Jambon <martin.jambon@e...> |
Subject: | Re: [Caml-list] Camlp4 3.10.0+beta: lists without $list:...$ |
On Fri, 23 Mar 2007, Nicolas Pouillard wrote: > On 3/23/07, Martin Jambon <martin.jambon@ens-lyon.org> wrote: > > I managed to create an object type using camlp4orf: > > > > let ctyp_object _loc ml = > > let fields = > > List.fold_left > > (fun o (name, typ) -> > > let m = <:ctyp< $lid:name$ : $typ$ >> in > > <:ctyp< $o$; $m$ >>) > > <:ctyp< >> ml in > > <:ctyp< < $fields$ > >> > > > > where ml is a list of method declarations of type (string * ctyp) list. > > Before we just had to do this: > > > > <:ctyp< < $list:ml$ > >> > > > > Is there anything simpler than my solution? Is a shortcut available? > > In fact there is some shortcuts but it was not for all constructions > (fixed now in CVS). ... > You can note that in `` [ $list:cases$ '' I used the $list:...$ > antiquotation that was used to inject some list in a tree. In 3.10 you > can still do that, but that's a sugar for a function call that will > join all your trees by the proper separator (bar here). > > FYI, I've just added all the missing $list:$ sugars to the CVS version > (will be public soon). Thanks. > > PS: any progress on the manual? It's kind of hard to test new features > > when you don't know what they are. > > I agree, but there is still no progress on the documentation :( > > BTW, have you read these slides > http://gallium.inria.fr/~pouillar/pub/camlp4/renovation-camlp4-longue.pdf 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. 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. 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$ >> gives a syntax error (well, that was yesterday night and it was late and I don't have the details here, but you can check). It's only needed because the $list:...$ is not supported for building my whole record declaration, in version 3.10.0+beta that is. Thanks Martin -- Martin Jambon http://martin.jambon.free.fr