[Python-ideas] And now for something completely different
talin at acm.org
Thu Sep 18 07:09:58 CEST 2008
Cliff Wells wrote:
> I was reading the documentation for Io ( http://www.iolanguage.com ),
> particulary about how Io implements control structures: in short, it
> doesn't. What it's able to do is let the user define control structures
> in Io itself. For example "if" and "for" are merely functions:
> for ( i, 1, 10, i println )
> if ( b == 0, c + 1, d )
There's a fundamental problem which is fatal to this idea and others
like it (which resulted in the death of many of my own suggestions over
The problem is that Python can't support "programmable syntax".
Think about the mechanics of import. Unlike C++ or Java, the "import"
statement doesn't actually do anything until the program is actually
run. The compiler never sees the contents of the imported module.
This means that any syntax-changing directives would have to be manually
copied into each and every Python source file that used them. (In a
sense, this is exactly how import future works.) There's no means to
have a standard library of syntax-changing directives.
More information about the Python-ideas