Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Primitive sizes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] Primitive sizes
On Thu, 30 Sep 2004, Jonathan Bryant wrote:

> Ok.  Maybe I need to make clear what I'm doing.  I'm trying to write
> native Java methods and have them call an OCaml library.  The problem is
> that I need Java compatible primitives to pass back from the methods. 
> In Java (ON ALL PLATFORMS), the primitives fall this way (in case you
> don't know them off the top of your head):

I don't know what Java's calling convention is.  My advice:

>  Type     Bits
>  -----    ----
> byte    - 8
> short   - 16
> char    - 16
> boolean - 8

The above I'd just promote to ints for Ocaml, and truncate as necessary.

> int     - 32

I'd use Int32's.

> long    - 64

I'd use Int64's.

> float   - 32
> double  - 64

I'd be inclined to promote both of these to Ocaml floats, which are 64-bit 
IEEE 754 floats (the same as Java's).  The extra precision won't hurt 
anything except stupidly strict binary compatability.

I assume you're using one of the Ocaml->JVM compilers kicking around.  
Tying Ocaml native mode (or VM) code to Java would be way too much work.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
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