[erlang-questions] Module-Function-Arguments (MFA)

Avinash Dhumane nistrigunya@REDACTED
Fri Jun 26 17:51:51 CEST 2015


I need to implement a "service" functionality which allows the "client" to
implement callbacks (from service into client's module) which it wishes to
handle.

I accept the module name as parameter from the client and mandate the
function names (callbacks) and parameters thereof which the client may
define in its module.

Suppose one of the callback names is 'handle_tick', and the module name
supplied by the client is held in variable 'Module' in my service
implementation code.

How do I verify whether client has implemented the function handle_tick()
in its module? Or, do I just invoke it and handle the exception using
try-catch?

Thanks
Avinash

PS: I observe that the web sockets functionality in Yaws uses similar
mechanism to invoke callbacks in client's module. But, digging into Yaws'
source code is a little too overwhelming for me :-(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150626/30a8178c/attachment.htm>


More information about the erlang-questions mailing list