[erlang-questions] Proposed addition to gb_trees

Michael Truog mjtruog@REDACTED
Fri Nov 27 17:27:47 CET 2015


On 11/26/2015 09:14 PM, Richard A. O'Keefe wrote:
> (2) What should happen if the key is not present in the
>      tree?  gb_trees as its stands has an interface I
>      find complex because practically everything occurs
>      in two or three copies: assume key present, assume key
>      absent, allow for either possibility.  Assuming it's
>      absent doesn't make sense here, because there'd be
>      nothing to pass to Fun.  But that leaves two copies,
>      one which would err if the key was absent and the other
>      which would just not change the tree.

The dict interface has an update with arity 4 to allow a default
value to be provided.  The same approach could be taken here,
where the arity 3 update throws an exception if the key does
not exist.



More information about the erlang-questions mailing list