[erlang-questions] Improve $handle_undefined_function

Björn Gustavsson bgustavsson@REDACTED
Tue Jan 22 15:41:16 CET 2013

On Tue, Jan 22, 2013 at 1:02 PM, Loïc Hoguin <essen@REDACTED> wrote:

> 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.
Except that your "improvements" to $handle_undefined_function
renders it completely useless for the problem it was supposed
to solve.

Namely to emulate the existing -extends() directive, which is
used as follows:


where Module is the module to be extended. [1]

Your mission, should you decide to accept it,
is to implement -extends(Module) in a parse transform.

You have no knowledge of the the other module. It might
not even exist when the module containing the -extends()
directive is compiled; furthermore, if more functions are
added to the module being extended in the future, you
should still be able to call them from the module
containing the -extends() directive (without recompiling

To make it more concrete, you should implement a
parse transform and use it to compile the following


extender should then be able to call any function in the
module 'mission_impossible' stored on my computer.
That is:


will call mission_impossible:foo(42) provided that
foo/1 is exported from mission_impossible.

You may use either the current implementation or
your "improved" version of $handle_undefined_function,
at your choice.

Should any of your computer systems crash or burn,
the Secretary will disavow any knowledge of your
actions. [2]

[1] http://www.erlang.se/euc/07/papers/1700Carlsson.pdf

[2] http://en.wikipedia.org/wiki/Mission:_Impossible

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

More information about the erlang-questions mailing list