lua-users home
lua-l archive

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

What is wrong with the following proposal?

  local <some mark to be invented> name = exp

Unlike a regular 'local' declaration, this one must define only one
variable and it must be initialized. (Both restrictions could be easily
removed; they are more about programming style.)

When the local 'name' goes out of scope, then:

1 - if its value is a function, that function is called (no parameters)
2 - if its value is a table/userdata, its __close (or some other new
name) metamethod, if present, is called.

Otherwise, 'name' is like any other local variable.

-- Roberto