Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocaml <-> C
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] Ocaml <-> C

Hello,

Paul Argentoff writes:
 > 
 > Let's say we have a function:
 > 
 > external f : t option -> unit = "c_f"
 > 
 > How can I make analysis depending on the parameter, which in Ocaml is:
 > 
 > match a with
 >   | None -> chunk1
 >   | Some x -> chunk2 x
 > 
 > What functions/macros from a standard ocaml includes set can I use?

None  is represented  by an  integer  (0) and  Some is  pointing to  a
block. You can test for the former case with the macro Is_long:

	if (Is_long(v)) {
	   ... None case ...
	} else {
	   ... Some case ...
	   ... you access to x here with Field(v, 0) ...
	}

-- 
Jean-Christophe