macro FAQ

Jacek Generowicz jacek.generowicz at cern.ch
Sun Aug 24 05:44:21 EDT 2003


mis6 at pitt.edu (Michele Simionato) writes:

> > Can this be implemented using metaclasses, or any other existing
> > Python mechanism ?
> 
> Yes.
> 
> http://groups.google.it/groups?hl=it&lr=&ie=UTF-8&threadm=2259b0e2.0306040808.1d737a54%40posting.google.com&rnum=2&prev=/groups%3Fhl%3Dit%26lr%3D%26ie%3DISO-8859-1%26q%3Dsimionato%2Bmacros%26meta%3Dgroup%253Dcomp.lang.python.*

Unfortunately I can't easily access this at the moment. I'll try to
have a look later.

> At the end it uses metaclasses+exec+a simple argument parser based on 
> tokenize. EXPERIMENTAL code, which I would not trust except as proof
> of concept.

If it uses exec, then it is faking up macros.

Lisp macros are little else besides offering language support for the
use of exec for this kind of thing.

If people start resorting to this sort of trick themselves, and
re-inventing it over and over again, then you might as well design it
properly, once and for all, and call it a macro system.

I submit that Python already has macros ... they just need a bit of
streamlining :-)




More information about the Python-list mailing list