lua-users home
lua-l archive

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


On 18 July 2018 at 15:20, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> I did not get your point here. Why a user that would forget to properly
> qualify its 'local' would not forget to use 'with'? What are the
> differences between 'local scoped' vs 'with' except the syntax?

it's precisely the syntax.   a 'with' block is always an extra block,
even if it covers the whole loop or function block (it usually
doesn't).  it's very visible, and so hard to miss.   if a novice
programmer sees the `with open('fname') as file: xxxx`  and likes it,
they will probably use it very intentionally.


i do like that feature, but not the syntax.  i too think that scopes
are scopes, don't have to be "special scopes".   still, for things
that might "seem to work until they don't"  (which is common around
resource finalization), explicit and "in your face" syntax has its
advantages.


-- 
Javier