Towards "to closed" local variables
Start of the implementation of "scoped variables" or "to be closed" variables, local variables whose '__close' (or themselves) are called when they go out of scope. This commit implements the syntax, the opcode, and the creation of the corresponding upvalue, but it still does not call the finalizations when the variable goes out of scope (the most important part). Currently, the syntax is 'local scoped name = exp', but that will probably change.
This commit is contained in:
@@ -173,6 +173,15 @@ end
|
||||
assert(x==20)
|
||||
|
||||
|
||||
-- tests for to-be-closed variables
|
||||
do
|
||||
local scoped x = 3
|
||||
local a
|
||||
local scoped y = 5
|
||||
assert(x == 3 and y == 5)
|
||||
end
|
||||
|
||||
|
||||
print('OK')
|
||||
|
||||
return 5,f
|
||||
|
||||
Reference in New Issue
Block a user