Hello, In an effort to learn a little more about clojure (and possibly introduce it at work) I decided to write a native client for the Beanstalk work queue. See http://kr.github.com/beanstalkd/ for more information about the queue and https://github.com/drsnyder/beanstalk for the client.
One of the decisions I wasn't sure about was whether to use a protocol or a struct map for the (socket, reader, writer) tuple. I started using a struct-map and then switched over to defprotocol/defrecord. See https://github.com/drsnyder/beanstalk/blob/82f301f1f825bb05aa14d85a220ec57c1dea61b2/src/beanstalk/core.clj#L117 for the definition. Is one preferred over the other (struct vs record)? Using the protocol +record idiom maps really well to the queue protocol-- you end up with statements like (.put object params), (.reserve object) etc which are very clear and intuitive from the developers perspective. It creates a one-to-one mapping to the beanstalkd protocol commands. If I were using a struct-map I might have methods like (beanstalk-put object params) etc. But one issue I encountered with defprotocol is that there appears to be a possible symbol table/space issue. When I compile, I get warnings like the following: Warning: protocol #'beanstalk.core/BeanstalkObject is overwriting function read Warning: protocol #'beanstalk.core/BeanstalkObject is overwriting function peek Warning: protocol #'beanstalk.core/BeanstalkObject is overwriting function use WARNING: read already refers to: #'clojure.core/read in namespace: beanstalk.core, being replaced by: #'beanstalk.core/read WARNING: peek already refers to: #'clojure.core/peek in namespace: beanstalk.core, being replaced by: #'beanstalk.core/peek WARNING: use already refers to: #'clojure.core/use in namespace: beanstalk.core, being replaced by: #'beanstalk.core/use WARNING: read already refers to: #'clojure.core/read in namespace: beanstalk.core-test, being replaced by: #'beanstalk.core/read WARNING: peek already refers to: #'clojure.core/peek in namespace: beanstalk.core-test, being replaced by: #'beanstalk.core/peek WARNING: use already refers to: #'clojure.core/use in namespace: beanstalk.core-test, being replaced by: #'beanstalk.core/use Is there something I'm can do to prevent these collisions aside from using a different name for the method? Thanks, Damon -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
