From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: stopping a loop iteration without exiting it
Date: Fri, 5 Jan 2018 15:05:13 +0100
Date: 2018-01-05T15:05:13+01:00 [thread overview]
Message-ID: <p2o0mp$brp$1@dont-email.me> (raw)
In-Reply-To: <p2mjo2$jn6$1@franka.jacob-sparre.dk>
On 01/05/2018 02:17 AM, Randy Brukardt wrote:
>
> There are a number of instances of it in the spam filter. When it is
> determined that a particular pattern cannot possibly match, one does a
> "continue" to move on to the next pattern. This is usually in an inner loop
> (so this is acting as a combination exit and continue). The rules for the
> spam filter turn out to be very complex, so the code implementing them also
> end up complex; simplifying the rules leads to allowing spam through or
> blocking "ham" (good mail).
and also (in another post):
> It's not a frequent need, it's just a non-zero need. I find I end up up
> writing such a goto (very roughly) once a year. But a good number of them
> aren't strict continues; there's often something at the bottom of the loop
> after the label.
I don't know of any language that has a "continue" that will apply to any but
the innermost containing loop, so such languages would not seem to have any
advantage in this case anyway. I suppose Ada could be the 1st with such a feature.
I don't know of any language with a "continue-like" feature that includes
executing some code at the end of the continued loop. I can't imagine what such
a feature might even look like.
But it appears that even if Ada had a "continue" feature, it might not replace
the goto of many of your real-world examples.
I've never written a spam filter, but I'd imagine that one would be structured
something like
All_Msgs : loop
exit All_Msgs when Msg_Source.Is_Empty;
Msg := Msg_Source.Get;
Is_Spam := False;
All_Patterns : for Pattern of Patterns loop
Is_Spam := Pattern.Check (Msg);
if Is_Spam then
Reject (Message => Msg);
exit All_Patterns;
end if;
end loop All_Patterns;
if not Is_Spam then
Allow (Message => Msg);
end if;
end loop All_Msgs;
and moving on to the next pattern would be "return False;" in Check. Reality is
probably more complex than this.
--
Jeff Carter
"Brave Sir Robin ran away."
Monty Python and the Holy Grail
59
next prev parent reply other threads:[~2018-01-05 14:05 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 16:54 stopping a loop iteration without exiting it Mehdi Saada
2018-01-03 17:23 ` Lucretia
2018-01-03 21:19 ` Randy Brukardt
2018-01-03 23:17 ` Robert A Duff
2018-01-04 8:47 ` Niklas Holsti
2018-01-05 1:31 ` Randy Brukardt
2018-01-04 10:08 ` Jeffrey R. Carter
2018-01-04 11:02 ` Dmitry A. Kazakov
2018-01-04 19:46 ` Robert A Duff
2018-01-04 20:47 ` Mehdi Saada
2018-01-04 21:17 ` Dmitry A. Kazakov
2018-01-04 23:08 ` Niklas Holsti
2018-01-05 8:38 ` Dmitry A. Kazakov
2018-01-06 16:50 ` Niklas Holsti
2018-01-06 17:20 ` Dmitry A. Kazakov
2018-01-07 11:36 ` Niklas Holsti
2018-01-07 12:05 ` Dmitry A. Kazakov
2018-01-07 21:22 ` Niklas Holsti
2018-01-08 8:35 ` Dmitry A. Kazakov
2018-01-08 20:57 ` Randy Brukardt
2018-01-08 21:19 ` Dmitry A. Kazakov
2018-01-08 21:48 ` Submitting requests to the ARG, was: " Simon Clubley
2018-01-09 9:45 ` Dmitry A. Kazakov
2018-01-08 22:35 ` Jeffrey R. Carter
2018-01-05 16:34 ` Robert A Duff
2018-01-05 19:09 ` G. B.
2018-01-07 11:52 ` Niklas Holsti
2018-01-07 12:27 ` Dmitry A. Kazakov
2018-01-06 0:53 ` Keith Thompson
2018-01-06 8:36 ` Dmitry A. Kazakov
2018-01-06 8:49 ` gautier_niouzes
2018-01-06 9:26 ` Dmitry A. Kazakov
2018-01-08 11:05 ` mockturtle
2018-01-09 11:05 ` AdaMagica
2018-01-09 11:26 ` Dmitry A. Kazakov
2018-01-09 12:50 ` Simon Wright
2018-01-09 13:07 ` Dmitry A. Kazakov
2018-01-09 13:47 ` Dennis Lee Bieber
2018-01-09 14:53 ` Dmitry A. Kazakov
2018-01-09 20:07 ` G. B.
2018-01-10 8:13 ` Dmitry A. Kazakov
2018-01-10 21:14 ` G. B.
2018-01-11 12:48 ` AdaMagica
2018-01-11 20:54 ` G. B.
2018-01-11 13:06 ` Dmitry A. Kazakov
2018-01-11 17:11 ` Simon Wright
2018-01-11 17:30 ` Dmitry A. Kazakov
2018-01-11 18:09 ` Simon Wright
2018-01-11 20:54 ` G. B.
2018-01-12 8:20 ` Dmitry A. Kazakov
2018-01-12 9:22 ` G. B.
2018-01-12 9:42 ` Dmitry A. Kazakov
2018-01-10 10:52 ` AdaMagica
2018-01-10 11:14 ` Dmitry A. Kazakov
2018-01-10 11:21 ` AdaMagica
2018-01-10 13:47 ` Dmitry A. Kazakov
2018-01-04 21:52 ` Mart van de Wege
2018-01-05 13:17 ` Jeffrey R. Carter
2018-01-05 14:35 ` Mart van de Wege
2018-01-05 15:21 ` Jeffrey R. Carter
2018-01-05 19:13 ` Paul Rubin
2018-01-05 23:50 ` Randy Brukardt
2018-01-06 1:19 ` G. B.
2018-01-06 9:59 ` Jeffrey R. Carter
2018-01-05 1:17 ` Randy Brukardt
2018-01-05 14:05 ` Jeffrey R. Carter [this message]
2018-01-05 23:58 ` Randy Brukardt
2018-01-04 12:43 ` gautier_niouzes
2018-01-03 17:28 ` Jeffrey R. Carter
2018-01-03 18:27 ` Mehdi Saada
2018-01-06 0:26 ` Matt Borchers
2018-01-06 22:04 ` J-P. Rosen
2018-01-07 2:05 ` Matt Borchers
2018-01-08 20:49 ` Randy Brukardt
2018-01-07 11:33 ` Mehdi Saada
2018-01-07 11:45 ` Simon Wright
2018-01-08 0:58 ` Matt Borchers
2018-01-07 17:47 ` Micah Waddoups
2018-01-07 21:04 ` Simon Wright
2018-01-23 3:49 ` Robert Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox