On Wed, 12 Oct 2011 19:00:56 +0200, Jacob Carlborg <[email protected]> wrote:

On 2011-10-12 18:18, Gor Gyolchanyan wrote:
You never know when exactly and in which conditions will that delegate
get called. You can't decide to quit something you don't know anything
about.

If a function implements something similar to a loop I would like to be able to abort it with a return just as you can with a loop built into the language.

void loop (void delegate () dg)
{
     while (true)
         dg();
}

loop
{
     if (someCondition)
         return; // stops the loop
}

However, a lot of code using this syntax would be more complex than what
you indicate. Should it work simply as a break in the loop? What if it
is a recursive function? There is a reason why opApply is designed the
way it is.

--
  Simen

Reply via email to