From: dmitry grebeniuk <gds-mlsts@moldavcable.com>
To: caml-list@inria.fr
Subject: creating a functional value from C
Date: Wed, 23 May 2007 14:20:05 +0300 [thread overview]
Message-ID: <151158176.20070523142005@moldavcable.com> (raw)
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
reply other threads:[~2007-05-23 11:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=151158176.20070523142005@moldavcable.com \
--to=gds-mlsts@moldavcable.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox