lua-users home
lua-l archive

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




On Sat, Oct 5, 2019 at 8:43 AM Rodrigo Azevedo <rodrigoams@gmail.com> wrote:
Why not use a simpler model for <close> variables as a simple
mechanism of a predictable call of __close() from its respective
value?

e.g.:

do
  local x <close> =  whatever
  x = something -- it's OK
  local y <const,close>  = true
  -- y = false -- compile-time error

  -- going out-of-scope
  -- call __close(), if it exists, from 'something' value.
  -- call __close(), if it exists, from 'true' value.
end -- end-of-scope

Namely, it does not imply <const> or checks before variables are out-of-scope.
If we want <const>, just explicitly declares it.


We rehashed these arguments many, many times already.

Short version: performance and robustness. It simply works better to set up the on-exit behaviors right away, and you can do most of the work at compile time. In light of that, making it const is meant to prevent nasty surprises.

/s/ Adam