[erlang-questions] defining default functions for a module
Wed Nov 11 01:48:12 CET 2009
My callbacks are not dynamic so I won't be leaking atoms.
I can have a dummy function but it makes dev longer and modules less readable.
I'm trying to do something similar to objects and classes in OO.
How gen_event is related?
From: Jayson Vantuyl <kagato@REDACTED>
To: Pablo Platt <pablo.platt@REDACTED>
Cc: erlang-questions <erlang-questions@REDACTED>
Sent: Wed, November 11, 2009 2:32:04 AM
Subject: Re: [erlang-questions] defining default functions for a module
Maybe require a callback module to have a dummy function, or is the function name really dynamic? If it is dynamic (and your program is network accessible), are you sure you won't be leaking atoms (i.e. exposing an exciting DOS)?
Also, have you considered gen_event? They're quite lovely, I assure you.
On Nov 10, 2009, at 3:25 PM, Pablo Platt wrote:
> I have a module that acts as a router.
> It gets requests and pass them to callback modules.
> Callback modules should have a function for each case unless they need to do something specific.
> Is it ok to use erlang:function_exported/3 to check if the callback module defined the needed function
> and if not to execute the default defined in the router?
> Will it cost me in performance or is it against the way I should do things in erlang?
> I thought a behavior will solve my need but it only recommend a module structure for the compiler.
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
More information about the erlang-questions