A similar question was asked Parameterised Modules in Erlang, it is about "what". My question is about "why"?
OTP Technical Board - Decisions affecting R16 contains the board decision about this issue, but I don't know the reason behind the decision.
Stateful Module in Programming Erlang 2ndEdition by Joe Armstrong introduces this feature in detail, but I don't see the author's attitude.
If we read the official document Function Calls, we see this feature is deliberately skimmed. In fact, the official document strongly discourages using this feature, refer to efficiency function calls. If so, why Joe Armstrong mentions such feature in his book?
I think this feature is awesome. As the above book mentioned, my client code could be like below
Obj:find(Key),
Obj:is_key(Key),
Then, we don't care whether Obj
is created by dict:new()
, or gb_tree:new()
, unfortunately, dict
and gb_tree
do not share a consistent interface, e.g. we have gb_tree:lookup
instead of gb_tree:find
.