From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: micha-1@fantasymail.de
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] question about caml_get_public_method
Date: Mon, 21 Aug 2006 18:14:42 +0900 (JST) [thread overview]
Message-ID: <20060821.181442.124866554.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20060821071532.32660@gmx.net>
From: "Michael Wohlwend" <micha-1@fantasymail.de>
> if I want to connect a c++ method to a method of an ocaml class, I can choose between:
> a) in the initializer of the ocaml class use register_value to register a method (like self#some_method) and then calling an external function which caches the registered value and calls that method
>
> or
>
> b) calling an external function with the ocaml object as argument and then use caml_get_public_method, cache the method-id of the callback methods and use those to make the callback.
>
> Is this just a matter of taste which one to use?
The second approach is going to be slightly simpler (no need to split
registration code between ocaml and C++, and the method ids do not
depend on the object/class.) Note that you don't really need to cache
the method itself, as caml_get_public_method is really fast.
You can also generate the method ids beforehand, avoiding need for any
cacheing. Here is a tool to do that.
http://camlcvs.inria.fr/cgi-bin/cvsweb/bazar-ocaml/lablGL/src/var2def.ml?rev=1.9
The 1st approach should work too.
Jacques Garrigue
prev parent reply other threads:[~2006-08-21 9:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-21 7:15 Michael Wohlwend
2006-08-21 9:14 ` Jacques Garrigue [this message]
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=20060821.181442.124866554.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=micha-1@fantasymail.de \
/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