Your own behaviours

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Your own behaviours

Gunilla Arendt-3
Hi,

This feature has now been added to Erlang/OTP R8 according to
an implementation proposal made by Ulf Wiger. Release note:

        It is now possible to have the compiler check user-defined
        behaviours and not only the pre-defined OTP behaviours
        (gen_server etc.).

        This is done by adding a function behaviour_info/1 to
        the behaviour module. behaviour_info(callbacks) should return
        a list of {FunctionName,Arity} which defines the callback
        functions the behaviour uses.

        When a callback module with the attribute
          -behaviour(Behaviour).
        is compiled, its exported functions will be compared with
        the list returned by Behaviour:behaviour_info(callbacks) and
        a warning will be issued if any callback function is missing.

        Note that the user must ensure that the module Behaviour is
        present at compile-time and can be found in the current code
        path.

Best regards, Gunilla



Lennart ?hman wrote:

> Hi!
>
> Mandatory callback functions, among other things, are defined
> in the module otp_internal. This module is used when compiling
> modules having -behavior attribute.
>
> If you wish to extend your OTP with your own behaviors, otp_internal
> must (should) be changed.
>
> My suggestion is that the functions in the otp_internal are changed to
> look for the "answers" in the generic module corresponding
> to the behaviour at hand. In this way you do not need to change
> modules belonging to the original system. But instead only program
> a set of required functions in any new behaviour you invent.
>
> Best Regards,
>
> Lennart
>
> -------------------------------------------------------------
> 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

--
_____Gunilla Hugosson____________________________________________
Project Manager, Erlang/OTP
Ericsson Utvecklings AB, UAB/S/P OTP Product Development
gunilla  +46-8-7275730


Reply | Threaded
Open this post in threaded view
|

Your own behaviours

Mickael Remond-2
Gunilla Hugosson (gunilla) wrote:
> Hi,
>
> This feature has now been added to Erlang/OTP R8 according to
> an implementation proposal made by Ulf Wiger. Release note:

Good news. R8 is really going to be a major release, full of new
features.
Thank you. I like that :-)

--
Micka?l R?mond
http://www.erlang-fr.org/