[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Coroutine __close metamethod proposal
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 31 May 2019 10:04:12 -0300
> Philipp> And maybe functions should have a default toclose behavior as
> Philipp> well.
>
> The ability to use a function as a toclose value previously existed, but
> was removed - I guess (from the timing) as a result of a discussion I
> had on the list about how a restricted environment needs control over
> what happens in error handling.
>
> As it stands, if an environment doesn't expose setmetatable() to the lua
> code, then it can ensure that the lua code can't get control over error
> handling other than with pcall, which the environment can intercept.
Right. And there is one more reason:
* Functions interact badly with coroutines. If a coroutine yields
and is never resumed again, its to-be-closed functions will never
run. To-be-closed objects, on the other hand, will still be closed,
provided they have appropriate finalizers.
-- Roberto