From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 53B45BC57 for ; Fri, 9 Jul 2010 12:29:03 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuwBAMuWNkzRVda0mGdsb2JhbACgNwgVAQEBAQEICQwHESKvA4VgiQEBAQMFhSIEiEmHNg X-IronPort-AV: E=Sophos;i="4.53,563,1272837600"; d="scan'208";a="63011018" Received: from mail-iw0-f180.google.com ([209.85.214.180]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Jul 2010 12:29:02 +0200 Received: by iwn8 with SMTP id 8so2608862iwn.39 for ; Fri, 09 Jul 2010 03:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=c8JDNzbgvQyffZwQHpfov0u4xY2qSLY9VCJQUoJwaUw=; b=NyIuEpwlejWDWQzOffP2kf80dumjcEqvS5/5aWBlb8/2zzFVo/3p2F9Zml+qW4xAub yfBZbB8zF2GkH5z1REoJs8JskiSsM5KgEKscATT1aIM+apBtq3MudRTyhKEViWIfCe90 X/wgsgctHxEaVLbwnpbuCNZU4AODPfFrcjczk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=NFcTQPUNAaUOd6Mek2QVPsc82xhZYxzb54pO6aum4TMnJ3EVf7G2RXFSiDXRbslIuW 5zkOMUpjZ4kUKx6WR6aqCqsWc5NE8KaCFGLSbu/wF4NyDXvtqqmckZJtkusX9zAoCeMk 798IOHiISIdxePdccwrABAVA8ksmrV4YQlBLk= MIME-Version: 1.0 Received: by 10.231.146.136 with SMTP id h8mr9475066ibv.0.1278671341941; Fri, 09 Jul 2010 03:29:01 -0700 (PDT) Sender: gaspard.buma@gmail.com Received: by 10.231.20.73 with HTTP; Fri, 9 Jul 2010 03:29:01 -0700 (PDT) In-Reply-To: References: Date: Fri, 9 Jul 2010 12:29:01 +0200 X-Google-Sender-Auth: kG-x3Qrm7l4FflcuXJoHmjam_DM Message-ID: Subject: Re: [Caml-list] ocaml for embedding From: Gaspard Bucher To: David MENTRE Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 pointer:01 runtime:01 globals:01 foo:01 foo:01 ocaml:01 compiler:01 callable:01 compiler:01 byte:01 wrote:01 caml-list:01 caml:02 caml:02 Hi David ! Thanks for the pointer. From my understanding of the use of caml_startup (or caml_main), this means that the caml runtime is global. In Rubyk, each "object" (processing unit) is separated from all other objects (no globals) so that we can properly encapsulate operations without side effects and provide fine grained locking (concurrency is important). Is there a way to avoid: 1. global locking (or locking only during script recompilation) 2. script level encapsulation Point (2) would mean that if object "a" contains the script: let foo a, b =3D ... do something and object "b" contains: let foo x, y =3D ... do something else The recompilation of script "b" does not change the definition of function "foo". One possible solution would be to force the creation of singleton classes for each script named after the script name (unique): let script_a =3D object method foo a, b =3D ... end;; let script_b =3D method foo x, y =3D ... do something else (does not hide script_a::foo) end;; This would solve the encapsulation problem, but what about concurrent calls to ocaml from C ? Is this possible ? Gaspard On Fri, Jul 9, 2010 at 9:06 AM, David MENTRE wro= te: > > Hello, > > 2010/7/8 Gaspard Bucher : > > 1. Is it possible to embed an ocaml compiler ? (something that eats > > std::string and produces a callable thing) > > No, not the compiler. It is however possible to embed an interpreter > and to load byte code (and native code?) on demand: > =A0http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc134 > > > 2. How would an interface between C++ and a compiled script work ? (pas= sing > > values, getting return values) > > Through a C interface. See above link. > > Sincerely yours, > david