lua-users home
lua-l archive

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


* Cosmin Apreutesei:

>> As Roberto said.  Normally, that is a program error, like holding a
>> pointer to a stack object that goes out of scope in C.  Don't do that.
>>
>
> But that breaks garbage-collecting semantics, which assures me never
> to have invalid pointers no matter what... IMHO this brings me back
> down to the C-level of responsibility (watching the stack).

It's like referring to a table index which isn't there.  A stronger
type system could catch that, too, but this wouldn't be Lua anymore.
(You'd need record types, perhaps even row types, and dependent types
to deal with an unbounded array part.)

Obviously, before doing anything with an object that can be closed,
you should check that it's not closed.  This is especially true if
userdata is involved.  I don't see anything wrong with that, except
that it's a bit cumbersome to implement, but this is nothing a user
has to be concerned with.