lua-users home
lua-l archive

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

On Fri, May 17, 2013 at 1:41 AM, Rena <> wrote:

doesn't add overhead to every instantiation. For that matter since Lua is interpreted, any kind of interface system would add overhead to at least every time the module is loaded, which might be an issue for e.g. a web server; I wonder if there's a way to eliminate that overhead using luac...

One approach is to only do the checking when in 'debug' mode, although Tony Hoare thought that switching off assertions in production was like going to sea without lifeboats. There are caching tricks possible (so that the metatables of objects implementing certain interfaces get flagged as supporting them dynamically) but still it can be expensive.  As for luac, I suspect we've already lost most type information hints at that point.  You'd need a static type inference system and that's not an easy thing, and not always possible without some static type annotations.