From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 2BB087ED88 for ; Tue, 4 Sep 2012 02:10:41 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of monnier.florent@gmail.com) identity=pra; client-ip=74.125.82.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of monnier.florent@gmail.com designates 74.125.82.182 as permitted sender) identity=mailfrom; client-ip=74.125.82.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f182.google.com) identity=helo; client-ip=74.125.82.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="postmaster@mail-we0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao0BABlGRVBKfVK2kGdsb2JhbAArGhaFb7UZCCIBAQEBCQkNBxQEI4IhAQEEEgIPBBkBGx0BAwwGBQsPAiYCAiMRAQUBHDuHWwEDDAQHKps8CQOLVE+Cc4R5ChknDVmIcwEFDIEViWyEFoIKgRIDlVmBFI0oPoQF X-IronPort-AV: E=Sophos;i="4.80,363,1344204000"; d="scan'208";a="171738583" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 Sep 2012 02:10:40 +0200 Received: by weyx56 with SMTP id x56so5000016wey.27 for ; Mon, 03 Sep 2012 17:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:user-agent:references:in-reply-to:cc :mime-version:message-id:x-face:content-type :content-transfer-encoding; bh=JYc8ilcVhbupnAlI4qKNhl8OtJykRNMiFX0g+ceBkVw=; b=OGckzngrOwMmT/wxq0mxnJeUKvMdp4UaVfzAdwTbwMAiMdYAY//0I8M1M/dVMKMzv1 GvQsz5hyOKLtf7o/Agq73Z03Pt1m58TiwoDvpZxIBNW4O1j1JKU5bvn9Js0KhkyaWIK8 3EwKbqxH3Yy1EwwaZ5859S5uI42MLmeEdCseBXVKxRA6qy+D34nkZRWGlG5wo5IpzuA8 F6/N+qtMRKzlSHTg9mkKCSSvqwnDUVuY/FbMkzIZWn/mX/HWaicO/tbUdtHcAskPw1TO fR/HMWevMo0XYhXNWZ8ORKJRId1lnZC03kzOpP8LIe98AGlORKobroWkuGOvYAppxI1w 9wUA== Received: by 10.180.94.38 with SMTP id cz6mr26595793wib.10.1346717439987; Mon, 03 Sep 2012 17:10:39 -0700 (PDT) Received: from localhost.localnet (pat35-5-78-226-58-147.fbx.proxad.net. [78.226.58.147]) by mx.google.com with ESMTPS id k20sm21592807wiv.11.2012.09.03.17.10.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Sep 2012 17:10:38 -0700 (PDT) From: Florent Monnier To: caml-list@inria.fr Date: Tue, 4 Sep 2012 01:57:25 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.33.7-desktop586-2mnb; KDE/4.4.5; i686; ; ) References: In-Reply-To: Cc: Paolo Donadeo MIME-Version: 1.0 Message-Id: <201209040157.25686.monnier.florent@gmail.com> X-Face: -0"dKXwF0PiXr]fa$^)NJY7$;waqUckGcM7&q,VU?Xv\[=CiVM]g]pDs^xmfU9+Q=Z,OdfMHUR-7Ao%evJh.=aiq,#r0Ux0dm'!l|zeAXj||$>1_(Lv4Hc",&F}sbHeK0`SBA$_|XP Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Validation-by: monnier.florent@gmail.com Subject: Re: [Caml-list] [ANN] ocaml-lua v1.0: OCaml binding of Lua library Le samedi 01 septembre 2012 16:03:18, Paolo Donadeo a =C3=A9crit : > I'm happy to announce the first release of ocaml-lua, the OCaml > binding of the Lua library. With ocaml-lua you can embed a Lua > interpreter in an OCaml program in a few lines of code, and use Lua > for configuration or customization purposes. >=20 > Here are some references: >=20 > The homepage of the project is hosted on OCaml Forge: > http://ocaml-lua.forge.ocamlcore.org/ > The complete library reference (ocamldoc generated) is here: > http://ocaml-lua.forge.ocamlcore.org/api-lua/ > Source tarballs are on the download page on OCaml Forge: > http://forge.ocamlcore.org/frs/?group_id=3D167 > The official GIT repository is here: > http://forge.ocamlcore.org/scm/browser.php?group_id=3D167 > Bug reports and feature requests are on my page on GitHub: > https://github.com/pdonadeo/ocaml-lua/issues >=20 > I hope it could be useful. It is useful at least for me ;) Thanks a lot! There is a problem with the returned status, and to make ocaml-lua able to = be=20 compiled with both Lua 5.1.X and 5.2.X, in Lua 5.1.X there is: /* thread status; 0 is OK */ #define LUA_YIELD 1 #define LUA_ERRRUN 2 #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 #define LUA_ERRERR 5 in Lua 5.2.X there is: /* thread status */ #define LUA_OK 0 #define LUA_YIELD 1 #define LUA_ERRRUN 2 #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 #define LUA_ERRGCMM 5 #define LUA_ERRERR 6 and in ocaml-lua there is: let thread_status_of_int =3D function | 0 -> LUA_OK | 1 -> LUA_YIELD | 2 -> LUA_ERRRUN | 3 -> LUA_ERRSYNTAX | 4 -> LUA_ERRMEM | 5 -> LUA_ERRERR | _ -> failwith "thread_status_of_int: unknown status value" I asked to join the project but I didn't commit anything because I don't kn= ow=20 how to fix this kind of translations. I've found this kind of mismatch in other ocaml bindings when the real valu= es=20 are used instead of the symbolic names, but it seems that this kind of code= is=20 written for performance purpose. In my own projects I always use a switch to convert from C to ocaml, and an= =20 array in the other direction, as in: http://www.linux-nantes.org/%7Efmonnier/ocaml/ocaml-wrapping-c.php#ref_enums So my question is, what is the better way to handle this kind of problems w= ith=20 this kind of translations ? And even with the other method (switch/array), we can use the C preprocesso= r=20 on the C side, and add a default at the end of the switch, but what is the= =20 recommended method for the OCaml side ? If there is an additional value for= =20 the enum, should we include it or not when compiled with the older version = of=20 the API ? (and raise an exception). Or generate different variants to refle= ct=20 the API at compiled time ? --=20 Best Regards Florent