>>>> "Karl" == Karl M Hegbloom
<karlheg(a)inetarena.com> writes:
Karl> Notice that it binds a variable called `equal', which is the name of
Karl> a built-in function. `comint-ipc' uses both the value and function
Karl> cell of some symbols... It occurs to me that what can happen is that
Karl> if there is a function that relys on being able to store something in
Karl> the value cell of the symbol it sits in the function cell of, and
Karl> that symbol gets shadowed by being bound from a lambda list, like
Karl> `equal' is here, and then someplace down the call chain it gets
Karl> called on, it won't work right because of the shadowing.
Karl> I believe this is exactly the sort of thing that lexical scoping is
Karl> meant to prevent.
Although dynamic scoping is evil, as you point out, the function cells
and value cells of symbols are basically entirely separate namespaces,
and typically no functions access global variables of the same name
as the symbol that names them. In fact, functions are really nameless
entities that can sit in the function cells of zero or more symbols,
and it is extremely bad style for the behavior of a function to
depend on the symbol that was used to invoke it.
It is common practice in Common Lisp (but not in Scheme!) to use
variables with names like `list':
(let ((list (list (foo) (bar))))
(...))
This particular example is probably bad style because it is too easy
to confuse the two `list's, which live in different namespaces.
Martin