lua-users home
lua-l archive

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


On 25 July 2018 at 17:16, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> As hard as I try, I don't see why 'with foo() as x' is clearer than
> 'local scoped x = foo()'.  Both have a very clear and unique mark
> ('with' vs 'scoped'). Moreover, 'with' has different meanings in
> some other languages, so it can be even more confusing.

I don't think it's clearer or less confusing.  I do think it's more visible.

Being visible has a few advantages on itself, for code reviews it's
more obvious, for beginners (reading code examples) its easier to
realize when it's being used and what is the scope of the variable.

on the other hand, the `scoped` mark is a lot less intrusive, which
has some other advantages, such as:

 -  its easier to add to existing code, simply adding some determinism
without changing the semantics.
 -  variables don't have to be at the top of the scope, so you can add
more "finalizers" without indenting too far from the left margin
 -  carries a lot less baggage, so you don't confuse with other
"withs" from other languages.

if this was a democracy, my vote would go to the `scoped` mark.


-- 
Javier