[erlang-questions] Elixir Protocols in Erlang & a Strange Warning

José Valim <>
Sun Dec 15 21:35:28 CET 2013

> It is more verbose, but will not come at any cost in terms of genericity
> and will not mess up tracing and anything else the way parametrized
> modules used to.
> You are right, however, that Erlang doesn't really have a thing like
> protocols, which are a pretty neat feature in languages that can provide
> a solid implementation for them.

Right. The parameterized module is not related to Elixir protocols at all.
The parameterized module here doesn't offer any benefit over a direct
dispatch. As Fred said, it only messes up stacktraces and what you have at
the end is still ad-hoc polymorphism (via guards).

I want to clarify this is not how Elixir protocols work. Vincent's example
is a good approximation but we are able to optimize it quite well. Once you
build a release the cost of a protocol dispatch is quite low: it costs a
pattern match (which you would have anyway) and one extra remote call.

*José Valim*
Skype: jv.ptec
Founder and Lead Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131215/b72d412a/attachment.html>

More information about the erlang-questions mailing list