[erlang-questions] towards a unified dict api

José Valim <>
Fri Jan 13 12:44:15 CET 2012


I agree with the general direction of creating another module called
gen_dict that adds a level of indirection instead of changing dict
implementation. So developers can choose between transparency (gen_dict)
and performance (dict).

But the truth is that Erlang lacks the proper abstractions to (elegantly)
solve this problem. Even if we create a module that properly wraps
gb_trees, orddict and dict, if the developer decides to create a new
dictionary (for example, a red black tree based implementation) there is no
way the developer will be able to hook his own dictionary into the gen_dict
API. An abstraction like Clojure's protocols would be able to solve this
more elegantly.

Tuple modules could be a possible solution to this problem, so one would be
able to call Dict:find(Key) and not worry about what a Dict really is, but
they wouldn't work for orddicts or gbtrees unless they are rewritten to be
in the tuple module format and I doubt this is a direction people would
like OTP libraries to move towards to (I certainly don't).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120113/3371ef22/attachment.html>


More information about the erlang-questions mailing list