PEP 315: Enhanced While Loop

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Tue May 6 18:24:55 EDT 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3EB80F8C.E85CBD1B at alcyone.com...
> The other variants which involve a
>
> KEYWORD condition:
>     statements
>
> where it's just "understood" that the statements will be executed once
> regardless seems like a very bad precedent, since it's quite nonobvious
> that that's the case, and I can't imagine a reasonable keyword used
> there that would flag that behavior in an intuitive way.

I think my biggest problem with the PEP and the modified versions which are
following it on this thread is that the whole idea addressed a very small
set of real-world use cases, and that it would likely set a bad precedent
which could allow a figurative avalanche of flow-control structures that are
begging to be added to the language.

Just to illustrate based on the idea presently before us, we have in the
language already:

while <cond>:
    <statements>

This proposal would add some variation to allow setup code to be executed as
part of the loop, but before the <cond>, which is argued as a convenient way
of handling setup code (I've picked my favorite of the variations):

while <optionalCond>:
    <statements>
and while <cond>:
    <statements>

If we let this in, might we soon see a request to allow a portion of the
loop to execute once after the <cond> tests false for the purpose of
allowing some sort of cleanup to occur that might run a risk of duplicating
code?

And let's not neglect the fact that some other languages have negative logic
versions of their flow-control statements, so if pressure continued long
enough, we might (shudder) see new keywords added to eliminate the need for
a "not".

After typing this, I'm starting to feel that maybe this is just an
unimportant, meaningless tangent.  I sure hope so.

--
Daniel Fackrell (newsgroups.NOSPAM at dfackrell.mailshell.com)
When we attempt the impossible, we can experience true growth.






More information about the Python-list mailing list