[erlang-questions] gb_trees, strange behaviour
Kostis Sagonas
kostis@REDACTED
Sat Nov 6 17:53:21 CET 2010
Michal D. wrote:
>
> Maybe we should update the documentation? It's pretty common to use a
> list of tuples as a dictionary in other languages and that's what
> appears to be specified in the Erlang documentation:
>
> ----------
> from_orddict(List) -> Tree
>
> Types:
>
> List = [{Key, Val}]
> Key = Val = term()
> Tree = gb_tree()
>
> Turns an ordered list List of key-value tuples into a tree. The list
> must not contain duplicate keys.
> ----------
>
> Although on a second reading, it seems that the word "ordered" in
> "ordered list" is key. So is an orddict just an ordered list of tuples?
In my opinion, the documentation should definitely be updated.
It should instead read:
from_orddict(OrdDict) -> Tree
Types:
OrdDict = orddict(Key, Val) (see <LINK TO orddict documentation>)
Also, in an ideal world, the orddict() type should have been declared
opaque instead so that tools such as dialyzer complain when finding code
that creates random lists (like yours) and passes them to a function
expecting an orddict() instead.
I think this change is still doable and should happen. I volunteer to do
this if there is enough consensus in the community.
Kostis
More information about the erlang-questions
mailing list