Thoughts on PEP315
newsgroups at jhrothjr.com
Tue Sep 23 03:47:05 CEST 2003
"Stephen Horne" <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$.co.uk> wrote in
message news:oalumvopu9afuhno85tbp2erl52rk9hht1 at 4ax.com...
> PEP315 (Enhanced while loop) suggests a syntax as follows...
> while condition:
I've snipped the rest of your lengthy analysis because I think
the problem is much deeper, and is essentially insoluble given
the structure of Python.
The difficulty is that there is no clear and obvious way of
distinguishing subordinate groupings from the main grouping.
Consider the if statement:
If we look at this, without knowing the syntax of the
if statement, it looks like three primary statements.
There is no a priori way of knowing, from the lexical
structure of the language, that elif and else cannot
occur by themselves, but must be preceeded by
a specific statement. You need the additional layer
of the syntactic relationships.
Consider the same structure in Ruby:
The thing that makes all the difference is the "end"
statement which closes the if. The elsif and the else
are clauses within the if statement, and there is no
way of missing that fact even if you don't know the
exact syntax of the if structure.
If we now go back to the loop suggestion,
it becomes rather obvious what needs to be
while condition # note the lack of a colon!
This is at least unambiguous as to what is
I don't, by the way, think that we need this
particular piece of syntactic sugar, regardless
of the syntax we dress it up in.
> Steve Horne
> steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list