python and macros (again) [Was: python3: 'where' keyword]

Paul Rubin http
Tue Jan 11 16:07:01 EST 2005


michele.simionato at gmail.com writes:
> 2. One could proposed hygienic pattern-matching macros in Python,
> similar to
> Scheme syntax-rules macros. Again, it is not obvious how to
> implement pattern-matching in Python in a non-butt-ugly way. Plus,
> I feel hygienic macros quite limited and not worth the effort.

It wasn't obvious how to do it in Scheme either.  There was quite
a bit of head scratching and experimental implementation before
there was consensus.

> 3. We would add to Python the learning curve of macros and their
> subtilities and we do not want it.

I can't imagine how it could be worse than the learning curve of
__metaclass__, which we already have.  If it was done in a way that
most of us would just rely on a few standard ones, that would be fine.

> 4. Macros would complicate a lot Python module system.

I don't see how, but maybe I'm missing something.

> 5. We have Guido providing a good syntax for us all, why we should be
> fiddling with it? More seriously, if some verbosity is recognized
> in the language (think to the "raison d'etre" of decorators, for
> instance) I very much prefer to wait for Guido to take care of
> that, once and for all, than having 100 different custom made
> solutions based on macros.

Every time some newbie asks an innocent "how do I ..." question, we
see unbelievably horrid answers from gurus.  Just check the FAQ about
conditional expressions, etc.  I just don't see Python syntax changes
as forthcoming.

> What I would be interested in is a Lisp/Scheme implementation
> compiling to Python bytecode, but I am not aware of any project
> in that direction.

But that sounds like a bizarre idea.  Python bytecode is just a
CPython artifact, not part of the language.  And it's not even that
good an artifact.  Good Lisp/Scheme implementations compile to native
code that beats the pants off of CPython bytecode.  It would make much
more sense to have a Python implementation that compiles Python to
S-expressions and then lets a high performance Lisp or Scheme system
take care of the rest.



More information about the Python-list mailing list