Applying a function recursively
Roy Smith
roy at panix.com
Sat Sep 10 10:12:32 EDT 2011
In article
<4ee53496-ebec-4ee5-be0c-de344ac586c8 at y39g2000prd.googlegroups.com>,
hetchkay <hetchkay at gmail.com> wrote:
[complicated description elided]
> You could consider this to be some sort of DSL. However, because of
> the number of rules involved, I am trying to be as close to Python
> expressions as possible. If the target setting is to be a tuple, for
> example, I want to be able to write the tuple directly as "( expr1,
> expr2 )", rather than, say, "Tuple(expr1, expr2)".
> There is also a requirement to validate the mapping on load so that
> run-time errors are minimized.
I assume by DSL you mean Domain Specific Language? Having worked with a
number of DSLs, my emphatic recommendation is DON'T DO IT!
What you will end up with is a language which is almost, but not quite,
like some other existing language. That means the people who use it
will need to learn something new. If you make it "as close to Python as
possible", all that will happen is people will assume it's Python, and
constantly be surprised when things don't work the same way.
Whatever features of "real Python" you left out, people will invariably
be clamoring for. Eventually, you will be forced to duct-tape them into
the language. You will end up bogged down forever in language
maintenance, adding features, fixing bugs, writing documentation,
providing tech support, etc.
Think of all the ecosystem stuff which grows up around a real language.
Debuggers. Profilers. Language-aware editors (or plugins to emacs,
eclipse, etc). Add-in libraries to do a zillion things you never
thought you would want to do. Hoards of really smart and enthusiastic
people on mailing lists, newsgroups, Stack Overflow, etc willing to help
out with problems. Books. Professional training courses. You will end
up with replicating all that, or doing without.
It sounds like what you really want to do is just use Python as your
scripting language. The lazy evaluation features you desire can be
handled by writing some library code.
More information about the Python-list
mailing list