lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've been experimenting with exactly this sort of thing here:

It's essentially a transpiler which compiles an OO curly brackety language to Lua source code. It supports guard expressions which are evaluated at run-time. I had this extended at some point to include cdata types.

The tests show examples of the language:

run with:

./bin/kula <file>

I decided to do a complete rewrite though in this branch:

and I haven't got guards in yet since I've decided to build a bytecode compiler for LuaJIT2 first:

It's all highly experimental and a bit messy, the branches diverge hugely, but right now I prefer to keep it that way because I haven't settled on the syntax and semantics yet.

Hopefully, though, you can get an idea of what can be done and how it performs. You need a fresh version of LPeg to make it work.


This looks extremely interesting. The syntax seems pretty neat compared to lua, and in fact there seem to be ideas there that haven't been explored in many languages yet. I might go as far as using this language, if the inheritance mechanisms are powerful enough.

Also, as suggested, I have performed a benchmark on the typecheck thing, and the results are.. surprising.

function A(n : Number, i : Number) {
  return n + i
n = 0
for i=1,5_000_000_000 {

If I remove the guard from A, the total time required to execute the script seems to not change at all. Now, this may be because the example is stupidly simple, but it's still very interesting. Does luajit optimize away the typecheck? If so, I wonder if it can do so in more complex situations as well.

Using regular luajit, I get around the same timing by the way.