lua-users home
lua-l archive

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


On Sun, Sep 27, 2009 at 7:01 PM, Ivan Kolev <ikolev@gmail.com> wrote:
> Static typing and compile-time checks (including warnings to the max) are
> indispensable.

In the absence of static typing, then dynamic type checking is the best we get:

http://lua-users.org/wiki/LuaTypeChecking

Further down that page is 'Solution: Function Decorators' which is an
interesting idea of David Manura. Here I'm using a later notation that
he introduces in his article about decorators:

sum = typecheck("number", "number", "->", "number") ..
  function(a,b)
    return a + b
  end

Now, this technique makes it possible to switch actual assertions on
and off at compile time, but it also gives a structured way to specify
function signatures.

Of course, it's a bit more work, but some extra work seems essential.
Given how fast a person can write Lua, we have to slow that person
down a little bit and force them to give some more clues ;)

steve d.