<br><br><div class="gmail_quote">On Fri, Dec 23, 2011 at 5:09 PM, Richard Carlsson <span dir="ltr"><<a href="mailto:carlsson.richard@gmail.com">carlsson.richard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
A thing I've been tinkering with on and off for years is making a unified API for dictionaries in Erlang (dict, orddict, gb_trees, ets, dets). This requires figuring out a set of function names and calling conventions that are mostly familiar but which don't already have a conflicting definition in one or more of the modules involved.<br>
<br>
In the end I went for using most of the dict module API unchanged, with some new synonyms, and a number of additional useful functions. I also made the dict module define a new 'dict' behaviour (even though it's just an interface rather than a complete behaviour).<br>
<br> One particular detail is that gb_trees (with its user-unfriendly name and rather different calling conventions) can now quite simply be used through the dict module as an ordered variant of dict, and you can pretend you never heard of the gb_trees module unless you want to use one of its specially implementation-dependent functions. An ordered dict can be created through dict:new([ordered_set]). This also resolved some major problems with clashing function definitions.</blockquote>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The code (based on the OTP maint branch) can be found here:<br>
<br>
<a href="https://github.com/richcarl/otp/tree/dict-api" target="_blank">https://github.com/richcarl/otp/tree/dict-api</a><br>
<br>
The quickest way of having a look at the suggested API is to follow this link and scroll down to see the behaviour callback:<br>
<br>
<a href="https://github.com/richcarl/otp/blob/dict-api/lib/stdlib/src/dict.erl" target="_blank">https://github.com/richcarl/otp/blob/dict-api/lib/stdlib/src/dict.erl</a><br>
<br>
<br>
Reactions, suggestions, and test pilots are most welcome. I'm not ready to write an EEP until I feel the API is good enough. Things still on the TODO-list are: updating the docs for ets and dets, figuring out a good set of iterator functions, and maybe include QLC table/1/2 functions and match/select functions in the API. And then the same kind of unified API should be made for sets and probably also for sequences.<br>
</blockquote><div><br></div><div>I'm wondering how that changes impact modules like 'sets', 'ordsets' and 'gb_sets', where ordsets were based on the same data structure as orddict, sets the same as dict, and gb_sets were based on gb_trees' structure. There was some kind of general relationship between all these modules that is now being lost.</div>
<div><br></div><div>Otherwise, that sounds good.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
A Good Yule to y'all,<br>
<br>
/Richard<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br>