* question about caml_get_public_method
@ 2006-08-21 7:15 Michael Wohlwend
2006-08-21 9:14 ` [Caml-list] " Jacques Garrigue
0 siblings, 1 reply; 2+ messages in thread
From: Michael Wohlwend @ 2006-08-21 7:15 UTC (permalink / raw)
To: caml-list
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?
cheers
Michael
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] question about caml_get_public_method
2006-08-21 7:15 question about caml_get_public_method Michael Wohlwend
@ 2006-08-21 9:14 ` Jacques Garrigue
0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2006-08-21 9:14 UTC (permalink / raw)
To: micha-1; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-08-21 9:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-21 7:15 question about caml_get_public_method Michael Wohlwend
2006-08-21 9:14 ` [Caml-list] " Jacques Garrigue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox