Buster Copley wrote:[color=blue]
> While playing around with my quine I was reminded
> of a situation I have come across before: when
> the exit-condition for a loop needs to be checked
> in the middle of a loop, rather than at the
> beginning (while) or the end (do ... while). It
> always seems to come up when I'm hand-rolling very
> simple parsers. (Doctor, it hurts when I do this ...)
>
> Anyone want to argue for or against any of these
> three alternatives, or suggest something better?
>
> copy (b, i = find (b, e, '%'), out);
> while (i != e) {
> b = f (i);
> copy (b, i = find (b, e, '%'), out);[/color]
Code duplication.
[color=blue]
> #elif defined B
>
> while (true) {
> copy (b, i = find (b, e, '%'), out);
> if (i == e) break;
> b = f (i);[/color]
How I used to do that (if I had to) was to add // NOTE! after the break.
So no one will miss it.
[color=blue]
> goto start;
> while (i != e) {
> b = f (i);
> start: copy (b, i = find (b, e, '%'), out);[/color]
Ahh. I looked at a goto. Now I have to go and confess. :-)
I sort of like that. It reminds me of the Duff's device and this:
http://www.cuj.com/documents/s=8890/cujexp0310dewhurst/
Since I am coming down with a fever (and it is not Saturday night here) I
might have missed important things here.
--
WW aka Attila