[u-u] wow, post-tested loops in sh
John Sellens
jsellens at syonex.com
Mon Jul 4 15:31:33 EDT 2016
On Mon, 2016/07/04 03:13:51PM -0400, Alan J Rosenthal <flaps at 56789.ca> wrote:
| >I trust you know about "break" of course?
|
| Well, yes. And I have to admit it's hard for me to argue as to why that
| doesn't constitute a post-tested loop. But to me it doesn't.
And I'll agree with you!
While technically it's very similar, it *looks* different.
When we see
do {
} while ( condition );
we know what that means.
When we see
while ( true ) {
}
it's a different animal. Even if the last thing in the loop is
if ( condition ) break;
We get used to certain idioms, and recognize them. And when things
don't fit the typical idioms, we have to work harder.
Which is of course why you said you wouldn't use your original example
in real code - because it's a confusing and unusual idiom.
My favourite example is one of the first perl programs I ever looked at,
years ago, which was someone's first perl program. Two adjacent lines:
$DEBUG && print "debug info\n";
print "more debug info\n" if ( $DEBUG );
At which point I concluded that perl was broken by (lack of) design.
Cheers!
John
More information about the u-u
mailing list