Erlang Language Behaviours Using a behaviour


Example

Add a -behaviour directive to your module to indicate that it follows a behaviour:

-behaviour(gen_server).

The American spelling is also accepted:

-behavior(gen_server).

Now the compiler will give a warning if you've forgotten to implement and export any of the functions required by the behaviour, e.g.:

foo.erl:2: Warning: undefined callback function init/1 (behaviour 'gen_server')