Version française
Home     About     Download     Resources     Contact us    
Browse thread
Give back a Pair from C to OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Give back a Pair from C to OCaml?
Zitat von Till Varoquaux <till.varoquaux@gmail.com>:

> from the manual:
>
> >>Tuples are represented by pointers to blocks, with tag 0.
>
> You have to create a block with two fields and put each integer in
> one
> of these fields (ocaml integers  that is). I can't tell you exactly
> from the top of my head but I do rememenber it isn't really hard.
[...]

I only have seen so much different docs about that topic.
For example OCaml-book from OReilly writes other things then
I found at other places.

But it doesn't matter what the OCaml-book says, only the reference
manual does count. But the reference manual is not an introductional
text, and so I may have to reread it to understand it.

For example I can use "CAMLprim value <functionname> (.....){...}"
or I can throw out "CAMLprim" (which is, what I found in the
OReilly-book).

Also "value x" or "int x" are working as C-parameters
of a function. But an OCaml-int is not the same like a
C-int, so I would expect gcc throw out at least a warning.
I have added "-Wall", but no warning there.

Possibly that's because what is mentioned in "18.2",
that int's are "value".
But there is no distinction between the OCaml-ints and the
machine's C-ints in that text. Is "an unboxed integer" meant
to be a machine's native int, 32 Bits or 64 Bits, depending on the
machine?. Can it be given as parameter and return value as it is?
At least the missing compiler-warnings seem to say me that.


Possibly I should read the reference manual in more detail
but possibly someone sees, what I have overseen...?!


Ciao,
   Oliver