Sun Sep 8 18:41:55 CEST 2002
originally behaviours were developed because their are many
ways to implement a process structure of linked processes
monitoring each other. Monitoring each other in the sence that
you like appropriate actions to be taken if a process terminates
due to a fault. In large project you like all programmers to
use the *same* strategy. It would also be nice if this fault
tolerance stuff was programmed once and for all (by someone
who hopefully knows what he is doing :-). Therefore the code
of a process "using" a certain behaviour is divided into a
generic part and a specific part.
In the generic code these things are hidden, linking, reporting
erronous states, taking some kind of action in the event of
an unexpected process termination etc. You then only have to
write the specific code that will do the task your process is
meant to be responsible for. But since different tasks may
require processes to behave in slightly different manners,
a collection of behaviours were invented.
The specific code must implement an interface to the generic
code. Those functiona are called the call-backs. Take a look
at the man-page for gen_server, which is the simplest behaviour.
Alex Peake wrote:
> Thank you Francesco.
> I guess the answer is that there is nothing "of a tutorial nature".
> I was looking for more of:
> What is a behaviour? When do you need one? How do you build one?
> (I saw a quote from Joe Armstrong something of the nature that -- in Erlang you do not need objects
> because you have behaviours -- so I wanted to explore what this meant)
> > -----Original Message-----
> > From: Francesco Cesarini [mailto:francesco@REDACTED]
> > Sent: Sunday, September 08, 2002 6:02 AM
> > To: Alex Peake
> > Cc: erlang-questions@REDACTED
> > Subject: Re: Behaviours
> > Hi Alex,
> > OTP behaviors are covered in detail in the Design Principles
> > documentation at
> > http://www.erlang.org/doc/r8b/doc/design_principles/part_frame.html It
> > also gives a few good examples. You can complement this with the manual
> > pages for the different behavior modules. Lastly, you can find tons of
> > examples of usage of behaviors in the contributions section of the open
> > directory.
> > Good Luck,
> > Francesco
> > --
> > http://www.erlang-consulting.com
> > Alex Peake wrote:
> > >Is there, somewhere, a more tutorial description of how to create behaviours?
> > >
> > >Alex
> > >
> > >
> > >
Lennart Ohman phone : +46-8-587 623 27
Sjoland & Thyselius Telecom AB cellular: +46-70-552 6735
Sehlstedtsgatan 6 fax : +46-8-667 8230
SE-115 28 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED
More information about the erlang-questions