[erlang-questions] Erlang modelling question

Olivier Boudeville <>
Sun Jun 24 23:52:12 CEST 2007


Yes, this was what I was thinking at, at least at first.

4 cases of incoming messages : two types of requests (regular or oneway,
hence with the sender PID or not), with or without parameters (with an
atom to discriminate ambiguous cases if needed), and between 0 and n
"default handlers" in case this per-class handler does not specify what
to do. Default handlers could be seen by POO-fans as superclasses.
Actually such a full-blown solution could be almost found from various
sources.

But at first I will (try to) keep it simpler, just to know if it may be
worth the trouble doing so !

Thanks for your help,

Olivier.

Val Functor a écrit :
> On 6/23/07, *Olivier Boudeville* <
> <mailto:>> wrote:
>
>     How such a problem could be mapped into Erlang concepts ? How
>     would you
>     model the situation, knowing that each creature can live, move and
>     die,
>     that mammals are indeed specialized creatures that have backbones, and
>     that dogs are specialized mammals with four legs and a tail ?
>
>     What I would like is to avoid the developer having to hardcode by
>     himself the implied inheritance between actors : when adding a cat in
>     the simulation, I would like to specify 1. it is a specialized
>     mammal,
>     2. what are its specific traits, but not that a cat has a backbone and
>     it can live, move and die.
>
>
> A cat is a modeled by a process.
> A cat can only: receive messages, to which it can only either reply or
> not.
> If it knows how to reply to a message it does so.
> If it does not know, but knows of some other process who could know,
> it forwards the incoming message there and the reply, if any, to the
> original requester.
> If it does not know, and does not know who else to ask, it either does
> not reply or it does reply 'i do not know'.
>
> The creator of the cat would pass it knowledge about where to send
> messages it does not know how to handle
>
>



More information about the erlang-questions mailing list