[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: object methods as first class values
- From: "Nick Trout" <ntrout@...>
- Date: Thu, 28 Nov 2002 18:06:53 -0800
> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br] On Behalf Of Ignacio Castaño
> Sent: November 28, 2002 3:24 AM
> To: Multiple recipients of list
> Subject: object methods as first class values
>
>
> Hi,
> In lua functions are first class values, that's nice, because
> lua functions
> can be used to customize behaviours the same way callbacks
> are used in C,
> for example:
>
> ok = Button()
> ok.onClick.add( exit )
Just add a closure as a handler:
ok.onClick.add( function() app:exit() end )
And if you need to bind any parameters you just put them in your
closure?
ok.onClick.add( function() local s=0 app:exit(s) end )
Or, instead of adding a function handler couldn?t you replace the
default onClick function?
ok.onClick = function() exit() end
or
ok.onClick = function() app:exit() end
Nick