
14 Aug
2015
14 Aug
'15
2:44 a.m.
On 14/08/15 09:21, William Yager wrote:
If I mis-index a vector, I don't want it to fail silently with mempty; I want it to fail loudly. What you've described (default value on out-of-bounds access) is not correct for most use cases. Sometimes exceptions are the right behavior.
Precisely. «An element is not found, so I'll just return 0[*] or "".» Even JavaScript knows better than that. Granted, there *is* a way to use this API properly (using Maybe-like monoids). But it's also easy to make the wrong code type-check without realizing it. [*] that's essentially what Nikita proposed earlier in the thread