Your own behaviours

Gunilla Hugosson <>
Fri Sep 21 14:07:25 CEST 2001


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   : 

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



More information about the erlang-questions mailing list