lua-users home
lua-l archive

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


On 11/6/07, steve donovan <steve.j.donovan@gmail.com> wrote:
I'm coming to agree with Fabien that any meta-extension should be used
to add _new_ things to Lua, not confuse the issue with curly braces ;)

The proposal of the day: type annotations for function 'prototypes':
function F(String s, Number t)
        ...
end

The actual code that the compiler sees is this:

function F(s,t)
   _assert_type(s,"string","s")
   _assert_type(t,"number","t")
  ....
end

One of the tutorials in metalua manual proposes pretty much this. I've just realized that it somehow "disappeared" from the manual, but an older version is here: http://luaforge.net/docman/view.php/227/164/tutorial.typecheck.pdf, and up-to-date sources are here:
http://metalua.luaforge.net/src/samples/tutorial-typecheck.lua.html

Since global code manipulation is more practical in metalua, it allows more stuff: it also checks returned types, it checks every re-assignment to a typed variable, and the type grammar is quite rich.

I'm also occasionally working on static type inference for (some dialect of) Lua, but it's a much more more complex and theoretical issue. However, I'll finish metalua 0.4 before going seriously back to this, and anyway, it'll be more interesting for lambda-loving theoreticians than hackers.