Stop being the product.
Become the owner.
or
sign uplog in

Which programming languages execute the for-loop iterating…

Which programming languages execute the for-loop iterating expression exactly once?

Do any programming languages evaluate their for-loop iterating expression exactly once?

Curious which of POSIX sh, Rust, Go, blah blah blah can safely move iterators into the for loop declaration, instead of having to use an explicit variable prior.

Examples:

\* Looping over the output lines from a shell subcommand

\* Looping over entries in a slow, complicated mathematical integer series that takes time to regenerate

\* Looping over file system directory contents

I imagine that programming languages with iterable interfaces may evaluate the iterator expression exactly once, then safely process the iterable.

Ranges are fine.

Boolean conditionals and post operations are of course evaluated every time.

No idea for shells or non-iterable contexts.
#technology
earnings
2,000 mlx total
$0  total
engagement
3 views
0 reactions

0 comments