[erlang-questions] orddict - is it an expected behavior?
zxq9
zxq9@REDACTED
Tue Jan 12 14:02:42 CET 2016
On 2016年1月12日 火曜日 13:50:50 Minin Maxim wrote:
> Hi All,
>
> is it an expected behavior?
>
> 1> orddict:merge(fun(_, _X, Y) -> Y end, orddict:from_list([{1,a},{2,b}]), [{1,c},{1,f}]).
> [{1,c},{1,f},{2,b}]
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.
OTOH, it is a little hard to blame the stdlib for throwing bad data around when the programmer is the one who pitched the first foul ball. I would rather see a crash there, but if this function has a typespec Dialyzer would almost certainly catch the mistake at check time -- which is the whole point of having it.
-Craig
More information about the erlang-questions
mailing list