Getting in to metaprogramming

Michele Simionato michele.simionato at gmail.com
Wed Nov 26 09:05:54 EST 2008


On Nov 26, 11:55 pm, "Hendrik van Rooyen" <m... at microcorp.co.za>
wrote:
> Then another thing - it strikes me that any problem that can be solved
> by metaprogramming, can be solved by putting similar code into a class
> and instanciating an instance.
>
> Does anybody know if this is true?
>
> If it is, it limits the usefulness of metaprogramming to the creation
> of "stored procedures" for "later execution".
>
> - Hendrik

Many times (probably most times) you can avoid code generation and use
classes or
higher order functions instead. Actually I don't like code generation
techniques
in Python and other languages. I would make an exception for Lisp-like
languages,
however, since there you a pretty powerful macro mechanism that in
some cases can be
better than using higher order functions, especially if performance is
important.
I say something more in the latest episode of my "Adventures of a
Pythonista in Schemeland"
which some of you may find interesting: http://www.artima.com/weblogs/viewpost.jsp?thread=240836


  M. Simionato



More information about the Python-list mailing list