in reply to Re^6: Using lazy list with a for loop
in thread Using lazy list with a for loop
But because of cleaner scope and loop-control statements I'd rather prefer
for (my $iter = get_iter(); my ( $widget ) = $iter->(); ) { ... }
over
my $iter = get_iter(); while ( my ( $widget ) = $iter->() ) { ... }
This approach will put $iter in a tight scope and properly destroy.
Needless to say, if Perl had macros like Lisp, we wouldn't need to repeat that discussion again and again...
Keyword-simple could solve this, but is restricted to statements only.
see also
Can I check if a loop's scope is entered for the first time?
Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Using lazy list with a for loop
by ikegami (Patriarch) on Jan 03, 2023 at 16:26 UTC |