Re: Callables vs functions
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Callables vs functions
- From: "Thiago L." <fakedme@...>
- Date: 2014年11月20日 13:08:12 -0200
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...