On 6/11/2011 12:56, pron wrote:
E.g., one developer may add a keyword to a map for one purpose, and another, use the same keyword for a different purpose. With classes, all data manipulation for a single type is located in one place, so such clashes can easily be prevented, let alone the fact that encapsulation helps delineate legal operations with the data.

One way to encapsulate things in clojure is namespaces. For this specific example you gave there, one might use namespace qualified keywords to add some data to your map. This way name clashes are only possible when you want them. I am actually using that very technique to add application (and namespace) specific data to the request map from a ring (web) application as it is passed further down through different namespaces during the routing of the request. Namespaces can have private vars and functions as well.

The documented interfaces mentioned by Daniel are very useful too, protocols are providing this functionality. Though i must confess I sometimes still use multimethods to that effect =)

In my opinion, far from being a weakness, programming in the large is a strong point of clojure.

Sacha


--
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