<div dir="ltr"><div class="gmail_extra" style>On Tue, Jan 22, 2013 at 1:02 PM, Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span> wrote:<br></div><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"><div class="im">That's a question about $handle_undefined_function in general, not about this specific implementation proposal. Björn is the one who wrote the current implementation that's now in master, I don't have to tell him what can be done with it, he knows. I do have to tell him how implementing it this way improves the usage, though. Which is the sole reason of this thread.<br>
</div><div class=""><div class="h5"><br></div></div></blockquote><div><br></div><div style>Except that your "improvements" to $handle_undefined_function</div><div style>renders it completely useless for the problem it was supposed</div>
<div style>to solve.</div><div style><br></div><div style>Namely to emulate the existing -extends() directive, which is<br></div><div style>used as follows:</div><div style><br></div><div style>-extends(Module).</div><div>
<br></div><div style>where Module is the module to be extended. [1]</div><div style><br></div><div style>Your mission, should you decide to accept it,</div><div style>is to implement -extends(Module) in a parse transform.</div>
<div style><br></div><div style>You have no knowledge of the the other module. It might</div><div style>not even exist when the module containing the -extends()</div><div style>directive is compiled; furthermore, if more functions are</div>
<div style>added to the module being extended in the future, you</div><div style>should still be able to call them from the module</div><div style>containing the -extends() directive (without recompiling</div><div style>it).</div>
<div style><br></div><div style>To make it more concrete, you should implement a</div><div style>parse transform and use it to compile the following</div><div style>module:</div><div style><br></div><div style>-module(extender).</div>
<div style>-extends(mission_impossible).</div><div style><br></div><div style>extender should then be able to call any function in the</div><div style>module 'mission_impossible' stored on my computer.</div><div style>
That is:</div><div style><br></div><div style> extender:foo(42)</div><div style><br></div><div style>will call mission_impossible:foo(42) provided that</div><div style>foo/1 is exported from mission_impossible.</div><div style>
<br></div><div style>You may use either the current implementation or</div><div style>your "improved" version of $handle_undefined_function,</div><div style>at your choice.</div><div style><br></div><div style>Should any of your computer systems crash or burn,<br>
</div><div style>the Secretary will disavow any knowledge of your</div><div style>actions. [2]</div><div style><br></div><div style>[1] <a href="http://www.erlang.se/euc/07/papers/1700Carlsson.pdf">http://www.erlang.se/euc/07/papers/1700Carlsson.pdf</a></div>
</div><div><br></div><div>[2] <a href="http://en.wikipedia.org/wiki/Mission:_Impossible">http://en.wikipedia.org/wiki/Mission:_Impossible</a></div><div><br></div>-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB
</div></div>