in reply to Re^3: Insensitive Scoundrel
in thread Insensitive Scoundrel

Re: Now, what would you expect that loop to return, if it were like a map? You can't skip or restart map in the same way, you realise, probably because it could cause some very strange behavior.

I got it: You have next, last, continue to modify the looping. How about a keyword result or somesuch that is like the "return" from a function? Just give an argument to next, continue, etc. and you don't need new keywords.

Dropping off the end of the block is an implicit "continue", just as the last statement in a function is an implicit "return". If you don't give an argument to the next, last, or whatnot, it becomes an undef empty list and doesn't add anything to the result list.

Replies are listed 'Best First'.
Re: map and foreach are the same
by Aristotle (Chancellor) on Oct 04, 2002 at 20:22 UTC
    Just a minor nitpick: not giving an argument should implicitly pass the empty list, not undef - just like you do when you want an iteration of a map to "disappear" from the result list. </nitpick> :-)

    Makeshifts last the longest.