lua-users home
lua-l archive

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

> On Wed, Jul 18, 2018 at 11:55 PM, Roberto Ierusalimschy <
>> wrote:
> > It is not by chance that Lua avoids too many syntactical constructs.
> > They are hard to be represented in the C API.
> >
> If "with" is syntax sugar on top of scoped vars then a representation in
> the C API isn't needed.
> The benefits of "with" syntax are related to readability:  1) it's clear by
> code structure that a resource is open, and 2) named variables can be
> elided in many cases, e.g.:

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.

'with foo()' might be slightly better than 'local scoped _ = foo()',
but I don't think it is worth creating a new construct (plus a new
reserved word) just to avoid the '_'.

As I already explained, the more you insist on 'with', the less I like
the general idea. If 'with' is really superior to 'local scoped', there
is something I am not understanding correctly about the whole stuff. I
will not try to solve a problem I am not understanding.

-- Roberto