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 CB47FBC57 for ; Wed, 7 Jul 2010 22:37:01 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkkCAMOCNEzRVdQ0kGdsb2JhbACDHZxzCBUBAQEBCQkMBxEDH656O4IMhWcuiFMBAQMFgSSDCXIEiD0 X-IronPort-AV: E=Sophos;i="4.53,554,1272837600"; d="scan'208";a="62903914" Received: from mail-vw0-f52.google.com ([209.85.212.52]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Jul 2010 22:36:49 +0200 Received: by vws11 with SMTP id 11so125516vws.39 for ; Wed, 07 Jul 2010 13:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=dfBvL2pW/F1IZUpbxWav/+ix+CU42puo0W+6AiSD0LE=; b=PuWrp/Ffm1iZzu5zoHI6p/D3EpjQPHJDdkWG7SZ4XcHv9NUc7rSlopkN2EeZOnqn89 LvrQefH4AY2h8uNuKVLZAUoQ0yR9kpZzhTw7UFtgt4Vl0xbFO9Sjwx6j7buW42k/0JgT unsB9XAHMWV6nXl3ksiPtnPP/9Vbkk+bQzSkU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=ByNZWQdoUYbjDH8G3Nc2vqKFNW/N4/R3dHYMlnB/7CDI4eQ6OUY5FrF7l6yg1J/xAB KJ4nMw4ETc/bqSW2i6ojKehAfUWkmfBO61S8snn6gPTCl4QgXpg79GmPD3eKm+5yyX3k 6APXABb+qzq8opYPEh7+AW+aijF3F28wHNkZY= Received: by 10.220.125.16 with SMTP id w16mr3660469vcr.224.1278535008189; Wed, 07 Jul 2010 13:36:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.170.210 with HTTP; Wed, 7 Jul 2010 13:36:28 -0700 (PDT) In-Reply-To: <4C339FE3.6000402@citycable.ch> References: <4C339FE3.6000402@citycable.ch> From: Paolo Donadeo Date: Wed, 7 Jul 2010 22:36:28 +0200 Message-ID: Subject: Re: [Caml-list] Binding the Lua library [was: adding a scripting language to an ocaml program] To: OCaml List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 guillaume:01 guillaume:01 doable:01 ocaml:01 28,:98 userdata:98 userdata:98 5.1:98 W6:98 garbage:01 closures:01 incremental:01 wrote:01 stack:01 On Tue, Jul 6, 2010 at 23:28, Guillaume Yziquel wrote: >> And, of course, any ideas or help on the garbage collector(s) issue are >> welcome. > I do not know much about Lua's GC. My experience (for R, Python and Java)= is > that it's doable. The GC implemented in Lua [1] is an incremental mark-and-sweep collector. Since Lua type system is simple (nil, boolean, number, string, function, userdata, thread, for coroutines, and tables) it automatically collects everything without problems. The strategy for basic types is to copy values from the C (or OCaml) side to the Lua stack: this copy decouples the two GC and sets them free to deallocate values. Problems arise when one tries to share userdata or closures between OCaml and Lua. In this case it's not clear (at least to me) how to approch the problem. [1] http://www.lua.org/manual/5.1/manual.html#2.10 --=20 Paolo =E2=A0=A0=E2=A0=B5