-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why no public decode/2
?
#25
Comments
Hi! When adapting the Sqids spec to Elixir conventions, I found no “operational error” to return when decoding - for ex, decoding a string with characters unknown to the configured alphabet will just return an empty list instead. However, decoding can still raise if you feed it a non-binary, or a binary that’s not UTF-8 encoded. These do not count as operational errors (in my intuition of Elixir convention) but rather as “you’re holding it wrong” cases, where non-bang versions of functions nevertheless raise. I therefore considered: what if there is So I chose Reviewing my thinking, I speculate the purest implementation would have been a Would that be a breaking change? I say it would, or at least more so than an already raising function that starts raising on operational errors whereas it didn’t before. I went into the weeds there. I hope my reasoning was clear, and I’m open to a new perspective on this, as I’ve debated myself in the past about bang-function semantics. I’ll leave this issue open for a while. Thanks for raising it! (No pun intended) |
Why
decode!/2
does not have a public non-throwing counterpart?The text was updated successfully, but these errors were encountered: