[Python-Dev] A Hygienic Macro System in Python?
Greg Ewing
greg@cosc.canterbury.ac.nz
Tue, 19 Mar 2002 17:39:40 +1200 (NZST)
Tim Peters <tim.one@comcast.net>:
> Maybe Guido can introduce a canned "withlock" macro just
> for that <ahem>:
>
> withlock lock:
> do stuff
Daniel Mahler <mahler@cyc.com>:
> There are many APIs that lead you to write code with certain fixed
> parts
> ...
> I think the thing worth noting here is that the introduced
> constructs would usually be colon&indent type entities
I've been trying to think of a Pythonic syntax for passing
code blocks to procedures. The best thing I've come up with
so far is something like
lock.do:
something()
which would be (sort of) equivalent to
def thunk():
do_something()
lock.do(thunk)
except that the thunk would have to have write access to
the namespace it's embedded in, perhaps implemented by
sharing the stack frame.
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@cosc.canterbury.ac.nz +--------------------------------------+