why no "do : until"?
Steve Lamb
grey at despair.rpglink.com
Wed Jan 3 15:35:31 EST 2001
On Wed, 03 Jan 2001 11:24:34 -0700, Bjorn Pettersen <pbjorn at uswest.net> wrote:
>So then you'd also write:
>do {
> something;
>}
>while (condition);
>to be consistent? Seems ugly and inconsistent to me (the else isn't a
>statement, it's part of the if ;-)
I don't write in a language that has a do/while (incidentally I feel that
all loops outside of while are superfulous, but that's just me). Secondly it
isn't statements that are intended, it is blocks. The else denotes the
beginning of a different block. Yes, it is part of the if, but it is the
beginning of the next block. I don't take { on a line of its own and }
doesn't close another }.
In that case Python is actually quite clear.
if something:
do something
else
do something else
Note that the else is on the same intention as the if because it is
starting a different block? Same as:
if (something) {
do something;
}
else {
do something else;
}
The difference there is that one needs the } to close the block. I do not
feel that pushing the else over, effectively intenting it, makes the code
clear.
if (something) {
do something;
} else {
do something else;
}
... translated to "no braces"...
if (something) {
do something;
else
do something else;
Doesn't quite match the Python way of denoting the beginning of the next
block with the else:, does it?
So, to recap. } ends a block, if/else/elsif (perl), etc starts a block,
the closing } lines up with the opening statement, not the opening brace.
Any wonder why I want to switch over to Python for a great many things?
--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
ICQ: 5107343 | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------
More information about the Python-list
mailing list