[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 (alpha) now available
- From: Patrick Donnelly <batrick@...>
- Date: Thu, 20 Jun 2019 13:58:58 -0700
On Thu, Jun 20, 2019 at 1:51 PM Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> 2) With regards to the 'toclose' variable declaration, introducing a
> 'with' statement is the nicest approach.
>
> with <vars> = <initializers> do
>
> end
>
> This idiom is familiar to most programmers who use Python.
> BTW @Patrick Donnelly this has nothing to do with Python's reasons for it etc.
Quoting myself from the prior thread:
"I want to point out the reasons why Python requires a control
structure but Lua would not: Python's locals are function-scoped.
Declaring a local in Python means it doesn't go out of scope until the
function returns. For this reason, Python requires an explicit control
structure to define the lifetime of the variable. Lua does not have
this limitation."
They absolutely needed another control structure to implement their
flavor of RAII.
--
Patrick Donnelly