[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: New scoping rule for "repeat" and "continue" patch
- From: Glenn Maynard <glenn@...>
- Date: Wed, 28 Sep 2005 23:31:29 -0400
On Wed, Sep 28, 2005 at 09:41:17PM -0500, Rici Lake wrote:
> Indeed, leading to anti-self-documenting code. I've seen the same thing
> in
> C, occasionally preceded with a comment like "this 'do' is only to
> allow the
> use of 'break´". I've always thought that it would be better to use a
> goto
> in such cases, since (may I not be smitten by Djikstra's ghost) a
> 'goto' with
> a well-chosen label is easier to understand than a misused iteration
> construct.
This practice is very clear to me, and seems just as self-documenting as
an equivalent goto; I consider this construct obvious enough to not need
a comment.
The main problem I have with goto is that it's poorly scoped: there's no
way of knowing, reading a label, how flow arrives there; I have to scour
the function. It's immediately clear to me, however, that the only ordinary
way to reach a while(0) is from within the block; there's no chance that
something before or after might also (intentionally or not) go there.
This is a measurable advantage in clarity to me.
By the way, not wrapping the last word or two of lines would make your
mails somewhat more, er, self-documenting. :)
--
Glenn Maynard