From: Florent Monnier <monnier.florent@gmail.com>
To: caml-list@inria.fr
Cc: Paolo Donadeo <p.donadeo@gmail.com>
Subject: Re: [Caml-list] [ANN] ocaml-lua v1.0: OCaml binding of Lua library
Date: Tue, 4 Sep 2012 01:57:25 +0200 [thread overview]
Message-ID: <201209040157.25686.monnier.florent@gmail.com> (raw)
In-Reply-To: <CAPzAKVDgHCnUptqzmnZBuaLQizuxPR51R_PMM=4pfus7AFLZNg@mail.gmail.com>
Le samedi 01 septembre 2012 16:03:18, Paolo Donadeo a écrit :
> 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.
>
> Here are some references:
>
> 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=167
> The official GIT repository is here:
> http://forge.ocamlcore.org/scm/browser.php?group_id=167
> Bug reports and feature requests are on my page on GitHub:
> https://github.com/pdonadeo/ocaml-lua/issues
>
> 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
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 = 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 know
how to fix this kind of translations.
I've found this kind of mismatch in other ocaml bindings when the real values
are used instead of the symbolic names, but it seems that this kind of code is
written for performance purpose.
In my own projects I always use a switch to convert from C to ocaml, and an
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 with
this kind of translations ?
And even with the other method (switch/array), we can use the C preprocessor
on the C side, and add a default at the end of the switch, but what is the
recommended method for the OCaml side ? If there is an additional value for
the enum, should we include it or not when compiled with the older version of
the API ? (and raise an exception). Or generate different variants to reflect
the API at compiled time ?
--
Best Regards
Florent
next prev parent reply other threads:[~2012-09-04 0:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-01 14:03 Paolo Donadeo
2012-09-03 23:57 ` Florent Monnier [this message]
2012-09-04 4:24 ` Francois Berenger
2012-09-04 14:55 ` Paolo Donadeo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201209040157.25686.monnier.florent@gmail.com \
--to=monnier.florent@gmail.com \
--cc=caml-list@inria.fr \
--cc=p.donadeo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox