Loop iterator - example.txt
kris
foo at bar.com
Sat Apr 29 17:28:13 PDT 2006
Derek Parnell wrote:
> 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.
> }
> }
>
Does that retry that instance, or retry the entire loop? Couldn't the
semantics be either, given the appropriate condition?
More information about the Digitalmars-d
mailing list