* Ocaml <-> C
@ 2005-04-18 11:14 Paul Argentoff
2005-04-18 11:49 ` [Caml-list] " Jean-Christophe Filliatre
0 siblings, 1 reply; 3+ messages in thread
From: Paul Argentoff @ 2005-04-18 11:14 UTC (permalink / raw)
To: caml-list
Hello world!
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?
--
Yours truly, WBR, Paul Argentoff.
Jabber: paul@jabber.rtelekom.ru
RIPE: PA1291-RIPE
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Ocaml <-> C
2005-04-18 11:14 Ocaml <-> C Paul Argentoff
@ 2005-04-18 11:49 ` Jean-Christophe Filliatre
2005-04-18 12:27 ` Paul Argentoff
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe Filliatre @ 2005-04-18 11:49 UTC (permalink / raw)
To: Paul Argentoff; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Ocaml <-> C
2005-04-18 11:49 ` [Caml-list] " Jean-Christophe Filliatre
@ 2005-04-18 12:27 ` Paul Argentoff
0 siblings, 0 replies; 3+ messages in thread
From: Paul Argentoff @ 2005-04-18 12:27 UTC (permalink / raw)
To: Jean-Christophe Filliatre; +Cc: caml-list
Dear Jean-Christophe Filliatre,
Let JF = "Jean-Christophe Filliatre" in
written_by JF =>
JF> if (Is_long(v)) {
JF> ... None case ...
JF> } else {
JF> ... Some case ... ... you access to x here with Field(v, 0) ...
JF> }
Thanks.
--
Yours truly, WBR, Paul Argentoff.
Jabber: paul@jabber.rtelekom.ru
RIPE: PA1291-RIPE
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-18 12:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-18 11:14 Ocaml <-> C Paul Argentoff
2005-04-18 11:49 ` [Caml-list] " Jean-Christophe Filliatre
2005-04-18 12:27 ` Paul Argentoff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox