lua-users home
lua-l archive

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


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.

-- 
Javier