lua-users home
lua-l archive

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

On Fri, Jul 27, 2018 at 3:14 AM, Roberto Ierusalimschy <> wrote:
Does Python's 'with' handle this is some different way?

When wrapping a resource within an object, isn't the first order of business to implement a proper __gc finalizer?  Then if someone forgets to explicitly close it, or forgets to put the "scoped" qualifier on var, or there's an out of memory exception when creating the scoped var, it will eventually be cleaned up by garbage collection.  Specifically for the out-of-memory scenario, it's rare enough that this should suffice rather than having every use of scoped var do a paranoid dance.

It would be the same in Lua or Python.