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

Re: what is the problem?



>>>>> "PG" == Paul Graham <paulgraham@yahoo.com> writes:

  PG> Perl has been getting Lispier, but it started further away from
  PG> Lisp than Python and Ruby.  As a first approximation, Python
  PG> seems to be an inadvertant reinvention of a 1970s
  PG> dynamically-scoped Lisp (except for s-expressions and thus
  PG> macros).  It seems as if these ideas came to Python indirectly
  PG> via Modula-3, which was based in part on Lisp.

Python wasn't dynamically scoped.  It didn't support nested scopes at
all.  Every function regardless of whether it was nested inside
another function had access to two namespaces -- the local namespace
and the global/builtin namespace.  The determination of the global
namespace is static; it's the globals where the function was defined.

I believe these odd scoping rules are the result of some bad
experiences with Pascal, where nesting functions was one of the few
structuring techniques for large programs.  So several people were
familiar with large Pascal programs that were very hard to understand
because they used many nested functions.  Python, then, wanted to
discourage this style of programming.

Jeremy