lua-users home
lua-l archive

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


Dibyendu:

On Mon, Jun 17, 2019 at 11:16 AM Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> I haven't checked but the manual should state that the __close()
> metamethod needs to be idempotent. It needs to track the state of the
> resource so that if it is called multiple times, it still behaves
> correctly.
> This is a well known pattern that most close() operations need to follow.
> Another aspect is that as is recommended in most other languages,
> raising errors in finalizers and close operations is usually a bad
> idea. Perhaps some advice on this should also be in the manual.

NEEDS is a little strong, specially since the <toclose> feature seems
to have an easy and well defined behaviour, and the <toclose>
x.__close() pairs are going to be nested unless someone does some
coroutine stuff ( I'm specifically planning on using it for
ref-counting on a handle I need to share among several coroutines, but
it is just going to substitute an old ref-counting mode ).

And the warning about erroring in finalizers and close methods is a
good hint too, but I think there is already something about it in the
manual, but I'll need to read it again, I'm not sure.

Francisco Olarte