lua-users home
lua-l archive

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

On Oct 25, 2004 at 06:02 +0200, Gunnar Zötl wrote:
> I think there is a slight misconception here: even if a version of lua
> would be made that supported typed variables, given luas dynamic
> nature, some checks would still have to be done at runtime. Consider
> this - extremely simplified - fragment, using a syntax proposed in an
> earlier post: 
> do
>   local a: int, b: string, c
>   a = 1
>   c = a
>   b = c
> end
> There may not always be a way to check wether the assignment 'b = c'
> is valid using a static type checker.

I would expect "b = c" to be a compile error.  The valid version would
be something like "b = tostring(c)"

> It gets even more interesting when tables and userdata are
> involved. Thus I feel that adding typed variables to the language
> itself is not overly beneficial.

Static typing is really effective at finding some kinds of errors.
But I have a feeling it would add too much size and complexity to Lua.
I believe JavaScript 2.0 has added some kind of type annotations,
though I don't know much about it.  Maybe there is something to be
learned there.

Thatcher Ulrich