Movatterモバイル変換


[0]ホーム

URL:


do...until wisdom found...

Alex Martellialeaxit at yahoo.com
Tue Apr 17 15:16:47 EDT 2001


"Dennis Baker" <drbaker at softhome.net> wrote in messagenews:mailman.987527904.6377.python-list at python.org...> On Tue, 17 Apr 2001 09:28:15 -0700 Bob Cannard <bob_cannard at mentor.com>wrote:>> ) Has no one else found that the majority of while-type> ) loops actually need some code before the test and some> ) after?Yes.  Donald Knuth, one of the truly greats of programming,pointed this out in the mid-'70s in an article in ComputingSurveys (ACM) with a provocative title -- "Structured programmingwith GOTO statements".  His "N and 1/2 times loop" classicconstruct is exacly the one you, Bob, identified.> ) Doubly so in Python where it seems impossible> ) to embed a local side effect in the while condition.> ) As a result, most non-for loops degenerate into> )> )         while 1:> )             set up for this cycle> )             if c: break> )             whatever needs to be doneKnuthian syntax might be more like:    loop:        set up for this cycle    while not c:        whatever needs to be doneand I do think it would be superior sugar.  The semanticsare identical to the above snippet, anyway.> That's a product of poor design.  I consider it a failure to resort tothis sortUh, Dennis, have you READ Knuth's classic article?  Findingreprints of the mid-70's original issue of "Computing Surveys"may be hard, but it IS one of the articles that define thehistory of programming, so it's been widely reprinted, forex in his "Literate Programming" book, an interesting oneto read anyway.  Please come back with your critique AFTERyou are aware of the Master's arguments...Alex


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp