lua-users home
lua-l archive

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


On Mon, Nov 14, 2011 at 10:24 PM, Stefan Reich <stefan.reich.maker.of.eye@googlemail.com> wrote:
I'm still dreaming of a Lua IDE that is smart enough to see what types
my variables have and what methods the objects support.

This is definitely on our roadmap. There are some real challenges, though: type inference is about propagating constraints across variables on which values they're allowed to contain. If your language and type system haven't been designed explicitly to facilitate this propagation (in practice, if your type system isn't based on Hindley & Milner's), you won't be able to guess much about variable, unless users put a lot of type annotations in their code. Moreover, the constraints system quickly becomes unmanageable when subsumption (implicit subtyping) involved. And we need some subtyping in Lua. For instance a type "anything" to type the 2nd arg of table.insert(): this "anything" is a supertype of every other, more precise type.

So we consider parsing an extended version of luadoc tags, to extract optional typing hints from them without breaking the language; this will allow users to specify the types handled by their APIs. Some things will most likely not be handled: for instance, "table.insert(table, [number, ] anything)" would require an extremely sophisticated  type system to handle the optional 2nd arg (signature overloading is the 2nd nemesis of type inference systems, with subtyping). Once the type annotation system works properly, we'll be able to progressively add local inference rules, to guess parts of what the user hasn't annotated. We'll most likely do that in Lua/Metalua, so that proficient Lua developers will be able to tweak it without needing to know the intricacies of the Eclipse SDK.