|
On 2/11/2011 1:47 PM, steve donovan wrote:
I agree. It's a bit of a grey area, I'm not sure if I would consider this part of the type system, though you can partially / explicitly implement some of the things a "stronger" type system can do.On Fri, Feb 11, 2011 at 2:39 PM, Christian Tellefsen <christian.tellefsen@funcom.com> wrote: A fair summary. But these two points:* It has no type modifiers (like const, for example). * You can't create new types or new complex / compound types.We can make a table read-only through some metatable magic, so 'const' can be catered for. And metatables generally give the mechanism to generate _user_ types, even if they do all collapse into tables or userdata on the language level. steve d.
For example, you can't declare any variable as being const, though you can make a table object that can't be changed at all. In this case, Lua is "weaker" than, say, the C++ type system is, since you can place fewer type constraints in Lua.
The language doesn't do implicit type checks on metatables, though you can do it yourself by explicitly typing in a check using getmetatable(). In this case, Lua is "weaker" than (for example) C++ classes, in which types are automatically checked.
Of course, "weak" and "strong" here isn't saying anything about whether the language is "good" or "bad", but rather something about how it works, what it is useful for, and how it should be programmed in :D
Cheers, Christian Tellefsen