[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal] Thread Metatable
- From: Sean Conner <sean@...>
- Date: Tue, 23 Jun 2015 14:18:54 -0400
It was thus said that the Great Soni L. once stated:
>
>
> On 23/06/15 03:09 PM, Sean Conner wrote:
> >It was thus said that the Great Luiz Henrique de Figueiredo once stated:
> >>>>co = coroutine.create(function() print"test" end)
> >>>>...
> >>>>Can we get a thread metatable?
> >>>debug.setmetatable(co,{__len=function(thread) return "abc" end})
> >>>print(#co) --> abc
> >>I think the OP wants
> >> debug.setmetatable(co,{__index=coroutine})
> >>so that he can say co:resume().
> > Or
> >
> > debug.setmetatable(
> > co,
> > {
> > __call = function(co,...)
> > return coroutine.resume(co,...)
> > end
> > }
> > )
> >
> >so that we can say
> >
> > co()
> >
> > -spc
> >
> >
> And how do you get the status with that?
>
> Not co:status(), that wouldn't work...
You could always add __index ...
-spc