[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: state of the Lua nation on resource cleanup
- From: Javier Guerra <javier@...>
- Date: Sat, 30 May 2009 19:42:18 -0500
Cosmin Apreutesei wrote:
> > 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).
that's how Scheme and a few other LISP dialects do. A special form (i.e. a macro) defines a lexical scope where a resource is valid. any exit (normal flow, exceptions, continuations-based exit, etc) releases the resource. if you take a reference with you when exiting, it's your problem.