[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A Lua todo-list DSL
- From: Dirk Laurie <dpl@...>
- Date: Wed, 18 May 2011 13:51:56 +0200
Jonathan Castello <twisolar@gmail.com> wrote:
> do
> local list = {}
> local mt = debug.setmetatable(0, {
> __call = function (self, content)
> list[self] = content
> end,
> })
>
> ; (1.) "Hello, world!"
> ; (2.) "Get groceries"
>
> for k, v in ipairs(list) do
> print(k .. ": " .. v)
> end
> end
Are semicolons required? Let's try ...
---- Do this in the global namespace
list = {}
function reminder(self,item) list[self] = item end
debug.setmetatable(0, {__call = reminder})
-- The following is OK
(1) "Butter"
(2) "Eggs"
-- This too
(3) "Tea"; (4) "Coffee"
-- But this gives an error
(5) "Whisky" (6) "Beer"
-- As does this
(7) "Brandy" --[[
--]] (8) "Gin"
----
D.