lua-users home
lua-l archive

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





On Mon, Dec 23, 2013 at 8:38 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
On Friday, December 20, 2013 10:35:25 AM Sir Pogsalot wrote:
> In some situations it would make sense to assign a table to
> __pairs/__ipairs -- similarly to how you can assign a table or function to
> __newindex/__index.

I was going to mention something about __call and whether a callable table
should be treated like a table or a function. But then I see that __index
currently ignores __call as well.

--
tom <telliamed@whoopdedo.org>


Actually it errors on callable tables being assigned to __call (Lua 5.2)

 > t = setmetatable({}, { __call = setmetatable({}, { __call = function () return 42 end }) })
> = t()
stdin:1: attempt to call global 't' (a table value)
stack traceback:
    stdin:1: in main chunk
    [C]: in ?

I do not like this but I was advised to raise the issue in a separate posting, which I have done :-)  The problem is if a __call is found, that reference is "raw-called".  Another __call isn't looked for, it just errors because it expected a function :(  So inflexible >.<