[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: New Lua 4.1 (work) event (handler) tables
- From: "Joshua Jensen" <jjensen@...>
- Date: Thu, 20 Dec 2001 13:14:54 -0700
> > I'm wondering why you chose to only make the event tables (handler
> > tables) available to tag methods only? That is:
> >
> > As I have stated in previous postings, having these handler tables
> > available for storing functions can save considerably on memory.
> > Sure, I can put whatever functions I want in the handler
> table, but I
> > have to use the ugly syntax in the second print() above to
> access the
> > data.
>
> You can use inheritance (delegation) for that, as we have
> always done in Lua:
>
> Events = { print = function (self) print(self.x) end }
> Events.index = Events
>
> MyTable = {x = 0}
> eventtable(MyTable, Events)
>
> MyTable:print()
Sure... But the other part of the equation is speed. For those of us
who operate in real-time environments where memory is limited, the
handler tables take care of the size, but nothing takes care of the
speed. It is ridiculous to perform a table lookup, have it fail, call a
tag method to do yet another table lookup, when you know exactly where
the function you needed to call is already (in the handler table),
thereby only resulting in one table lookup.
Is there a solution to the speed issue?
Josh