<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">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>
<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>On 01/22/2013 12:57 PM, Vlad Dumitrescu wrote:<br>
</div><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>
Hi,<br>
<br>
On Tue, Jan 22, 2013 at 12:10 PM, Loïc Hoguin <<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a><br></div><div>
<mailto:<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>>> wrote:<br>
<br>
On 01/22/2013 07:34 AM, Björn Gustavsson wrote:<br>
<br>
Why not use the existing -export() attribute and write like<br>
<br>
this:<br>
<br></div>
-export([monitor/2,demonitor/_<u></u>_1]).<div><br>
<br>
monitor(process, Pid) -><br>
do_something.<br>
<br>
demonitor(Pid) -><br>
do_something_else().<br>
<br>
So what would be the advantage of your version?<br>
<br>
<br>
It still allows Evan Miller to write this:<br>
<br>
-attr([first_name/1, last_name/1, ...]).<br>
<br>
$handle_undefined_function(F, [Model]) -><br>
{_, Value} = lists:keyfind(F, 1, Model),<br>
Value.<br>
<br>
<br>
I'm sorry, but I don't think you are answering Björn's question. For<br>
this particular case, why not write regular Erlang like<br>
<br>
first_name(Model) -> get(first_name, Model).<br>
last_name(Model) -> get(last_name, Model).<br>
get(F, [Model]) -><br>
{_, Value} = lists:keyfind(F, 1, Model),<br>
Value.<br>
which is much clearer to understand. One argument might be that there is<br>
some duplication, but I think that it could be handled with much more<br>
elegance if we had abstract patterns implemented.<br>
<br>
Do you have a more relevant example where using<br>
$handle_undefined_function gives significant advantage?<br>
</div></blockquote>
<br>
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.<div>
<div></div></div></blockquote></div><br></div><div class="gmail_extra">Maybe I'm confused, but your answer would make 100% sense if Björn's question would have been</div><div class="gmail_extra">
<br></div><div class="gmail_extra" style>"</div><div class="gmail_extra"><div> Why not use the existing -export() attribute and write like this:<br><span style="color:rgb(34,34,34)"> -export([monitor/2,demonitor/</span><span style="color:rgb(34,34,34)">1]).</span><br>
</div><div> <span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">$handle_undefined_function(</span><u style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"></u><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">mon</span><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">itor, [process, Pid]) -></span><br style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">
<span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"> do_something();</span><br style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"> $handle_undefined_function(</span><u style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"></u><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">dem</span><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">onitor, Pid) -></span><br style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">
<span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"> do_something_else().</span></div><div>"
</div><div><br></div><div style>My question is a follow-up on his own formulation, where your suggestion is compared with an implementation not using <span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">$handle_undefined_function at all.</span></div>
<div><br></div><div style>best regards,</div><div style>Vlad</div><div style><br></div></div></div>