[erlang-questions] (no subject)

Vance Shipley vances@REDACTED
Fri Jun 15 20:15:46 CEST 2007


On Fri, Jun 15, 2007 at 02:06:31AM -0700, Thomas Lindgren wrote:
}  > http://wiki.trapexit.org/index.php/Cascading_Behaviours
}  
}  Writing all the "redirection code" explicitly is a bit
}  cumbersome compared to object-oriented inheritance. Is
}  there a better erlang-y way of doing this?

What this was supposed to be was an OTP-y way of doing things.

I have used this technique to create APIs for services I've
written.  For example in my Q.921/LAPD protocol stack (*)
implementation I use a lapd_mux_fsm(+) behaviour to provide the
stack specific functions and let the user implement a layer 1
binding in her own gen_fsm like module.

I don't much care how much typing I need to do for this use,
it only gets done once.  I created a template for gen_fsm and
gen_server however so when I redo the effort it's easy.

I've gone back and forth over the years on what an API should
look like.  Originally folks were encouraged to wrap the API
in a functional interface; foo:send(Msg), etc.  A more erlang-y
way would be to use explicit message passing; Foo ! Msg.  I
use OTP extensively for most of my production work so I have
also found that gen_fsm:send(foo, Msg) was a logical method.
If I were to embrace the plain_fsm/sys_fsm method fully I
would ditch the OTP API entirely and have a satisfyingly 
functional erlang-y interface using pure message passing.

	-Vance


(*) http://code.google.com/p/lapderl
(+) http://www.motivity.ca/lapd/lapd_mux_fsm.html
(=) http://www.erlang.org/ml-archive/erlang-questions/200504/msg00277.html



More information about the erlang-questions mailing list