lua-users home
lua-l archive

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

1) About limitations.
Why to-be_closed variables must be initialized at the very beginning?
Why they must be const?
Why an error must be raised if a value doesn't have the metamethod?
Are all these limitations necessary?
The concept of "to-be-closed" variables would be more clean and easy-to-understand without all these restrictions.
I mean, all the specific actions should be taken only when variable is going out of scope and only if it has the metamethod.
Besides that, such variable could be used as usual local variable.

2) About naming.
"close" says about the value (the value will be closed) and says nothing about the variable
"scope" says about the variable (the variable goes out of scope) and says nothing about the value
We need a word emphasizing the semantical link between "value" and "variable"
There was a suggestion "bind" (the value is bound to the variable)
I suggest another one: "evict" (the value is evicted from the local variable when the variable goes out of scope)
local <evictable> x = setmetatable(obj, {__evict = ...})
The name doesn't insist on what user should use this feature for (closing/finalizing/releasing/destructing/unlocking).
IMO, the word "evict" explains the purpose of such variables better than the word "bind".
The phrase "evictable variables" is good enough too.