lua-users home
lua-l archive

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



On 20/11/14 08:38 AM, Dirk Laurie wrote:
2014-11-20 7:25 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:

I know that one of the very few global functions that I've added as part of
my "standard Lua" environment is an `is_callable` function.
Why not a `which` function?  Returns the function that would be called or nil.

Because calling a table(...) invokes __call(table, ...), NOT __call(...).

Would be cool if type() had extra fields:

type(3) -> "number:integer"
type(3.0) -> "number:float"
-- etc... OR: (mostly backwards compatible)
type(3) -> "number", "integer"
type(3.0) -> "number", "float"
type(setmetatable({},{__call=print})) -> "table", "callable"
-- etc

But then it would become more of a capability test thingy...