lua-users home
lua-l archive

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


On 29 January 2018 at 16:39, Paige DePol <lual@serfnet.org> wrote:
>
> Actually, adding an optional type system to Lua was considerably easier than
> I thought it would be. Just needed to add an extra field in the lua_TValue
> struct to hold the expected type, then check the current type against the
> expected type for any instructions that set R(A) and throw an error if they
> do not match. Of course, if there is no expected type then no check is done.
>

Interesting. Lua can reuse the same stack slot for different variables
(of different types) and variables may be left unitlialized. How /
when  do you set the expected type? I could not see a way of doing
this - so I maintain the expected type in the function's Proto
structure.

Regards
Dibyendu