lua-users home
lua-l archive

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

AOA> I believe that type checking is an efficient way to test many things, and
AOA> thus an efficient way to express many of your tests. By your logic, syntax
AOA> errors might as well be delayed until runtime as well. I do not agree that
AOA> this is a productive approach. It takes two seconds to compile a file,
AOA> while running a test suite can take minutes. I believe that the sooner
AOA> problems are found, the better.

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: 

  local a: int, b: string, c
  a = 1
  c = a
  b = c

There may not always be a way to check wether the assignment 'b = c'
is valid using a static type checker. 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.

Just a thought: how about a lint-like thing? There was a post some
time ago about a type inference engine for python, I am pretty sure
sth similar could be made for lua. You would have static checks, that
might be assisted by special comments as some lints do. But you would
not need to change the language in order to accomplish this, plus it
would spare the need for a major semantic change to lua, being that
variables do not have types, only values do.