lua-users home
lua-l archive

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


Jamie Webb wrote:
In this vein though, it would still be nice if one could write in Lua
something like:

function foobar(String x, MyClass y) ... end

Where String and MyClass are predicates aginst which the arguments can
be checked, if enabled by an interpreter flag.

function String(x)
  return assert(type(x)=="string", "String expected, got " .. type(x))
end

function MyClass(x)
return assert(classtype(x)=="MyClass", "MyClass expected, got " .. classtype(x))
end

:-)

D.