lua-users home
lua-l archive

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

Regarding the type system in Javascript: That type system is similar to what is proposed for Lua: They have an "Any" type, which they call Object, they use Pascal like syntax: "var x:Integer; function foo(x:Number):Number {return x;}", defining types is optional, and adding type annotations does not change the meaning of the program.

It is different in that:

1) they allow type expressions such that you can use a variable as a type in the syntax (with the meaning that type intended is the type of the variable),

2) they have many more types in the language (including a "Never" type for no values, and "Void" for functions that do not return a useful value),

3) they define a range of implicit coercions

4) they provide syntax for explicit coercions.

Regarding 1, I think that is a mistake.

Regarding 2, a "Void" type might be useful.

Regarding 3, the only implicit coercion in the proposal is that everything can convert to the "Any" type. The others are not relevant in Lua, given the few basic built-in types.

Regarding 4, this can be expressed as functions that take an any parameter and return the required type, so no need for special syntax.

Asger Ottar Alstrup