[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: (not) handling new programming idioms with grace
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 26 Jul 2018 16:14:52 -0300
> > if we create the resource and then
> > the variable allocation fails, the resource won't be closed.
>
> If the Lua core must take care against this out of memory situation, it
> follows that any library using scoped vars must take equal care.
>
> But this seems like a tall order in general. You mean there must be no
> malloc from the time a resource is created and its corresponding Lua object
> is assigned to a scoped var. Does Lua (or LuaJIT) even define when the
> core or stdlib might allocate memory? For example, iterators can be
> complicated and it seems likely the resource object could get wrapped in a
> closure, etc. before reaching the scoped var. And what if the iterator
> contains multiple resources-- is it possible to ensure either both or none
> are allocated, and cleanup ownership is properly transferred from the
> iterator constructor to the for loop?
Does Python's 'with' handle this is some different way?
-- Roberto
- References:
- Re: (not) handling new programming idioms with grace, John Belmonte
- Re: (not) handling new programming idioms with grace, Roberto Ierusalimschy
- Re: (not) handling new programming idioms with grace, Patrick Donnelly
- Re: (not) handling new programming idioms with grace, John Belmonte
- Re: (not) handling new programming idioms with grace, John Belmonte
- Re: (not) handling new programming idioms with grace, Patrick Donnelly
- Re: (not) handling new programming idioms with grace, Roberto Ierusalimschy
- Re: (not) handling new programming idioms with grace, John Belmonte
- Re: (not) handling new programming idioms with grace, Roberto Ierusalimschy
- Re: (not) handling new programming idioms with grace, John Belmonte