[Python-Dev] thunks (was: code blocks using 'for' loops and
generators)
Brian Sabbey
sabbey at u.washington.edu
Thu Mar 17 01:41:52 CET 2005
Jim Jewett wrote:
> It may be time to PEP (or re-PEP), if only to clarify what people are
> actually asking for.
I will PEPify this, unless someone does not think I am the correct person
to do so. The PEP is probably a better place to try to address questions
you raise, as well as give the rationale that Josiah Carlson was looking
for.
But, in short:
> Brian Sabbey's example from message
> http://mail.python.org/pipermail/python-dev/2005-March/052202.html
> *seems* reasonably clear, but I don't see how it relates in any way to
> "for" loops or generators, except as one (but not the only) use case.
The original post in this thread was an idea about using 'for' loops and
generators, but that idea has since been replaced with something else.
> (1) Calls for "Ruby blocks" or "thunks" are basically calls for
> placeholders in a function. These placeholders will be filled
> with code from someplace else, but will execute in the function's
> own local namespace.
It wasn't my intention that the thunk would execute in the function's
namespace ("function" here is to mean the function that takes the thunk as
an argument). I was thinking that scope rules for the thunk would mimic
the rules for control flow structures.
-Brian
More information about the Python-Dev
mailing list