lua-users home
lua-l archive

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


I noticed that numbers in Lua can have a trailing decimal point, even
if there's no fractional part (such as "1."). This gave me an idea for
a horrible little DSL that emulates a to-do list:

----
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
----

It's pretty horrific, but interesting nonetheless.

~Jonathan