lua-users home
lua-l archive

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


On 12 April 2018 at 12:53, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Thu, Apr 12, 2018 at 12:41 PM, Viacheslav Usov <via.usov@gmail.com> wrote:
>> about deterministic collection/finalization. The principal issue is that
>> some userdata are much more than a handful of bytes, they can be handles,
>> connections, money and what not.
>
> This is the important point. I first encountered this issue when doing
> Lua on top of Java in Android - the userdata could contain really big
> objects like images, but the Lua GC had no way of knowing this. A GC
> on top of a GC! I recall that Eric Wing had similar issues with his
> ObjectiveC/Lua bridge.
>
> I must say I like the idea of deterministic resource finalization,
> although I understand it has runtime implications.
>

As I was writing my initial post I did think about suggesting a
try/finally type approach. But the problem with Lua is that it has
adopted a longjmp based exception handling method ... this makes it
hard / maybe impossible to implement deterministic 'finally' type
clause. When Java code calls C code via JNI, the exception handling is
not done using longjmps.

Regards
Dibyendu