nested scopes
Michael Hudson
mwh21 at cam.ac.uk
Tue Feb 6 13:43:28 EST 2001
Darren New <dnew at san.rr.com> writes:
> D-Man wrote:
> > Do you know of any situations where it would be advantageous to have
> > dynamic scoping instead of static scoping? (Note that I'm not asking
> > for situations where dynamic scoping exists, but where it would be
> > better)
>
> My understanding is that it was more an artifact of the implementation of
> LISP than it was a desirous effect. It might be better if you're trying to
> form closures or do funky macro stuff or something, but I'm not sure.
It's good when you're calling a function (call it A) that calls
another function (call this one B) that has parameterizable behaviour,
because A doesn't have to put all of B's parameters in its argument
list - you get B to read these paramters from special (ie. dynamically
scoped) variables and bind them around your call to A. Can't think of
a real good example now, I'm afraid. The Common Lisp printer uses
special variables extensively.
I'm not sure this could be made to work in Python, not least because
it has a rather different notion of binding to Python.
Cheers,
M.
--
Roll on a game of competetive offence-taking.
-- Dan Sheppard, ucam.chat
More information about the Python-list
mailing list