lua-users home
lua-l archive

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


On Mar 9, 2016 7:19 AM, "Roberto Ierusalimschy" <roberto@inf.puc-rio.br> wrote:
>
> > Pascal introduced the construction
> >
> > with tbl do
> > ...
> > end
> >
> > Inside the do block, fields of 'tbl' shadow outer variables.
> >
> > [...]
> >
> > Problem 1: Local variables defined outside the `for` stay visible.
>
> With due respect to Pascal, I think this is a good thing. It is weird
> that something invisible, probably declared somewhere else, takes
> precedence over something visible, declared in the same chunk.
>
> -- Roberto
>

I never thought I'd say this, but I like the way Visual Basic 6 does it:

with foo
    .x = 1
    .y = some_local_var
end with

I don't remember the exact syntax, but the important part is you still included the dot from foo.x, so that distinguished properties from other variables in outer scopes.