lua-users home
lua-l archive

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


On 2/11/2011 12:46 PM, Alex Queiroz wrote:

     Wrong. Strong typing means that, like in Ocaml, you cannot add
integers to floating point numbers directly. Even in C, with its
static type system, integers are silently promoted to floating point
numbers in such a case.

Unfortunately, 'strong typing' isn't well defined, and means quite a lot of different things. A language can be strongly typed in some ways while simultaneously weakly typed in other ways.

Compile time type checks, lack of automatic conversion, no type conversion, well defined type behavior, detection of type errors, no access to underlying representation, etc., are examples of strong typing.

In general, the earlier you can detect a type error, the less chance there is of you getting surprised by type errors, and the more you can use the type system to detect, the stronger the typing is.

As far as I know, Lua is strongly typed in (at least) these ways:

* It has a type system.
* There is run time type checking (= dynamic typing).
* Typing errors are always detected and reported when they happen.
* You have no access to the underlying representation (no reinterpret_cast, for example). * Each variable always contains a value with a particular type, and you can find out what it is.

And weakly typed in these ways:

* There is no compile time type checking (= static typing).
* It has some automatic type conversion.
* It has fairly coarse grained typing (one single numeric type)
* It has few types (8 or 9, depending on whether you think userdata and lightuserdata are the same type)
* It has no type modifiers (like const, for example).
* You can't create new types or new complex / compound types.

Cheers,
Christian Tellefsen