lua-users home
lua-l archive

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



On 6-Dec-06, at 6:51 AM, Shmuel Zeigerman wrote:

Rici Lake wrote:
On 5-Dec-06, at 6:37 PM, Shmuel Zeigerman wrote:

C provides SetEvent function, and Lua registers only
*one* event handler. C calls that handler passing
event name (a string) and any number of parameters.
Or you could just register the handler table, which would also work nicely with the Lua 5.1 module system.

Yes, but what extra functionality/flexibility would that achieve?
Could you give a simple example?

It gives no extra functionality, just syntactic sugar. It lets you define your collection of handlers in a single module file, using standard function definitions:

function onStartup() ... end

function onShutdown() ... end

etc.

On the other hand, the events onKeyPressed() and onMouseClick() (and friends) look like they should apply to some interface object. In that case, they could simply be normal object methods.