[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is string always same as number? (the consistency of lua)
- From: Christian Tellefsen <christian.tellefsen@...>
- Date: Fri, 11 Feb 2011 13:39:38 +0100
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
- References:
- Is string always same as number? (the consistency of lua), Xavier Wang
- Re: Is string always same as number? (the consistency of lua), Miles Bader
- Re: Is string always same as number? (the consistency of lua), Dirk Laurie
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger
- Re: Is string always same as number? (the consistency of lua), steve donovan
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger
- Re: Is string always same as number? (the consistency of lua), steve donovan
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger
- Re: Is string always same as number? (the consistency of lua), Philippe Lhoste
- Re: Is string always same as number? (the consistency of lua), Xavier Wang
- Re: Is string always same as number? (the consistency of lua), Alex Queiroz