Hi Nils,

A while back, I also took a stab* at implementing Erlang-style actors in 
Clojure, along with solutions for a few classic concurrency problems 
(Dining Philosophers, Sleeping Barber).  I was blown away by how easy it 
was to implement actor semantics on top of agents.

Comparing our respective efforts, I see a lot of room for improvement in 
mine :)  I like how your actors send messages containing the address of the 
recipient, which seems truer to the actor model.  Also, you raise a great 
point regarding pattern matching; I think that can greatly simplify the 
message handlers in my code.  Looks like it's time for me to get acquainted 
with core.match :)

Thanks for the food for thought!

*https://github.com/bitsai/clojure-actors

On Friday, December 2, 2011 1:17:43 PM UTC-7, Nils Bertschinger wrote:
>
> Hi,
>
> how do Clojure agents relate to Erlang actors?
> To gain some insights, I tried to implement Erlang style message
> passing between agents. The first version is just a very incomplete
> sketch (no mailbox, case instead of pattern matching ...), but already
> shows that it is quite easily doable:
> https://github.com/bertschi/clojure-stuff/blob/master/src/stuff/actors.clj
>
> The idea is that the agent holds a dispatch function which is then
> called by ! (send) with the message to be send. Somehow it resembles
> the way closures can be used to implement an object system. Thus,
> agents seem to be the functional analog of agents:
>                     Functional programming         Object-oriented
> programming
> sequential              closure
> object
> concurrent               agent
> actors
>
> Another great design from Rich Hickey! Clojure is fun and gets better
> every day ...
>
> Thanks,
>
>     Nils
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to