[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc2) now available
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 22 Jun 2011 11:31:25 -0300
> On Wed, Jun 22, 2011 at 3:10 PM, Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
> > There seems to be another problem with the function approach (assuming
> > an opaque structure). A subtle detail when creating files in Lua is
> > that the creation of the userdata may fail (memory error). So, if the
> > user opens a file and then calls this new function, Lua may raise an
> > error and the open file is lost forever.
>
> Then make this new function return NULL rather than throwing an error.
For that it would need to enclose the "lua_newuserdata" into a
lua_pcall. It is doable, but the "export structure" approach
seems simpler (does not need lua_pcall) and more flexible (user
may add other fields).
-- Roberto