lua-users home
lua-l archive

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


Thijs,

> I get the explanation. But what is the problem? In the example you gave everything works as expected, optimised or not.

Some would expect objects returned by g() to survive until the end of scope (e.g. they're OS locks being held). This is not necessary by the word of documentation and developers, but it happens to be implemented that way and some people rely on that. The problem is that "create-local-and-forget"-style 'RAII' seems to be, as of now, fundamentally incompatible with the "might die as soon as it's surely not accessible" semantics. You must not forget to unlock the lock manually, otherwise you risk having it unlocked for you *earlier*, which is a bit unexpected by some people but makes perfect sense for others.

Best regards,

--
DoubleF