lua-users home
lua-l archive

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

On Mon, 18 Sep 2023 14:09:36 -0700
Gé Weijers <> wrote:

> On Sun, Sep 17, 2023 at 3:56 AM Jan Behrens <> wrote:
> >
> > Is this a bug that could/should be fixed?
> >
> I don't think this is even a bug, when you yield there has to be a call to
> 'resume' that receives the values yielded, and there isn't any.

Oh, you are right, I missed this.

> You could
> potentially return the values from coroutine.close but that would mean that
> coroutine.close could not 'close' the coroutine because it may have to
> yield potentially multiple times through the cleanup process.
> I have trouble thinking of a use case for this to begin with.

Use case is implementing something like an effect system for Lua, see
<> where causing an
effect is implemented by yielding in Lua. I wanted to use the __close
mechanism to implement something like Koka's "finally"
However, I need to be able to yield from within a "final handler"
because it needs to cause effects (handled by more outer layers).

In my use-case, an unhandled yield will cause another yield in the
outer coroutine; which is why I didn't notice that my example posted
here can't work.

I will think further about my problem.

> -- 
> Gé

Thanks a lot for your feedback!

Jan Behrens