<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/5/24 Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 05/23/2013 02:02 PM, Ronan Lamy wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2013/5/23 Łukasz Langa <<a href="mailto:lukasz@langa.pl" target="_blank">lukasz@langa.pl</a> <mailto:<a href="mailto:lukasz@langa.pl" target="_blank">lukasz@langa.pl</a>>><div class="im"><br>
<br>
On 23 maj 2013, at 20:13, Éric Araujo <<a href="mailto:merwok@netwok.org" target="_blank">merwok@netwok.org</a> <mailto:<a href="mailto:merwok@netwok.org" target="_blank">merwok@netwok.org</a>>> wrote:<br>
<br>
> Question: what happens if two functions (say in two different modules)<br>
> are registered for the same type?<br>
<br>
Last one wins. Just like with assigning names in a scope, defining methods<br>
in a class or overriding them in a subclass.<br>
<br>
<br>
This is a serious annoyance, considering that there are several places where a large library can reasonably define the<br>
implementations (i.e. with the class, with the function, or in some utility module). Note that in contrast with the case<br>
of functions in a module or methods in a class, linting tools cannot be expected to detect a duplication between<br>
functions with different names defined in different modules.<br>
</div></blockquote>
<br>
What would you suggest happen in this case?<br></blockquote><div><br></div><div>Raise a ValueError, maybe? In that case, there needs to be a way to force the overriding when it is explicitly desired. One way would be to allow unregistering implementations: overriding is then done by unregistering the old implementation before defining the new one. This is a bit cumbersome, which IMHO is a good thing for an operation that is just as disruptive as monkey-patching a class or a module.<br>
</div></div></div></div>