Objects as processes: Do you wrap message passing?
Joel Reymont
joelr1@REDACTED
Fri Apr 15 10:49:45 CEST 2005
Howdy!
I'm implementing objects as "active processes" /is that the term?/ and
all the method calls are handled in a dispatch loop like this:
dispatch(This) ->
receive
{ Pid, bet_size, _, _, Stage } ->
Pid ! { retval, bet_size(This, Stage) },
dispatch(This);
...
dispose ->
ok
end.
Then I invoke the object like this:
Limit = fixed_limit:new(10, 20),
Limit ! { self(), bet_size, 0, 0, preflop },
{ Low, High } = retrieve().
Do you usually add an extra layer on top of this by wrapping dispatch
functionality in a function? Is it better to add
bet_size(Limit, Foo, Bar, Stage) when pid(Limit) ->
Limit ! { self(), bet_size, Foo, Bar, Stage },
retrieve().
and then call
fixed_limit:bet_size(Limit, ...)
Thanks, Joel
--
http://wagerlabs.com/tech
More information about the erlang-questions
mailing list