Clojure provides a mechanism for early termination from reduce expressions with 'reduced': https://clojuredocs.org/clojure.core/reduced
It's unusual to see a special early termination function: most PLs only provide general control flow constructs like exceptions.
miniblog.
Related Posts
I don't really understand Rust's `loop {}` syntax. It's syntactic sugar for `while true {}` but it feels odd to have special syntax for this case.
The name `loop` also doesn't imply 'loop with no termination condition' to me (other than break/continue).
I have a theory: Suppose I created a language Foo that printed execution time at termination:
$ ./hello
Hello World!
(Finished in 0.6 seconds)
I'm sure that Foo developers would be particularly sensitive to performance (for better and worse).
@wasamasa@niu.moe I suppose it makes some usages easier and others harder.
jQuery.each supports early termination, whereas Array.prototype.forEach does not. In Smalltalk this is less necessary.