lua-users home
lua-l archive

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


On 31 Mar 2013, at 09:58, Marco Salamone wrote:

> I've read that a Lua program IS a table.

I've not managed to follow your entire post, but a lot of it seems to be based on this, and I don't think that's correct, or if it is, I'm totally misunderstanding Lua myself. Lua is very table-centric, but functions are not tables, and share little in common with tables, other than they are both values. Yes, userdata and tables have a call metamethod, but I think this is just nice syntax for function/table/userdata polymorphism, nothing more. x.__call(x), and x:__call() work just as well as x(). You can even cock it up like so:

function mt:__call()
	print(string.format("mt's __call on %s", self))
end

x = {}
setmetatable(x, mt)

-- This works, but is probably a mistake!
y = {}
x.__call(y)

> Let me first note that I haven't coded anything in the language yet- which in many ways is rude of me, but I'm operating under a compulsion to understand and discuss it.

There are some things that we can only experience and understand second hand, for these things we have to rely on other people's accounts. However I don't think anyone will disagree that the best way to understand anything is to get first hand experience. If you're so interested, is there some reason you can't try Lua and come back with at least some basis for a discussion?

Also there is a bit of a tendency on mailing lists where people who appear to have made more effort - like actually trying stuff, will get better responses.

Kev