[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Table constructions
- From: Gavin Wraith <gavin@...>
- Date: Sun, 05 Mar 2006 20:00:10 GMT
In message <440B3ACF.40805@entai.co.uk> you wrote:
> I'm trying to modify Lua so that a table constructed as:
>
> t = { weight = 9, wibble, foo }
>
> results in a table as:
>
> { weight = 9, wibble = true, foo = true }
>
> I've been playing around with the code in lparser.c, but I'm not having
> much success (this is the first time I've done any hacking on Lua).
> Thanks,
> Andrew Sidwell
Andrew I know this is not exactly what you want, but what about
this?
insertkey = function (t)
local f
f = function (k)
if k then
t[k] = true
return f
else
return
end -- if
end -- function
return f
end -- function
mytable = { weight = 9 }
insertkey (mytable) "wibble" "foo" (57) "grumpkin" ()
for k,v in pairs(mytable) do
print (k)
end
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/