Explanation of macros; Haskell macros

Michael T. Babcock mbabcock at fibrespeed.net
Mon Nov 3 08:54:26 EST 2003


>
>
>The costs: syntax seems to be constrained to have a very regular surface
>structure full of parentheses; the language must describe and implement a
>representation of code as data which would otherwise be unnecessary; every
>compiler must include an interpreter; it's hard to report errors to the
>user showing the code as it's written in the source if the error is found
>after macro expansion.
>

I don't really want to jump into the middle of a discussion here, but if 
someone wanted to do this in Python, one *can* of course write Python 
code that generates Python code and then executes it.  This gives the 
compile-time type macro execution timeframe; build the code you want to 
execute with Python before executing it then execute it.  There's no 
need for an additional macro-like system when your runtime allows you to 
execute your own strings.

I know this is a higher-order discussion on the merits of macro systems 
in other languages and how they'd benefit (or not) Python, but I decided 
to throw my $0.02 (CAN) in.

-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock







More information about the Python-list mailing list