lua-users home
lua-l archive

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


Edgar Toernig <froese@gmx.de> writes:

> I think the confusion is on your side because you make a distinction
> between lexical and static scoping.  It's the same.  If you think
> I'm wrong give a reference to a text that defines the difference.

I got to run, and am taking some time off, but I'll get back to you on
this.  I believe the pointer on lua-user.org fully explains the
concept of lexical scoping.  It's not the opposite of dynamic scoping,
did you notice?

> By your understanding C (or GCC if you require function nesting) is
> not lexically scoped either and a lot of people will disagree.

As I understand C, every nested function it allows has access to all
variables in all enclosing functions in which it exists, therefore, C
is lexically scoped.  C is a boring example of a lexically scoped
language because it meets the nested function test by prohibiting them.

> > Functions can be defined within functions, however, a nested
> > function does not have access to variables defined in any of its
> > enclosing functions.  Therefore, Lua is not lexically scoped.

> You are focused very much on function nesting.  There are more kind
> of nesting constructs in Lua (for-do-end, while-end, do-end, ...).
> Just because some scope accesses are forbidden/unsupported does not
> mean that it's not lexically scoped.  What if i.e. Pascal had a
> "private" keyword for locals which prohibits access from other
> functions.  Would this make Pascal no longer lexically scoped?

The point to focus on is that if a language fails the nested function
test, it's not lexically scoped.  There is no need to consider other
issues.

So long.

John