lua-users home
lua-l archive

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


Hi,

Following is a brief description for some additional type checking in
Ravi. I am pleased that this works as Ravi maintains Lua's approach of
compiling code in a single pass with no intermediate AST. This makes
it harder to add type checking - added to that is my lack of complete
understanding of the Lua code generator, which always makes me nervous
when trying to make changes.

The newly supported type annotations are:

string - Lua string
closure - Lua function
Name - A value that has a metatable registered in Lua with given Name

These type annotations can now be used in:

* function parameters
* local variable declarations

Additionally the @type syntax is supported for type assertions.

Unlike the other type annotations in Ravi - these annotations do not
lead to more efficient JIT code generation. The aim here instead is to
enable cheaper type assertions, at compile time if possible, but
typically at run time. The syntactic support makes the code less ugly
as well.

Note that these features are new and testing is still ongoing. If you
try them out and hit problems please let me know.

Previous posts on this topic:

http://lua-users.org/lists/lua-l/2017-10/msg00063.html
http://lua-users.org/lists/lua-l/2017-01/msg00164.html

Regards
Dibyendu