caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] c++ class to ocaml class or module?
@ 2010-12-28 23:15 Jacques Garrigue
  2010-12-28 23:26 ` Joel Reymont
  0 siblings, 1 reply; 4+ messages in thread
From: Jacques Garrigue @ 2010-12-28 23:15 UTC (permalink / raw)
  To: Joel Reymont, caml-list

From: Joel Reymont <joelr1@gmail.com>

>Would you suggest wrapping a C++ class in a class in OCaml?
>
>Should I pick another approach, e.g. using a module?

In C++ classes act both as object generators and modularity providers.
So you should first determine what is the role of the class you're wrapping.

Note also that since the FFI cannot directly create ocaml objects, you
will first need to wrap methods as external functions anyway.
I would only suggest making the extra effort of combining these
functions into classes if sutyping is actively used.

Jacques Garrigue

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] c++ class to ocaml class or module?
  2010-12-28 23:15 [Caml-list] c++ class to ocaml class or module? Jacques Garrigue
@ 2010-12-28 23:26 ` Joel Reymont
  2010-12-29  0:11   ` Jacques Garrigue
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Reymont @ 2010-12-28 23:26 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: caml-list


On Dec 28, 2010, at 11:15 PM, Jacques Garrigue wrote:
> I would only suggest making the extra effort of combining these
> functions into classes if sutyping is actively used.

This is a large surface C++ API where I need to subclass to provide callbacks.

For example, the initialization arguments to the "engine" class are grouped into a "parameters" class so I need to create the parameters object in C++ and then individually set the members. 

---
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] c++ class to ocaml class or module?
  2010-12-28 23:26 ` Joel Reymont
@ 2010-12-29  0:11   ` Jacques Garrigue
  0 siblings, 0 replies; 4+ messages in thread
From: Jacques Garrigue @ 2010-12-29  0:11 UTC (permalink / raw)
  To: Joel Reymont; +Cc: caml-list

On 2010/12/29, at 8:26, Joel Reymont wrote:
>> I would only suggest making the extra effort of combining these
>> functions into classes if sutyping is actively used.
> 
> This is a large surface C++ API where I need to subclass to provide callbacks.
> 
> For example, the initialization arguments to the "engine" class are grouped into a "parameters" class so I need to create the parameters object in C++ and then individually set the members. 

As this doesn't seem to involve subtyping, I would suggest just
putting your parameters into an ocaml record, and have a class on the
C++ side that accesses the fields of such a record.
Keep the FFI as simple as possible.
If you need more structure on the ocaml side, you can always add it later.

Jacques Garrigue

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Caml-list] c++ class to ocaml class or module?
@ 2010-12-28 21:34 Joel Reymont
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Reymont @ 2010-12-28 21:34 UTC (permalink / raw)
  To: caml-list

Would you suggest wrapping a C++ class in a class in OCaml?

Should I pick another approach, e.g. using a module?

	Thanks, Joel

---
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-29  0:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-28 23:15 [Caml-list] c++ class to ocaml class or module? Jacques Garrigue
2010-12-28 23:26 ` Joel Reymont
2010-12-29  0:11   ` Jacques Garrigue
  -- strict thread matches above, loose matches on Subject: below --
2010-12-28 21:34 Joel Reymont

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).