Python as natural language (was Re: ANNOUNCE: 'goto' for Python

Ville Vainio ville at spammers.com
Thu Apr 1 09:33:20 EST 2004


>>>>> "Richie" == Richie Hindle <richie at entrian.com> writes:

    Richie> Entrian Solutions is pleased to announce version 1.0 of
    Richie> the 'goto' module.

    Richie> This adds the 'goto' and 'comefrom' keywords to Python
    Richie> 2.3, adding flexibility to Python's control flow
    Richie> mechanisms and allowing Python programmers to use many
    Richie> common control flow idioms that were previously denied to
    Richie> them.

I like it! I especially like the way comefrom maps to how we
speak. You know, "come here when you are done with the first
file". Programming is hard for the beginners because there really is
no direct mapping of many everyday speech idioms, and comefrom goes a
long way to redeem this for Python. 

There is still a long way to go, though. I have some problems telling
nouns apart from verbs. Python could innovate here by prefixing all
the function names with !. This ought to make the parser faster also,
considering that Python startup time has gone up in recent versions.

Another gripe of mine is the if-statement. Often what is done is more
important than the condition that determines what we are to do in the
first place, esp. in situations where the condition is of the form "if
the previous command succeeded". This could be easily redeemed by a
postfix-if statement:


err = foo()
    dostuff()
    domorestuff()
:if not err

This seems pretty elegant, considering that exceptions are a hackish
and unnatural way to solve this problem. Python parser would cope with
this just fine.

-- 
Ville Vainio   http://tinyurl.com/2prnb



More information about the Python-list mailing list