lua-users home
lua-l archive

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


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