<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

It is more verbose, but will not come at any cost in terms of genericity<br>
and will not mess up tracing and anything else the way parametrized<br>
modules used to.<br>
<br>
You are right, however, that Erlang doesn't really have a thing like<br>
protocols, which are a pretty neat feature in languages that can provide<br>
a solid implementation for them.<br></blockquote><div><br></div><div style="font-size:13px;font-family:arial,sans-serif">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).</div>

<div style="font-size:13px;font-family:arial,sans-serif"><br></div><div style="font-size:13px;font-family:arial,sans-serif">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.</div>

<div class="gmail_extra"><div><br></div><div><br></div><div><span style="font-size:13px"><div><span style="font-family:arial,sans-serif;border-collapse:collapse"><b>José Valim</b></span></div><div><span style="font-family:arial,sans-serif;border-collapse:collapse"><div>

<span style="font-family:verdana,sans-serif;font-size:x-small"><a href="http://www.plataformatec.com.br/" target="_blank" style="color:rgb(42,93,176)">www.plataformatec.com.br</a></span></div><div><span style="font-family:verdana,sans-serif;font-size:x-small">Skype: jv.ptec</span></div>

<div><span style="font-family:verdana,sans-serif;font-size:x-small">Founder and Lead Developer</span></div></span></div></span></div></div><div><br></div></div></div></div>