[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Functions with individual metatables
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 26 May 2009 08:30:30 +0200
On Mon, May 25, 2009 at 7:46 PM, Petite Abeille <petite_abeille@mac.com> wrote:
> I, for one, use FuncTable all over the place :)
> for aContact in aDB( 'select * from contact' ) do
> print( aContact.name, aContact.email )
> end
That is indeed cool. It's true that Lua people don't use standard OOP
so much because it's so easy to create closures of various types.
My unscientific tests here show that there's only a 35% penalty for a
table call over a straight local call, and a 45% penalty for a
standard OOP call (i.e. metatable lookup). Straight lookup (object
contains methods) is a 35% penalty. Now microbenchmarks are to be
taken with lots of sodium chloride, but this does give an upper bound
on the penalty, since these are trivial function calls, and usually
the body will actually do some work ;)
So, not bad at all! But it would be nice if the standard library
respected __call.
steve d.