lua-users home
lua-l archive

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


On Fri, Mar 31, 2017 at 6:14 PM, Gé Weijers <ge@weijers.org> wrote:
> On Fri, Mar 31, 2017 at 12:24 PM, William Ahern <william@25thandclement.com>
> wrote:
>>
>>
>> Either Roberto or Luiz once proposed a construct that automatically
>> invoked
>> a __close metamethod on an object upon exiting a block. IIRC, it would be
>> invoked even if scope exit occured because an error was thrown.
>>
>> I thought that was a cool idea. It's similar to the using, with, and defer
>> statements of other languages.
>
>
> It sometimes looks like this list is trying to reinvent Scheme one feature
> at a time. None of the above languages
> have coroutines (or it's Scheme cousin: call-with-current-continuation), and
> 'exit means exit'.
>
> Not so with coroutines, yield exits a block, but it may or may not return.
> If you're holding a lock using an RAII-style
> userdata you may be in trouble, either because after a resume you run your
> code without owning the lock, or the coroutine
> never gets resumed, and the lock is held way too long.

Uh, you'd be in trouble with coroutine yields regardless of the lock
management mechanism (RAII or just manual lock/unlock).

BTW, I find it unnecessarily passive aggressive to assert Lua et al.
are "reinventing" Scheme. It is the very nature of all (spoken and
artifical) languages to borrow (or steal) from each other. I don't go
out of my way to cite French whenever I pass out my resume (or spell
it to their standards for that matter).

-- 
Patrick Donnelly