English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2007-03-23 (06:13)
From: Martin Jambon <martin.jambon@e...>
Subject: Camlp4 3.10.0+beta: lists without $list:...$
I managed to create an object type using camlp4orf:

let ctyp_object _loc ml =
   let fields =
       (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?

If not, I think there should really be one. By the way, there should also 
be some shortcut for building list patterns and expressions without 
List.fold_*. A library could do that.


PS: any progress on the manual? It's kind of hard to test new features 
when you don't know what they are.

Martin Jambon