[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Multiple toclose on the same value..
- From: Francisco Olarte <folarte@...>
- Date: Sat, 15 Jun 2019 20:33:45 +0200
One question regarding to close, just seeking confirmation ( or
denegation in case I've read the manual wrong ).
<toclose> depends on the variable going out of scope, so if I do
something like this ( I know example is stupid but something similar
may happen in more complex ways ):
do
local original = generate_value_with_toclose_metatmethod()
...
local <toclose> copy1 = original
...
local <toclose> copy2 = original
...
end --
Will __toclose be called twice on the valuewhen reaching end ? ( I
expect it to be )
Same question with
do
local <toclose> o = gvwtcmm()
...
do
local <toclose> c1 = o
...
end
...
end
Will __toclose be called on reaching each end?
( 1st case is weird, but some code generation / value shuffling /
aliasing may lead to something like that, 2nd one may be more common
when reusing code via functions ( i.e., a function which does
something on an open connection closing it at end, a second function
which reads and acts upon some headers and dispatchs to the 1st one )
)
( How many times is called is not a problem to me, AAMOF I normally
dessign my "closeable" classes with an idempotent close() method, and
my plan to use <toclose> is just to alias it as __toclose, I just want
to know if I've interpreted the work manual correctly )
Regards.
Francisco Olarte.