[erlang-questions] orddict - is it an expected behavior?

Jesper Louis Andersen <>
Tue Jan 12 14:13:23 CET 2016

On Tue, Jan 12, 2016 at 2:02 PM, zxq9 <> wrote:

> It probably should crash there, IMO. There are other places in the stdlib
> where you can drop invalid data grenades by passing wrong types, too. I
> guess there isn't a super convenient way to check this, though -- so maybe
> it is a tradeoff made in the interest of performance.

It is an instance of positive/negative testing or type I/II errors:

* Positive polarity: if we supply valid preconditions to a function, its
postcondition is valid
* Negative polarity: if we supply invalid preconditions to a function, it
rejects the input

They are duals, and in a "perfect" function, they coincide: Any input is
either accepted or rejected based on the input according to the
specification. There is no risk of valid input being rejected or invalid
input being accepted.

What Kostis says is arguably true: most of the specifications in Erlang's
stdlib only concerns itself with the positive variant, and makes no claims
about the negative variant. This is often true in many programming

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160112/43ae8686/attachment.html>

More information about the erlang-questions mailing list