lua-users home
lua-l archive

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




2011/2/10 Philippe Lhoste <PhiLho@gmx.net>
Steven Donovan wrote:
>> I'd be curious what a language has to do to be strongly typed by this
>> definition....

I am not a specialist, but it seems that languages like Haskell and Scala are seen as (very) strongly typed. At least they have elaborate (and complex) type systems and are quite touchy about this. They are at least stronger than Java (with its generics using type erasure, although it indirectly affects Scala as well).

Yes, strongly type will notice you that all type convert will all has cost. and prevent errors. so correctness and conveniences IMHO the former is more important.

So, maybe in e.g. Lua 6, we may complete remove the implicit convert in Lua.




On 10/02/2011 11:14, Axel Kittenberger wrote:
Correct me if I'm wrong, but I always understood under strong types no
implicit//hidden typecasts.

Well, Scala makes lot of use of implicits, but at least they are defined formally... And they sure ease the task of the programmer (eg. for Java compatibility) although they can bring confusion as well.

As I know, strong types has another name: static type, they means the variable instead of value has type: value has not type, but variable does. i.e. the object/memory/space hold the corresponding value has type, but not the value itself.

e.g. value 1 has not type, but the space of "1" has type "int", so if we change the type of space, the value "1" will have a different type, maybe string "\1" (a string has only one character, and it's value is number 1).

in another way, implicit types also has another name: dynamic type, they means the variable all have not type, the value itself has type. that means, the value "1" has type "int", wherever it was. and variable e.g. a has no type, it could contain any value of any types.

e.g. Lua, ruby, python are implicit type or dynamic type.

but the point is, dynamic type means "the type of value is immutable", that means, you can not change the type of 1, 1 has type "int" and always has this type. if you change int 1 to another type, you also create a new value with the corresponding type you want convert. in Lua, string "1" and number 1 can not in the same memory/space/object, they are just different values.

so, the point is not "type", Lua is a complete implicit type language, but the point is "implicit conversion", what means, does Lua need create new value implicit? I think the answer is no.

 
--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --