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

Re: T vs. franz



"I can't understand how anyone can defend a defaultly dynamically scoped
Lisp except on the grounds of tradition.  A dynamically scoped lisp
violates referential transparency: i.e. merely by chosing a variable
name unwisely and using it as a free variable you can get screwed if
someone else's function you call temporally binds the variable."

It is possible that you don't understand how dynamic scoping works.
Dynamic scoping does not violate referential transparency. If a function
call another which binds a variable, the callee's actions on its
temporary variable does not affect the value as seen by the caller. Did
you mean something else?

"Big packages written in dynamically scoped lisps tend to consist of
lots of top level functions, and to avoid naming conflicts people tend
to use very long variable names like subprogram-name-do-the-right-thing.
Lexically scoped lisps allow the use of Algol style block structure; you
can hide functions that are used only by one superior function."

The question only has to do with dynamic scoping of VARIABLES: the issue
of the name scope of FUNCTIONS can be separated and is in most commonly
used Lisp dialects.
While function-name scope is an important issue, it is partially
orthogonal to the lexical vs. dynamic scoping debate.

"Another important point is that in lexically scoped lisps the
semantics of the interpreter and the compiler are the same."

One way to avoid the problem in dynamically scoped lisps is to fix the
compiler to preserve the interpreters symantics (all variables are
"special" by default.) (This is done in Interlisp.)
That is to say, it is quite possible to have a dynamicly scoped lisp
where the semantics interpreted and compiled code is the same.

"Elegance" and "cleanliness" may argue for lexical scoping, but these
are terms which do not have objective metrics. (One judges them by
personal appreciation.)

"Referential transparency" and "consistent semantics of interpreted and
compiled code" are better criteria, but lexical scoping does not clearly
dominate dynamic scoping using those criteria.