Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
camlp4 3.10 and ints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-13 (12:32)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] camlp4 3.10 and ints
On 6/13/07, Richard Jones <> wrote:
> I'm getting some odd errors with camlp4 (3.10) and integers.

Thanks to Jeremy Yallop for responding to this. I then just add a few bits...

> Firstly, INT returns a string, rather than an int, and similarly
> $int:...$ expects a string instead of an int.  I can live with this,
> but it seems a bit strange, and unless I'm mistaken is different from
> what camlp4 <= 3.09 did.

Not it's not different and the reason is simple. Camlp4 wants to keep
the representation of your integer and turning it to int will
normalize it ("42", "4_2", "0000042", "0b0101010"...).

With 3.10 you also have active antiquotations $`int:...$ $`int32:...$ for that.

Conversely on the parser side you can also get integers instead of
string by using real patterns in your production rule.

[[ s = INT -> (* s is a string *) ... ]];

[[ `INT(i, s) -> (* i is an integer and s its representation *) ... ]];

Nicolas Pouillard