<div dir="ltr"><div><div><div>One definite benefit in having to explicitly write every callback even if it is doing "default" stuff is that everything *IS* then explicit and you can directly SEE what happens. And come on, writing a 2 line default case for a few callbacks is really not that much to extra code.<br><br></div>A major problem with having implicit "default" cases is that what people consider to be a reasonable default handling varies depending on what just that server is doing. There is no default that suits every server so I will probably have to write it out and anyway.<br><br></div>Hiding callbacks behind defaults also means that you don't SEE everything that is there. This can be a major problem for newcomers.<br><br></div>Robert<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 February 2016 at 11:54, Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 02/26/2016 10:27 PM, Onorio Catenacci wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
While there may be other considerations you want to keep in mind,<br>
there's one, to my mind, major point that's been neglected in the<br>
discussion of using Elixir: macros.<br>
<br>
I have been led to understand by people far more familiar with Erlang<br>
than I am that in order to use certain behaviours from OTP one has to<br>
write boilerplate code for several callbacks whether one wants to modify<br>
the behavior from defaults or not.<br>
<br>
Elixir's macros allow the library to provide default implementations for<br>
these callback functions.  Of course a developer can override the<br>
defaults if needed but not having to code what I don't need strikes me<br>
as a big advantage--especially if we're discussing a new developer who<br>
doesn't already know either Erlang or Elixir.<br>
</blockquote>
<br></span>
I'm not even sure what makes you think you need macros to provide default implementations? You don't. The gen_server for example has an optional callback with a default implementation: format_error. That it doesn't provide defaults for other callbacks is purely a design choice, and not a limitation of the language. You could trivially extend gen_server to make all callbacks optional, no need to have macros for that...<span class="im HOEnZb"><br>
<br>
-- <br>
Loïc Hoguin<br>
<a href="http://ninenines.eu" rel="noreferrer" target="_blank">http://ninenines.eu</a><br>
Author of The Erlanger Playbook,<br>
A book about software development using Erlang<br></span><div class="HOEnZb"><div class="h5">
_______________________________________________<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" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>