Loop iterator - example.txt
Derek Parnell
derek at psych.ward
Sat Apr 29 17:33:33 PDT 2006
On Sun, 30 Apr 2006 10:28:13 +1000, kris <foo at bar.com> wrote:
> 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?
Just the instance and not the entire loop. There is a 'restart' key word
to do the whole loop thing.
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d
mailing list