There’s an article called Boostrapping a Forth in 40 lines of Lua code[sic]1 that’s been around since around 2007. It’s a great article and I’d highly recommend reading it. However, I only recently found it after some interest in Forth. This is the Forth outer interpreter in Lua from the above article reformatted a bit: eval = function (str) return assert(loadstring(str))() end subj = "" pos = 1 parsebypattern = function (pat) local capture, newpos = string.
Lately I’ve been playing around with writing C bindings for a C++ library. Your first thought might be, “Why would you bind a C++ to C?” Those of you who have ever had to do bindings to other languages may already know the answer. In general, it’s much easier to bind C to another language than it is to bind C++ directly. Another, albeit less likely, reason might be because a client wants a C interface instead.
I’ve mentioned before (actually, probably only in that last post) about a game I’ve been working on on and off for the last few years (I think I said three, but it’s actually been five, with it being inactive for most of that time.) I had decided long ago that it would probably be scripted with Lua and I’m just now finally getting around to experimenting with that. I’ve ultimately decided it’s going to either be using OOLua or Luabind.
In a personal project which I’ve been working on and off on for the last three or so years (without really getting much done to be totally honest), I’ve decided to use Lua for the configuration file. The project itself is in C++, so this lead me to use the Lua C API to embed it in the project. Prior to deciding on Lua, I was using a manually parsed key/value format.