Hi, This is probably digressing a little from the original question but I was wondering if using namespaces here is a reasonable thing to do when designing ADTs.
> SICP tells us that we should be defining accessor functions > immediately when we create a new data type. > > (defn make-fraction [n d] {:numerator n :denominator d}) > (defn fraction-numerator [f] (:numerator f)) > (defn fraction-denominator [f] (:denominator f)) Couldn't you define the functions like so: (ns fraction) (defn make [n d] {:numerator n :denominator d}) (defn numerator [f] (:numerator f)) (defn denominator [f] (:denominator f)) And then from outside the namespace call (def f (fraction/make 1 2)) (fraction/numerator f) ; => 1 This seems to me to be a fairly clean way to encapsulate an ADT and it doesn't cost any more characters than the prefix style of naming functions. Regards, Mark. -- http://mark.reid.name --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---