lua-users home
lua-l archive

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

Raffaele Salmaso wrote:
Yes, you can.
If you get the instance method, you really get the closure, not the real method. But if you get the class method, this is the real method, no wrapper.

You're absolutely right, of course. Hey, it was late and I was low on caffeine...

Incidentally, it occurs to me that you should be able to optimise things by making __call pregenerate all the closures. It ought to be something along the lines of:

		__call = function(self, ...)
			tmp = {}
			setmetatable(tmp, klass)
			for i, j in pairs(super) do
				tmp[i] = function (...)
					return j(tmp, unpack(arg))
			if self.init then
				self.init(tmp, unpack(arg))
			return tmp

...although that doesn't take in to account object inheritence.

Would that work? If so, would it speed things up any?

[insert interesting .sig here]