lua-users home
lua-l archive

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


On Sun, 30 Jan 2005 02:16:03 +0100
PA <petite.abeille@gmail.com> wrote:

> 
> On Jan 30, 2005, at 01:57, PA wrote:
> 
> > -- The 'magic' incarnation
> > local aTask = LUTask.new( aConvolutedObject, aConvolutedObject.doIt() )
> 
> Ooops... I just realized that I cannot pass the function itself right 
> there... as this will have the unfortunate effect of executing it...

Why not

  LUTask.new(aConvolutedObject, function() aConvolutedObject.doIt() end)

?

For that matter, why wrap tasks around objects in the first place?  This isn't Java.  :)


 I 
> was thinking in terms of @selector instead of actual method 
> implementation... anyhow... passing only the object itself will do 
> instead:
> 
> local aTask = LUTask.new( aConvolutedObject )
> 
> Then the 'routine' method can simply call a default method like 'run':
> 
> -- private method to wrap ivars.method in a coroutine
> local routine = function()
>      if not ivars.routine then
> 	    ivars.routine = coroutine.create( self.object().run() )
>      end
> 
>      return ivars.routine
> end
> 
> And all is good in the Kingdom! Perhaps. Who knows, really.
> 
> Cheers
> 
> --
> PA, Onnay Equitursay
> http://alt.textdrive.com/
> 
>