[erlang-questions] Improve $handle_undefined_function

Björn Gustavsson <>
Tue Jan 22 07:34:44 CET 2013


On Mon, Jan 21, 2013 at 7:04 PM, Loïc Hoguin <> wrote:

> My proposal is to use an attribute to list the functions defined like
> this, so that error_handler can make the distinction between undef and
> badarg directly. The above function would then be written like this:
>
> $handle_undefined_function(**monitor, [process, Pid]) ->
>     do_something();
> $handle_undefined_function(**demonitor, Pid) ->
>     do_something_else().
>
>
I don't really get the rationale for your proposal.

If have understood you correctly, I must know beforehand
which functions that $handle_undefined_function would handle,
and put all functions to be handled in an attribute.

Why not use the existing -export() attribute and write like
this:

-export([monitor/2,demonitor/1]).

monitor(process, Pid) ->
   do_something.

demonitor(Pid) ->
   do_something_else().

So what would be the advantage of your version?

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130122/3c5e1136/attachment.html>


More information about the erlang-questions mailing list