"ocaml_beginners"::[] camlp4: boolean value in an expr

View: New views
2 Messages — Rating Filter:   Alert me  

"ocaml_beginners"::[] camlp4: boolean value in an expr

by Sashan Govender :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

How do I tell a bool to be an expr?

For example this

let pfx = false in
<:expr<foo $bool:pfx$>>

Will error when foo is a function that expects a bool. I see from
examples where camlp4 is used that there are places where something
like $int:var$ is used. Is there an equivalent for booleans?

Re: "ocaml_beginners"::[] camlp4: boolean value in an expr

by Jake Donham-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 17, 2009 at 10:18 PM, Sashan Govender <sashang@...> wrote:
> let pfx = false in
> <:expr<foo $bool:pfx$>>

Try `bool instead. This is a bit confusing because there are both int
and `int antiquotations; the int one takes a string and embeds it as
an int AST node (the AST node takes a string representation of the
int, I think in order to support antiquotations inside it), while the
`int one takes an int, converts it to a string, and embeds it as an
int AST node.

You can see some other antiquotations in
camlp4/Camlp4Parsers/Camlp4QuotationCommon.ml.

Jake