Python Macros
Michael Sparks
zathras at thwackety.com
Mon Oct 4 13:26:05 EDT 2004
Arich Chanachai wrote:
> How hard/easy is it to extend the Python syntax?
It's not that hard to do, but involves changing the compiler and if done
properly a whole slew of other things. If you want non-functional syntax
changes it's fairly trivial - just change the Grammar file and rebuild.
If you want a checklist of things you might want to look at when changing
the syntax you could look at this patch : http://www.python.org/sf/1013835
It's worth noting that this would probably result in a local overhead for
yourself in maintaining a private branch of python however - since this
changes your python in a fairly fundamental manner. I don't know what your
use case is though - if it's experimentation then I suspect that you'd be
happy with that :)
> Perhaps there are macro facilities for this?
Not that I'm aware of. (At least not as far as I know in the lisp or C
meanings of the term)
> I'd like to add messages and message passing, for example.
Why do you feel you need to extend the language for this? Why not (for
example) overload <<, >> and similar operators? __lshift__, __rshift__ etc.
I'd really recommend not extending the language unless you really don't have
any option - unless that's what you're specifically interested in :)
Regards,
Michael.
More information about the Python-list
mailing list