From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id A9D55BBAF for ; Wed, 25 Jun 2008 04:17:19 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvEBAD9HYUhC+VLqd2dsb2JhbACSL0MBDAUCBAkPBZoMhVo X-IronPort-AV: E=Sophos;i="4.27,700,1204498800"; d="scan'208";a="26680195" Received: from wx-out-0506.google.com ([66.249.82.234]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Jun 2008 04:17:18 +0200 Received: by wx-out-0506.google.com with SMTP id i30so1287231wxd.15 for ; Tue, 24 Jun 2008 19:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=0AHLtfpSYjxY/ItChSFp7UBD4hh+MP7IpPHwHaUNb6Y=; b=qO0agvp+C0CAxO6+G3Nd3CmkR4C7CA/cbITLEF9UCb3qmqeg9XsVN/zZ0lhlqDotpv BOpuOL4S7hvpIebOmH9kMND4S3llfBYB8cXkh8gDZ6/a6UqdRH0/ShBjgW+OA3qHoNxz Yv4JS784PKXO/LseYTPgErVZ0ieJ2x4QtZfYQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=H0ShVA4IrsuuMzbw0wCIZw/JvpyBYJNHHCyuGwZ3+MsoZsIqiDUjkT5UX96AE/1sWy BonG/ANOc0v5y7QzkGrywHGxk/ALsiwTi+dodjcqaoPRhgsfqyyTwSQcXILJNR8Ox0RF CehVKnNCcuBYJTssVO3wsRY4x05hSLr+BIqV4= Received: by 10.70.48.7 with SMTP id v7mr11170360wxv.61.1214360237547; Tue, 24 Jun 2008 19:17:17 -0700 (PDT) Received: by 10.70.9.11 with HTTP; Tue, 24 Jun 2008 19:17:17 -0700 (PDT) Message-ID: <6999988a0806241917p3d26a170s5ecfc8925e9d5e5d@mail.gmail.com> Date: Tue, 24 Jun 2008 22:17:17 -0400 From: "Peng Zhang" To: caml-list@yquem.inria.fr Subject: call ocaml from R MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Spam: no; 0.00; ocaml:01 ocaml:01 stub:01 mlvalues:01 alloc:01 val:01 peng:98 peng:98 closure:01 closure:01 callback:02 callback:02 caml:02 caml:02 defined:02 Hi folks, I need some help from you. What I want to do is that my main program is in R and I want to implement part of it with ocaml. The following is an example. /* mysin.R */ dyn.load("mysin.so") mysin <- function(x) .C("mysin", as.double(x), r = double(1))$r /* mycode.ml */ let sin_ml x = sin x let _ = Callback.register "sin_ml" sin_ml I want to use sin defined in mycode.ml in mysin.R Then I write the following stub code /* mysin.c */ #include #include #include #include #include void mysin(double * x, double * r){ value * closure_f; caml_startup(NULL); closure_f = caml_named_value("sin_ml"); *r = Double_val(caml_callback(*closure_f, caml_copy_double(*x))); } It isn't working right now. What I am not sure about is what to put in caml_startup. Can somebody help with me this? Thank you very much! Best, Peng