[Python-Dev] A Hygienic Macro System in Python?

Paul Prescod paul@prescod.net
Tue, 19 Mar 2002 01:05:40 -0800


Greg Ewing wrote:
> 
>...
> 
> I've been trying to think of a Pythonic syntax for passing
> code blocks to procedures. 

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

5.dotimes():
   print "Hello";

(or whatever it is...something like that) 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.

>...
> except that the thunk would have to have write access to
> the namespace it's embedded in, perhaps implemented by
> sharing the stack frame.

If the idea is for it to be a macro feature then yes. But it could be
JUST an anonymous implicit thunk. Isn't that how it is in Ruby or
Smalltalk? How would the procedure know what variable names to expect in
the block?

 Paul Prescod