* creating a functional value from C
@ 2007-05-23 11:20 dmitry grebeniuk
0 siblings, 0 replies; only message in thread
From: dmitry grebeniuk @ 2007-05-23 11:20 UTC (permalink / raw)
To: caml-list
Hello.
I want to create a functional value from C world,
which can be called from OCaml. Something to make
this code work:
external create_func_val : int -> (string -> string)
= "c_create_func_val";
value fv = create_func_val 123;
print_string (fv "abc");
print_string (fv "def");
Real situation is more complex -- functions
"c_create_func_val" and "fv" both has side effects,
so I can't just rewrite last lines as
"print_string (create_func_val 123 "abc");
print_string (create_func_val 123 "def");",
moreover, the real address that will be stored in
"fv"-closure becomes known only in function
"c_create_func_val", and it is the address of
C function that follow all gc-related conventions
(takes and returns "value"s, uses CAMLparam and so on).
As a simplification, "fv" should not hold any ML
values in its environment.
Is it possible? If yes, then how to do it?
Reading OCaml sources hadn't helped me.
--
WBR,
dmitry mailto:gds-mlsts@moldavcable.com
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-05-23 11:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-23 11:20 creating a functional value from C dmitry grebeniuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).