Status of PEPs?
Ville Vainio
ville at spammers.com
Fri Jul 2 08:37:30 EDT 2004
>>>>> "Neil" == Neil Benn <benn at cenix-bioscience.com> writes:
Neil> Hmm, respectfully - I disagree with that - I think that
Neil> while(true) is horrible. When reading through code - I expect
Neil> something like :
Neil> while <this statement == true>, keep repeating
Neil> So for while(true), I read :
Neil> while <true == true>, keep repeating
My brain immediately converts 'while 1' to 'loop forever' when it is
seen in code.
Neil> The use of the break statement is non-obvious to me, a flag
Neil> to escape the loop is more typing but avoids the while(true)
Neil> - which IMO compilers for many languages throw warnings
Neil> about. The ideal thing to
If you get a warning, use 'for (;;)'. Some environments (Symbian OS)
define a FOREVER macro, but I don't really see the point.
There are two highly idiomatic ways to use while 1:
while 1:
a = getobject()
if a is None:
break # flag doesn't work, you'd need to do "continue"
process(a)
morestuff(a)
while 1:
dostuff()
done = morestuff()
if done:
break
Neither really benefit from the flag approach. For both cases, it's
obvious that the break applies for 'while 1' condition.
Neil> important point, if these constructs are in common use in a
Neil> language, you basically just have to accept them and move
Neil> on. Life is too short!!
My advise would be that if something deeply bothers you in Python
design, it's better first to explore why you feel that way, and
whether the problem could really be with your own preconceptions and
expectations. For me, that has been the case on several occasions.
And believe me, as a C++ programmer, I don't hesitate to question the
decisions of language designers. After a decent amount of C++
exposure, Python's flaws seem ridiculously small.
--
Ville Vainio http://tinyurl.com/2prnb
More information about the Python-list
mailing list