[Python-Dev] A Hygienic Macro System in Python? (original) (raw)

Greg Ewing greg@cosc.canterbury.ac.nz
Wed, 20 Mar 2002 12:12:29 +1200 (NZST)


Paul Prescod <paul@prescod.net>:

Mixed feelings on that...not a big fan of the Ruby indiom:

5.dotimes(): print "Hello";

My proposal has the (possibly minor) advantage over the Ruby syntax that it doesn't have the (), so that it more closely resembles the syntax of built-in control structures, and doesn't look so much like you're making a call with one less parameter than you really are. (Unfortunately, in the process, it manages to obscure that you're making a call at all. :-[)

If you don't like the look of the dot-notation in that position, the lock example could be done using a procedure instead of a method of the lock object:

withlock mylock: do_something()

def withlock(lock, body): lock.acquire() try: body() finally: lock.release()

I sort of like the fact that Python figures out what control flow features people need (e.g. foreach and simple generators) and just implements.

Yes, but the feature we're talking about is designed for those cases where you badly need a control structure that Guido hasn't thought of yet.

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 +--------------------------------------+