default.txt 598 B

1234567891011121314151617181920212223242526272829303132
  1. --[[
  2. Simple signal/slot implementation
  3. ]]
  4. local signal_mt = {
  5. __index = {
  6. register = table.insert
  7. }
  8. }
  9. function signal_mt.__index:emit(... --[[ Comment in params ]])
  10. for _, slot in ipairs(self) do
  11. slot(self, ...)
  12. end
  13. end
  14. local function create_signal()
  15. return setmetatable({}, signal_mt)
  16. end
  17. -- Signal test
  18. local signal = create_signal()
  19. signal:register(function(signal, ...)
  20. print(...)
  21. end)
  22. signal:emit('Answer to Life, the Universe, and Everything:', 42)
  23. --[==[ [=[ [[
  24. Nested ]]
  25. multi-line ]=]
  26. comment ]==]
  27. [==[ Nested
  28. [=[ multi-line
  29. [[ string
  30. ]] ]=] ]==]