News for hackers. Stuff that matters.
Re:Closures and Objects Are Equivalent (2013) by samatman on Sunday November 20, 2022 @07:55AM (#33680537)
> What can you do with a closure? You can call it. What can you do with an object? You can not call it.

It's a good thing Lua doesn't have objects!

Because in Lua, you can call a table if it has a `__call` metamethod, this is valid Lua:

   (setmetatable({a = 5}, {__call = function(t) return t.a end}))()
which returns 5.

There are no comments on this comment yet.