caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk), caml-list@inria.fr
Subject: Re: [Caml-list] dynamically loading C functions
Date: Tue, 06 Mar 2001 10:02:20 -0800	[thread overview]
Message-ID: <4.3.2.7.2.20010306094319.00e2b8e0@shell16.ba.best.com> (raw)
In-Reply-To: <slrn9aa56n.sji.qrczak@qrnik.zagroda>


>Do you indeed support returning functions from C? OK, so you need to
>distinguish more than the OCaml type tells. For example by having two
>functions of type 'a t -> 'b t -> ('a -> 'b) t: one to use between
>arguments and another for the final result.

Right, I thought of that, and I also thought of having a special token in the "type stream" that indicates a return value.  Neither of these are quite as natural as I'd like, though.  I think having a @@-> that you use between args and return isn't terrible, but it's just even more syntax to make this harder to use and more error prone.  :)  The get_function could raise an exception if every function in the specification didn't have a return type specifed, though.

I've got it wired up to use the Bigarray ('a,'b) kind stuff now, so the caml function and the c function type signatures parallel each other as ('aa,'ab) t -> ('ba,'bb) t -> ('aa -> 'ba,'ab -> 'bb) t (and I can reuse the Bigarray type hierarchy, although I don't know how to get access to the internal definitions of the Bigarray abstract types which I need to actually return the information, I think...or maybe not, so I may need to copy them, which sucks...sometimes having "#include<>" is useful  ;).

As for whether I need to support returning functions, all of this is relative.  I would really like to just solve the entire problem at once, if possible.  I'd like to make this work for generic dynalinking, but the very case I was going to use first (wglGetProcAddress) does actually return a function pointer.  :)

Chris


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-03-06 18:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-05 20:28 Chris Hecker
2001-03-05 21:24 ` Marcin 'Qrczak' Kowalczyk
2001-03-06  0:10   ` Chris Hecker
2001-03-06  0:55     ` Chris Hecker
2001-03-06 16:48       ` Marcin 'Qrczak' Kowalczyk
2001-03-06 18:02         ` Chris Hecker [this message]
2001-03-08  8:22           ` Fabrice Le Fessant
2001-03-08  9:34             ` Chris Hecker
2001-03-09 10:54               ` Fabrice Le Fessant

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=4.3.2.7.2.20010306094319.00e2b8e0@shell16.ba.best.com \
    --to=checker@d6.com \
    --cc=caml-list@inria.fr \
    --cc=qrczak@knm.org.pl \
    /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;
as well as URLs for NNTP newsgroup(s).