[Python-Dev] A Hygienic Macro System in Python?
James_Althoff@i2.com
James_Althoff@i2.com
Wed, 20 Mar 2002 17:47:15 -0800
Or ...
invoke callable():
statement1
statement2
. . .
statementn
is syntax for:
def temp():
statement1
statement2
. . .
statementn
callable(temp)
del temp
More generally,
invoke expr-that-results-in-a-callable(a,b,c) lambda x,y,z:
statement1
statement2
. . .
statementn
is syntax for:
def temp(x,y,z):
statement1
statement2
. . .
statementn
expr-that-results-in-a-callable(temp,a,b,c)
del temp
examples:
invoke aquireLockAndDo():
sensitiveStuff()
invoke withConnectionDo():
generateReport()
invoke gui.showBusyCursorDuring():
doQuery()
invoke gui.showStatusDuring(msg="Searching..."):
doQuery()
invoke gui.showBusyCursorDuring():
invoke gui.showStatusDuring(msg="Generating Report..."):
invoke withConnectionDo():
generateReport()
invoke button.setEventHandler() lambda event:
print event
Freely substitute any preferred keyword: "call", "run", etc. instead of
"invoke".
call aquireLockAndDo():
sensitiveStuff()
run aquireLockAndDo():
sensitiveStuff()
etc.
Doesn't handle return values, but ...
Jim