What's better about Ruby than Python?

A.M. Kuchling amk at amk.ca
Tue Aug 19 08:58:36 EDT 2003


On Mon, 18 Aug 2003 15:17:03 -0700, 
	Erik Max Francis <max at alcyone.com> wrote:
> Roy Smith wrote:
> My view of this is that if you really want to do this, you're better off
> inventing a separate language -- however similar to Python -- and using
> a processor to turn that language into real Python, which can then be
> interpreted.  In an interpreted language, especially one as dynamic as

The problem is that writing such a processor is pretty messy.  I've just
been writing a translator for a supersmall subset of Python ('while', 'for',
assignment, and that's it).  While it was possible to do it with the
Lib/compiler/ package, the code for parsing the subset and generating Python
code from it is 12 screens long, ~300 lines of code.  It's also difficult to
change the keyword set; for now I'm simply disallowing variables named 'in',
for example.

Macros would generally be a compact way of doing this, though that
compactness would have a cost (just like regular expressions are concise 
but not very readable).  Perhaps the solution isn't macros, but some kind of 
Python-like-language parsing toolkit that's more easily customizable 
than the compiler package is.

--amk




More information about the Python-list mailing list