From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q43F2dHu032500 for ; Thu, 3 May 2012 17:02:41 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhwBAOacok/RVdIpkGdsb2JhbABEsm4IIgEBAQEJCQ0HFAQjggkBAQEDARICLAEbHQEDAQsGBQs7IQEBEQEFARwGEwgah1wBAwYFC5tcCQOMJIJzhR8KGScNV4h2AQULiXuHAgSVfoERii6DIz2EDA X-IronPort-AV: E=Sophos;i="4.75,523,1330902000"; d="scan'208";a="142462653" Received: from mail-pz0-f41.google.com ([209.85.210.41]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 03 May 2012 17:02:40 +0200 Received: by dakp5 with SMTP id p5so1582285dak.0 for ; Thu, 03 May 2012 08:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=o/VR50iy2FjQJiLTzYMlp3KhMdWRnyJzbUHVFkWAryo=; b=xD0MI8VDWqagCU/Jm4+UpQenWWIAokJBKICsYsArXoB5C0KPdDibKH/u9Fd2dmvYV7 0aeDau4ICv5wKHsJ1PGJeLIkbeBkFdTuA8VM5yzfCwiHe0+vDXftieZI0R3F38MlTqZL AjwkTwqymqDaAZzVBxMbhQ7EYQTqBem6ShJebfbR5YOulLSKhxQBXID6PGcnlRbcTmYV 5YUZ3dTqKmhNeu0Mpo6EKeeEKmjHNair+H1ATTUc3vmrM78CWdsWQrmcJYp63GVMZamG jfYZwQPjkgoz6Esvl08tqE6PIAQOgjcfFoywGQKdTjdGaTl9WEWlrL/xBZd2up/IEe4O bg+g== MIME-Version: 1.0 Received: by 10.68.136.69 with SMTP id py5mr8436913pbb.115.1336057358312; Thu, 03 May 2012 08:02:38 -0700 (PDT) Received: by 10.68.228.194 with HTTP; Thu, 3 May 2012 08:02:38 -0700 (PDT) In-Reply-To: References: <871un1z8sq.fsf@frosties.localnet> Date: Thu, 3 May 2012 16:02:38 +0100 Message-ID: From: Joel Reymont To: Gabriel Scherer Cc: Goswin von Brederlow , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] using modules to wrap c++ classes Gabriel, On Thu, May 3, 2012 at 3:27 PM, Gabriel Scherer wrote: > (1) You could define, on the C++ side, a generic GenericAdmCallbacks > class whose constructor would take as parameter a function pointer > implementing Alert (so the function itself only does the plumbing). There's another class RCallbacks with scores of Alert-like methods, though. I didn't count all the methods but I'd say about 50. Then there's another callback class... > Then you can expose this class as an OCaml abstract type, and wrap its > constructor to expose it to OCaml, so that it takes ocaml-land > callbacks and return the abstract type. I suppose I can have a static table on the C++ side with pointers to implemented methods. > You can then expose to OCaml > your function manipulating AdmCallbacks (let's call it > "call_me_later"). I guess I can represent the various callbacks for each class as a variant on the OCaml side that takes a closure per callback. I think I prefer your approach to my OOP one. Thanks Gabriel and thank you Goswin! -------------------------------------------------------------------------- Working on AlgoKit, a new algorithmic trading platform using Rithmic R|API ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+---------------------------------------