ocaml-ppx / ppx_tools

Tools for authors of ppx rewriters
MIT License
134 stars 39 forks source link

Antiquotations for strings, ints, etc. #52

Closed smolkaj closed 8 years ago

smolkaj commented 8 years ago

It would be useful to have antiquotations [%int ...], [%string ...] and so on instead of just [%e ...]. This would simplify

let s' = Ast_convenience.str s in [%expr Foo [%e s']]

to just

[%expr Foo [%string s]]
alainfrisch commented 8 years ago

Assuming Ast_convenience is opened (likely if you use it), you can already write:

   [%expr Foo [%e str s]]

which is even shorter and does not require extra magic.

smolkaj commented 8 years ago

Ah, fantastic! I didn't understand the semantics of [%e ...] correctly.