[erlang-questions] OO programming style in Erlang?

Sean Hinde sean.hinde@REDACTED
Mon Jan 22 13:23:53 CET 2007


On 22 Jan 2007, at 11:39, Ulf Wiger wrote:

> Den 2007-01-22 11:52:35 skrev Ladislav Lenart <lenartlad@REDACTED>:
>
>> *Question:* Is there a way such polymorphism can be
>> achieved in Erlang without actually merging (see above)
>> the modules that should behave polymorphically?
>
> No universally agreed upon common method, no,
> if I understood your question correctly.
>
> Xmerl, for example, introduced a notion of module
> inheritance, with which one were supposed to extend
> the functionality of export callbacks. See e.g.
> http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/ 
> xmerl.erl?revision=1.2&view=markup
> mainly lines 267-313.
> (or the OTP source tree for a more current version.)
>
> I don't know if anyone has actually made use of it.

I suspect not.

IMO the most important thing to take away from this discussion is  
that OO style is not the normal or best way to program in Erlang.

Try not to think of erlang processes as simply repositories of state  
- they are so much more than that.. Model each real world activity as  
an erlang process, and have each process maintain as much state as it  
needs to function as that real world process.

The API into the process would not typically be get/set operations,  
but real world calls like make_sale() or purchase(). It can all be at  
a much higher level using Erlang.

If you also follow the other advice in Ulf's post you will be getting  
there :-)

Sean




More information about the erlang-questions mailing list