in reply to Doing "it" only once

Supposing there is a way to pause (pause) a loop, and continue it later (cont { ... }), it's easy:

my macro do_something { ... } for (...) { pause, next if ...; do_something; } cont { do_something; }
For this to work, pause would only come into effect after the entire statement is evaluated. Alternatively, consider next :pause or pause :next.

Having things optimized with a simple hint I think would be trivial.

for (...) { notagain, next if ...; ...; }
would automatically be split.

Still, I don't think it's a problem that needs fixing. If you want to fix it, it's probably simple enough to do it in a module.

I would like the pause/cont combo, though. For many purposes, because not everyone likes to think in iterators.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
Re^2: Doing "it" only once
by blazar (Canon) on Sep 22, 2005 at 10:57 UTC
    for (...) { notagain, next if ...; ...; }
    Could notagain be a sort of macro that would turn this code into that above -- or better: taking into account that there may already be a cont block, "inject" some code into a suitable "hook" provided by the latter (which I would definitely expect to be there).