LOOP wisdom found (was: do...until wisdom found)...
Ken Peek
Peek at LVCM.comNOSPAM
Wed Apr 18 01:45:15 EDT 2001
OK--
I think the people in this news group have finally broke through my thick
skull... We can build no less than THREE looping constructs with only TWO
keywords.
If we have to make the language simple, then let's make it REALLY simple. I
dislike the keywords "while" and "break"-- here's why:
For a "newbie" (who is just learning to program) either "repeat" or "loop"
conveys more information about what is about to happen. Of these, the universal
meaning of "loop" seems to be more wide spread. (EVERYBODY knows what a "loop"
is, even if they have never programmed before.)
(Make believe a newbie is learning to program computers.) "break"-- well? What
does this mean? "If I type 'break', will it crash the computer?" The keyword
"break" is a "hold-over" from a previous language. I kind of like "leave"
instead of "break". It is more intuitive, and conveys what it is supposed to
do. A close second would be "exit", but that is probably going to be used for
something else.
Now, a loop "in the _nature_ of a while loop" would look like this:
# do the test before the body, just like "while"--
loop:
if condition: leave
# some stuff
# some more stuff
And, a loop "in the _nature_ of a do...until loop" would look like this:
# do the test after the body, just like "do...until"--
loop:
# some stuff
# some more stuff
if condition: leave
And, an infinite loop would look like this:
# never do a test, so we have an "infinite loop"--
loop:
# some stuff
# some more stuff
Of course, in either case, there is nothing to stop you from the bad programming
practice of putting in as many "if condition: leave" statements as you like, in
any place you like. So what? You cannot legislate morality... THIS code is
easy to learn and understand.
I too, have it on good authority that Python 3000 will address the eternal (and
infernal) "looping controversy" <somehow>. As to just what that "somehow" will
be, we will just have to wait and see what Guido will bless. (MY money is on
simplicity!)
--Nih!!!
--KP
"Fredrik Lundh" <fredrik at pythonware.com> wrote in message
news:0c3D6.5161$sk3.1518317 at newsb.telia.net...
< snip >
> in python 3000, expect "while" to be replaced with "loop/if/break" ;-)
< snip >
More information about the Python-list
mailing list