Concrete Proposal: while ... and while ...
Phil Hunt
philh at vision25.demon.co.uk
Wed May 26 09:38:25 EDT 1999
In article <374AD624.AB93C9CB at infercor.no>
paulb at infercor.no "Paul Boddie" writes:
> Whilst I don't lie awake at nights worrying about all the "while 1"s out there
> up to no good, it would be nice to provide a better way of expressing loops with> the continuation/termination condition not being at the start. Since "do" is
> considered off-limits, we could consider other keywords:
>
> while: # No getting away from this, sadly.
> first_part
> break if test2 # Imaginative use of existing keywords.
> # No second block, however. It could confuse.
There is already a syntax for `if' and `break' that does this, ie:
if test2: break
So what you are suggesting could be generalized, so that all
statements for the form:
if test: do_something
can be rewritten as:
do_something if test
This is useful, because it offers the programmer different ways to do
things -- different programmers prefer different ways of doing things,
so this way they'll all get what they want.
In fact, there already exists a language designed on these principles.
It is called Perl. (Some people have even gone as far to suggest that
Perl should replace Python as a general-purpose scripting language
because of its superior and easier-to-understand syntax). So I suggest
that Python 2.0 should include the entire syntax of Perl, as well as
the ``and while test:'' and ``break if test'' constructs.
--
Phil Hunt....philh at vision25.demon.co.uk
More information about the Python-list
mailing list