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:
Roberto Ierusalimschy
2018-10-08 10:42:07 -03:00
parent b114c7d487
commit 4cd1f4aac0
15 changed files with 81 additions and 22 deletions

View File

@@ -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