looking for tips on how to implement "ruby-style" Domain Specific Language in Python

Kay Schluehr kay.schluehr at gmx.net
Wed Jan 7 12:11:29 EST 2009


On 7 Jan., 16:50, J Kenneth King <ja... at agentultra.com> wrote:

> Python expressions are not
> data types either and hence no macros -- I can't write a python function
> that generates python code at compile time.

Have you ever considered there are languages providing macros other
than Lisp? Macros have nothing to do with homoiconcity.

> I can only write a python
> program that parses some other string and generates code that can be run
> by another interpreter.

No, it is the same interpreter and it is also possible to modify
python parsers on the fly. This is just not possible with Pythons
builtin parser.


>
> Consider:
>
> for i in range(0, 100):
>     do_something_interesting(i)
>
> That's a pretty straight forward Python expression, but I can't do
> anything with it -- it's not a unit of data, it's a string.
>
> The distinction is not subtle by any means.




More information about the Python-list mailing list