Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] int32/int64 literals in next release?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Shawn Wagner <shawnw@s...>
Subject: Re: [Caml-list] int32/int64 literals in next release?
On Thu, Nov 14, 2002 at 10:49:43AM +0200, Yurii A. Rashkovskii wrote:
> Hi Shawn!
> 
> On Wed, 13 Nov 2002, Shawn Wagner wrote:
> > Problems I know about already:
> 
> [...]
> 
> > Help with any of the above is appreciated.
> 
> May be something like this will be easier?
> 
> 
> open Pcaml;;
> 
> let create_int loc v = <:expr< (int_of_string $str:v$) >>;;
> let create_int32 loc v = <:expr< (Int32.of_string $str:v$) >>;;
> let create_int64 loc v = <:expr< (Int64.of_string $str:v$) >>;;
> let create_nativeint loc v = <:expr< (Nativeint.of_string $str:v$) >>;;
> 
> EXTEND
> 
>  expr:
>   [[
>      i = INT; "l" -> create_int32 loc i
>    | i = INT; "L" -> create_int64 loc i
>    | i = INT; "n" -> create_nativeint loc i   
>    | i = INT -> create_int loc i
>   ]];
> 
> END
> ;
> 

I'd rather not have to go to the trouble of running every .ml file through
camlp4 for something that the language should be able to handle by default
without resorting to special tricks. Using camlp4 also kind of defeats the
idea of not having to use a conversion function everywhere you'd want to use
a literal large int value, doesn't it? 

Anyways, I /think/ I can get camlp4 at least compiled, if I can figure out
where the constraints in an <:expr< > pattern are checked, and then how to
add more. Trying to make it recognize $int32:_$ and the like.

-- 
Shawn Wagner
shawnw@speakeasy.org
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners