Python's Lisp heritage
Ian Bicking
ianb at colorstudy.com
Mon Jul 15 17:09:43 EDT 2002
On Mon, 2002-07-15 at 15:35, Christopher Browne wrote:
> If a new Emacs mode requires adding in a bunch of additional
> parameters, dynamic scope lets them be visible throughout the scope
> during which they are "live" as opposed to just within the environment
> in which they were defined.
[snip]
> If all you have is lexical scoping, parameters have to get explicitly
> passed down the chain in order to get from function A to function C.
> That means introducing additional parameters to function B, which
> didn't actually care about those extra values.
Interesting argument. I think that you can achieve similar results with
big state-holding objects (for better or worse). With a web framework,
that might be the request object. Or in an editor in might be a buffer
object. If you have an object that persists for about the same scope as
you need this extended information, you just set an attribute on that
new object (or use a mix-in or some other technique). Then, in your
extensible application, this object gets passed around (perhaps
indirectly) to most functions and methods that would be extensible.
This does kind of defeat lexical scoping, though it avoids use of
globals. While function signatures don't change, it's at the sacrifice
of object interfaces. OTOH, it seems to work okay.
--
Ian Bicking Colorstudy Web Development
ianb at colorstudy.com http://www.colorstudy.com
4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241
More information about the Python-list
mailing list