Status of PEPs?
Neil Benn
benn at cenix-bioscience.com
Fri Jul 2 07:01:05 EDT 2004
Ville Vainio wrote:
>>>>>>"Thomas" == Thomas Reichelt <XXNOSPAMXX at gibts.net> writes:
>>>>>>
>>>>>>
>
> >> while 1:
> >> do stuff
> >> if condition:
> >> break
>
> Thomas> Well, in my opinion this kind of defeats the purpose of a
> Thomas> while-loop. The original intention is to test the
> Thomas> condition in the while-statement, and not to set up an
>
>Original intention for whom? You can imagine "while 1:" as an alias
>for "loop:", i.e. an eternal loop.
>
>The distrust of 'while 1' just needs to be unlearned, which is a
>matter of education.
>
> Thomas> infinite loop and break out somewhere. The behavior of
> Thomas> while (1) { } even generates a warning in other
> Thomas> languages...
>
>That's because 1 is not a conditional statement. It needs to be
>spelled out as "while(true)", or "for (;;)" in boolean-challenged old
>c++.
>
>
>
Hello,
Hmm, respectfully - I disagree with that - I think that
while(true) is horrible. When reading through code - I expect something
like :
while <this statement == true>, keep repeating
So for while(true), I read :
while <true == true>, keep repeating
The use of the break statement is non-obvious to me, a flag to
escape the loop is more typing but avoids the while(true) - which IMO
compilers for many languages throw warnings about. The ideal thing to
me would be to declare a flag (if needed) in the definition of the while
statement which would limit the scope to exactly the correct field. I
also agree however that do/while is not needed as flags work equally as
well.
It's a matter of syntactical reading of code and a philosophical
point. I must admit that there are some constructs commonly used in
Python that make me cringe (throwing exceptions as a matter of
convenience when you could detect that situation and not throw the
exception in the first place - for example) - however and this is the
important point, if these constructs are in common use in a language,
you basically just have to accept them and move on. Life is too short!!
Have a good weekend!
Cheer,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : benn at cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com
More information about the Python-list
mailing list