[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Makes funcname in Lua same as var? (lua syntax)
- From: David Manura <dm.lua@...>
- Date: Thu, 10 Feb 2011 23:24:28 -0500
On Thu, Feb 10, 2011 at 10:31 PM, Xavier Wang <weasley.wx@gmail.com> wrote:
> but can not write:
> local t = {}
> function t[1]() end
The closest may be
local t = {}
setmetatable(t, {__newindex = function(t,k,v)
local i = k:match'^_(%d+)$'
rawset(t, i and tonumber(i) or k, v)
end})
function t._1() print '1' end
t[1]()
> so maybe:
> funcname = var [`:' Name]
var there can lead to some confusion:
function f(x)[1](y) end
because parenthesis are used in multiple ways in Lua (as well as in
math): expression grouping, function calls, and function argument
lists.