[erlang-questions] Recommendations on optional callbacks
Tue Jul 22 02:11:05 CEST 2014
I still prefer behaviors...
src/my_evt.erl:5: Warning: undefined callback function handle_info/2
...sometimes "newer" isn't necessarily "better".
On Monday, July 21, 2014 4:08:06 PM UTC-5, Jay Nelson wrote:
> We have created a behaviour with -callbacks, but would like to simplify
> the implementation by providing default implementations of some of the
> callbacks. Using erlang:function_exported/3 to test for a user-supplied
> callback and instead calling a default implementation may work, but the
> compiler will complain for the user-defined module if no callback is
> supplied. What is the recommended best practice for this situation?
> The best I can come up with is to document the default implementation
> and leave it up to the user-defined module to call that function or
> provide its own so that the callback is always present.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions