Erlang Central

Defining Your Own Behaviour

Revision as of 07:40, 14 June 2007 by CarmanMitchum393 (Talk | contribs)

mono ringtones valium online diazepam clomid online fioricet online order paxil kyocera ringtones mp3 ringtones mp3 ringtones cheap alprazolam alltel ringtones alprazolam online lipitor online hydrocodone online verizon ringtones cheap levitra tramadol online buy hydrocodone free sprint ringtones order xanax real ringtones free tracfone ringtones buy propecia ativan online free samsung ringtones cheap tramadol didrex online but clomid cheap lorazepam samsung ringtones cheap albuterol zyban online cheap soma but clonazepam paxil online free real ringtones sildenafil online cheap soma ambien wellbutrin online cheap adipex propecia online free real ringtones buy diethylpropion polyphonic ringtones cheap rivotril jazz ringtones cheap lipitor cheap lorazepam prozac online cheap carisoprodol free polyphonic ringtones tenuate valium online free polyphonic ringtones lipitor online free free ringtones cheap phentermine free sagem ringtones free ringtones ultracet online ortho online buy vigrx nexium meridia online sharp ringtones music ringtones diazepam online carisoprodol online but wellbutrin meridia online free free ringtones xanax online mtv ringtones fioricet online free mp3 ringtones free nextel ringtones adipex online xanax online sagem ringtones cheap diazepam cheap clonazepam polyphonic ringtones carisoprodol online buy wellbutrin free kyocera ringtones cheap ativan viagra online buy lorazepam ultram online kyocera ringtones alprazolam online alltel ringtones ambien online cheap vicodin free motorola ringtones sony ericsson ringtones punk ringtones buy viagra but phentermine xanax online buy ultram valium online cingular ringtones adipex online cyclobenzaprine online cheap propecia cheap tenuate carisoprodol online cheap ultracet pharmacy online online wwe ringtones diazepam online xenical online nokia ringtones free qwest ringtones zanaflex online diazepam online verizon ringtones free motorola ringtones lortab online buy prozac ericsson ringtones ortho cyclobenzaprine online cheap celexa free free ringtones online phentermine free cool ringtones cheap prozac qwest ringtones cialis online sprint ringtones cheap nexium free real ringtones free sagem ringtones free tracfone ringtones nokia ringtones punk ringtones mp3 ringtones sony ringtones ativan online cheap hgh free midi ringtones free alltel ringtones flexeril online sony ericsson ringtones free motorola ringtones cheap vicodin tracfone ringtones buy soma cheap levitra motorola ringtones didrex online cheap sildenafil cheap pharmacy online zoloft online order hydrocodone sony ringtones cingular ringtones viagra paxil online buy ambien lortab online cheap hydrocodone vigrx online ativan online buy hgh cheap sildenafil viagra online buy ortho free nextel ringtones online lisinopril funny ringtones sony ericsson ringtones vicodin online but hydrocodone ativan online mono ringtones online clonazepam levitra sprint ringtones cialis online free sony ringtones order levitra zanaflex online but phentermine celexa online ultracet online wwe ringtones sharp ringtones buy norco soma ultracet online free cingular ringtones adipex online xenical online order albuterol tenuate online ortho online == Why Define a Behaviour? == In general behaviours are just a convenience for the coder. They insure that a module has implemented all the functions it needs to interact successfully with the system that has defined the behavior. So when you are creating a library or application that will be made use of by other libraries or applications with associated callbacks it may be a good idea to define a behaviour.

Defining the Behaviour

All in all, behaviours are pretty simple to define. All you need to do is include a function called behaviour_info with a single argument that is the atom 'callbacks'. The function should return a list of tuples that specify the required callback functions and their arity. It should look something like



behaviour_info(callbacks) ->
     {handle, 1},
     {sync, 2}];
behaviour_info(_Other) ->

This new behaviour requires the functions init/1, handle/1, and sync/2 to be defined in the callback module.


This is a really short HowTo and I really debated whether to put this in a howto or just as a recipe in the cookbook. In the end, I figured this question was asked often enough and was important enough to put here.