[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: (not) handling new programming idioms with grace
- From: Daurnimator <quae@...>
- Date: Tue, 17 Jul 2018 13:33:38 +1000
On 16 July 2018 at 22:21, Pierre Chapuis <firstname.lastname@example.org> wrote:
> On Mon, Jul 16, 2018, at 03:17, Daurnimator wrote:
>> What doesn't nicely translate to lua is what to do in the `yield` case:
>> local function foo()
>> with bar do
>> coroutine.yield(baz) -- maybe baz contains something based on `bar`
>> local f = coroutine.wrap(foo)
>> if xyz then -- only *maybe* does the coroutine get resumed
> I was unsure how that was dealt with in Python. This code:
> class Foo(object):
> def __init__(self):
> def __enter__(self):
> return self
> def __exit__(self, *args):
> foo = Foo()
> def my_gen_f():
> while True:
> with foo:
> yield True
> def f():
> my_gen = my_gen_f()
> This is unrelated to the GC, disabling it does not change the output.
Looks like PEP-0533 mostly fixes the issue in python.
suggests that the GC is still involved.
I'm wondering if `with` in lua could just have more methods than
:open() and :close().
e.g. :yield() and :resume() if a `with` block is yielded past.