package lua-ml

  1. Overview
  2. Docs
An embeddable Lua 2.5 interpreter implemented in OCaml


Dune Dependency





Published: 02 Dec 2019


Lua-ML - an embeddable Lua 2.5 interpreter implemented in OCaml

Lua-ML is an implementation of the Lua 2.5 programming language in OCaml. Just like the original Lua implementation in C, it is designed for being embedded into applications as an extension language. In this case, for applications implemented in OCaml.

Lua is designed to extend applications written in C and its API is tailored to do that, using a stack-based design to pass values between C and Lua. Lua-ML is specifically tailored to extend applications implemented in Objective Caml and employs an interface that makes passing values between the two worlds seamless.

The Case for Extension Languages

Why would you want to use an extension language for your application? Highly configurable software like a web server, text editor, compiler, game or test generator has probably too many configurations as that these could be handled by command-line options alone. This leads to the addition of configuration files which typically permit to assign strings, numbers and booleans to names. As the project matures, more flexibility is needed, for example some kind of name space to manage the ever increasing number of options. At this point the design of most configuration files starts to break as it was never designed for this.

An extension language provides much more expressive power that you might not need initially: assigning values to names is syntactically as easy as in any other format, yet it provides a vastly superior upgrade path. Used to its full potential, a language like Lua permits users to extend an application with new functionality that would be never possible in a traditional configuration file as such a file has no notion of execution.

In summary: an extension language is a good choice for any application that needs to be highly configurable by the user and potentially needs also to be extensible by the user. Rather than designing your own, Lua provides a well designed language for this purpose.

To make an application truly extensible it needs to be designed for that. This means that the most important data types and functions are accessible from the Lua side such that they can be manipulated by the user. How to do this best is currently beyond the scope of this documentation. However, here are two examples that use an earlier version of Lua-ML and that you could study:


For an example application, take a look at example/

History and Raison d'être

Lua-ML was developed as part of the [C-- compiler] project and is part of its source code. The C-- compiler uses an elaborate build process which makes it difficult to build just the Lua-ML library and a sample application. This is an attempt to untangle Lua-ML from its C-- legacy to make it more easily available.


The Lua-ML interpreter was written by Norman Ramsey It was originally part of the C-- project at and brought to GitHub by Christian Lindig who also worked on the C-- project 2000 to 2002.


Lua-ML is distributed under the two-clause BSD license. See the LICENSE file for details.

Dependencies (2)

  1. ocamlbuild build
  2. ocaml >= "4.07" & < "5.0.0"

Dev Dependencies


Used by (1)

  1. soupault < "1.8.0"




Innovation. Community. Security.