3 ms·
That’s a silly abuse of the idea of least surprise. Documented, long-lived built-in data structures like generators that support behavior like exhaustion and mu
by mlthoughts2018 8y ago
That’s a silly abuse of the idea of least surprise. Documented, long-lived built-in data structures like generators that support behavior like exhaustion and mutation in a time-tested way are _clearly_ not some kind of surprising and useless or pedantic quirk.
I mean, consider implicits in Scala. It’s hard to think of a worse violation of least surprise, but because it’s documented and time-tested and becomes a de facto standard in that language, the argument of least surprise becomes nothing but a preference debate.
The behavior where max raises an exception on an exhausted generator is not at all surprising, from the point of view of language documentation, ubiquitous and popular advice on that data structure, etc. etc.
And besides all that: if you did happen to find a serious design bug that created a surprise problem, there are tons of ways to solve that problem in a dynamically typed language that wouldn’t require static typing or borrow checking or any explicit state management. It still would not be evidence that those things are a superior way to solve it.