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 > 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 wrote: > > > Dear Philippe, > > > > On 1 October 2012 17:21, Philippe Veber > 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 > > > >