Jérémie Dimino <jere...@dimino.org> writes:

> Le samedi 10 décembre 2011 à 19:10 +0000, Wojciech Meyer a écrit :
>> I'm aware that these are huge changes to Camlp4, but it would make
>> meta programming more powerful and push Camlp4 to the next level.
>
> Sure. But it seems that the next version of OCaml will have runtime
> types, see http://www.lexifi.com/blog/runtime-types , so maybe it is not
> needed to add this to camlp4.

It's interesting and I didn't know about it. However, the problem is
slightly different, I would like to know the typing of a freshly
generated piece of code by Camlp4 in the previous phase. Then, have
pattern matching against these meta types in annotated AST and produce
another AST, which in turn have most likely another typing and pass to
the next phase etc. I would say that Camlp4 is fine for the simpler
syntax extensions and majority of small DSLs but when you start composing
syntax extensions and macros it quickly becomes a problem.

>
> Also they are problems that i don't know how to solve with the camlp4
> approach. For example consider:
>
>   let x = 1
>   type int = A
>   let y = A
>
> The typer knows that x has the type (int, 1) and y has the type (int,
> 42). But what you send to ocaml is a parse tree, and you cannot make
> this difference in the parse tree.

Yes, you would need a type information in the parse tree as mentioned
before, so you want to feed up the compiler with AST start unrolling
macros top-down and then follow up with the inferred types bottom-up.

Cheers;
Wojciech


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to