> and perl has closure, so it looks commute uses closure concept
> > > My question is that conj takes two argument and how conj finds
> > > the first argument? Is it somehow provided by commute?

commute is passed conj as a function.
commute then calls conj messages msg,
and sets messages to be the result (which is messages with msg added
on)

There is a more in-depth example at
http://en.wikibooks.org/wiki/Clojure_Programming/Concepts
(defn add-employee [e]
  "add new employee e to employee-records"
  (dosync (commute employee-records conj e)))

commute: At the commit point of the transaction, sets the value of ref
to be:
(apply fun most-recently-committed-value-of-ref args)

ie: (commute messages conj msg)
means: messages = apply conj messages msg

No closures involved.


Regards,
Tim.
--~--~---------~--~----~------------~-------~--~----~
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
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