lua-users home
lua-l archive

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


Christian Bielert wrote:
> A thing that I will need pretty early on will be clean, fast type-checks on
> function entry.

I don't think so. Why whould you *need* type checks? Have you
heard of "duck typing"?

> Obviously, the type-checks would have to be extended to also support cdata
> and custom class-objects, but the point should be clear. It basically
> reflects a function declaration as it can be found in C++, i.e. in C++ you
> would write the above code as: void foo(number a, string b = "nA", int c)

If you use the FFI, then it'll already do the type checks when you
pass arguments to a C function.

> Anyway, I'm mainly asking here since I have little experience with lua, and
> if there are any fundamental flaws with my approach, the sooner I know it
> the better. :)

Lua is a dynamically typed language. Either you work with it or
you wreck it.

If your first instinct is to create a huge framework that does
type checking and your own flavor of classes -- this is a sure
sign you're heading in the wrong direction.

Related: http://lua-users.org/lists/lua-l/2011-10/msg00825.html

--Mike