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

J Kenneth King james at agentultra.com
Thu Jan 8 16:25:56 CET 2009


Jonathan Gardner <jgardner at jonathangardner.net> writes:

> On Jan 7, 9:16 am, "Chris Mellon" <arka... at gmail.com> wrote:
>>
>> The OP wants a Ruby-style DSL by which he means "something that lets
>> me write words instead of expressions". The ruby syntax is amenable to
>> this, python (and lisp, for that matter) syntax is not and you can't
>> implement that style of internal DSL in those languages.
>>
>> The answer to the OP is "you can't - use Ruby or modify your requirements".
>>
>
> As far as putting the code into Python, yeah, you can't put it in
> Python. The best you can do is store it in a string and then interpret
> the string with some function later on.

That's what I'm saying.

It seems we're defining "DSL" in two different ways.

You can't write a DSL in Python because you can't change the syntax and
you don't have macros.

You can write a compiler in Python that will compile your "DSL."

As another poster mentioned, eventually PyPy will be done and then
you'll get more of an "in-Python" DSL.



More information about the Python-list mailing list