Loop iterator - example.txt
Derek Parnell
derek at psych.ward
Sat Apr 29 17:12:53 PDT 2006
On Sun, 30 Apr 2006 06:02:10 +1000, Bruno Medeiros
<brunodomedeirosATgmail at SPAM.com> wrote:
> In fact, the very idea seems like a very awkward idiom to me. I would
> like to examine a real example, can someone post one?
We use it in the area of retrying a database transaction after some sort
of exception condition has happened. It has nothing directly to do with
loop index maintenance.
In pseudo-code ...
foreach (inout Customer cust; CustomerSet )
{
try {
cust.name = UI.CustName;
cust.address = UI.Address;
. . .
}
catch (BadUI e)
{
// Recover from the (rare) UI data error
. . .
retry; // Reprocess the same customer record.
}
}
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d
mailing list