lua-users home
lua-l archive

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


>>>>> "Roberto" == Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:

 >> The ability to use a function as a toclose value previously existed,
 >> but was removed - I guess (from the timing) as a result of a
 >> discussion I had on the list about how a restricted environment
 >> needs control over what happens in error handling.
 >> 
 >> As it stands, if an environment doesn't expose setmetatable() to the
 >> lua code, then it can ensure that the lua code can't get control
 >> over error handling other than with pcall, which the environment can
 >> intercept.

 Roberto> Right. And there is one more reason:

 Roberto> * Functions interact badly with coroutines. If a coroutine
 Roberto> yields and is never resumed again, its to-be-closed functions
 Roberto> will never run. To-be-closed objects, on the other hand, will
 Roberto> still be closed, provided they have appropriate finalizers.
    
Incidentally, in my case, hiding setmetatable() from the application
would be highly undesirable, so I'm looking into whether it's possible
to prevent the code from creating a __close method by wrapping
setmetatable() and rawset().

-- 
Andrew.