lua-users home
lua-l archive

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




On Mon, Jul 1, 2019 at 7:30 AM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> How many stack slots do I have available when __close is called?

In any realistic use, the code needs to call something to "acquire a
resource" in an _expression_:

  local <toclose> x = <acquire a resource>

So, if that call worked, there is at least one stack slot available
to release that resource.

Of course, we can come up with some weird (at least in my view)
code like that, to prove me wrong:

  -- 'f' is a resource acquired in some different scope
  local <toclose> x = f

We will try to improve on that.

-- Roberto


It's not that strange if f is a function argument: it's not an unusual pattern at all to do something like run(newContext()).

/s/ Adam