Problem with dict:new()

Robert Virding <>
Sun Nov 25 22:04:56 CET 2001


Nico Weling <> writes:
>Hi all,
>
>after upgrading to Erlang R8B I've got a lot of badmatch errors due to the 'new' dict module.
>
>How is it possible to use the new release without changing my own programms?

This is just to confirm what other replies have stated.  The internal
representation has changed and dict's are now much more efficient.
Note that the internal representation was was never defined before!

There is a dict:size/1 function which returns the size of the dict,
the number of elements.

There is also another module orddict which has exactly the API as dict
but where the internal representation is defined to be a list of pairs
(tuples) ordered on the first element which is the key.  Here you
could test with [], but it is cleaner to use size/1.  I personally
find that sometimes it is practical to know that the representation is
a list, but with fold/3 I don't need it that often.

Perhaps there should also be a foreach/2?

Robert



More information about the erlang-questions mailing list