Metasyntax/Macros

Paddy McCarthy paddy3118 at netscape.net
Wed May 14 04:03:40 EDT 2003


I went googling for messages on Python and adding a macro facility,
but ended up with just too many hits and got lost.

The reason I was looking was that I can get envisage an application
but seemed to remember that the addition of macros to Python got shot
down before but could not remember the reasons.

How I think it would be used? - In Electronics people write simulation
models 'programs' in several domain specific languages - VHDL, Verilog
etc. When they need to Verify these models they find that they gain
from using a higher level programming language, and often augment
their test suite with scripting languages like Perl as well as domain
specific languages such as Specman and Vera. If Python was that higher
level language then i thought that a macro facility would allow some
of the domain specific languages syntax to be re-used , People could
write

 module my_mod (x,y,z) ...

and create a Python class. By choosing a careful set of macros the
resultant {ython-with-macros source could be understandable to people
with only the domain specific language knowledge,

If their is one-to-one 'mapping' between the macro and the non-macro
Python it represents, then maybe the interpreter could, when given the
macro definitions and some code, spit out a version where the macros
are substituted wherever possible; or another version where all macros
are expanded to their core-python statements & expressions.

I guess I'm interested in two types of opinions
 1) What do you think - disregarding implimentation issues
 2) What do you think as a whole


yet another thought experiment from me - 

Cheers, Paddy.




More information about the Python-list mailing list