[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.sub and __call metamethod
- From: "David Manura" <dm.lua@...>
- Date: Sat, 18 Oct 2008 15:17:12 -0400
On Sat, Oct 18, 2008 at 2:16 PM, Javier Guerra Giraldez wrote:
> i think a nice feature for 5.3 could be to allow more than one parameter as
> index: o[x,y,...] would be interpreted as getmetatable(o).__index(o,x,y,...)
A related suggestion was to allow __index to return multiple
values[1]. What then is the real distinction between __index and
__call other than syntax ("[]" and "()")?
mt = {}
debug.setmetatable(function()end, mt)
mt.__index = function(t,k) return t(k) end
function f(x) return x^2 end
assert(f(5) == 25)
assert(f[5] == 25)
[1] http://lua-users.org/lists/lua-l/2007-07/msg00177.html