Hello everyone, I have spent a few days implementing a client library for Redis (http://code.google.com/p/redis/), a key value storage system, that is slightly more than 'just' a key value storage system.
My Lisp experience before Clojure is basically limited to a couple of hundred lines of ELISP code for my Emacs setup, so the Lisp way of thinking, and associated concepts, patterns and so on, is really new to me. This is my first real Clojure project and I would be very grateful for feedback on everything from overall design, style and nomenclature to misspelled comments. Some things are not yet implemented, most notably the "SORT" command. I felt I needed som feedback before proceeding any further. The source code can be found on github at: http://github.com/ragnard/redis-clojure Also, I have two questions (actually, I have many, these two came to my mind): I decided I wanted the functions that perform Redis commands to have the same name as the command. For example, the command to check if a key exists is: "EXISTS key" Therefore, I wanted the corresponding clojure function to be: (exists "key") This turned out to be problematic since a couple of the commands have the same names as some clojure.core functions, most notably get and set. I solved this by checking if *ns* already contained a mapping for the name, and if so, ns-unmap:ing it. To use the functions, you would then have to (require 'redis), ie. not :use, and call them namespace qualified, ie. (redis/get "key") (redis/set "key" "value") First question: Is this a bad idea? How should you generally solve function name clashes? In this case, I really wanted to have the same name, not "redis-get" or something similar. Second question: I tried AOT compiling my library, and packaging the class files into a JAR (check build.xml, jar target). However, when I try to use JAR file and (require 'redis) I get the following exception: Caused by: java.lang.IllegalStateException: keys already refers to: #'redis/keys in namespace: redis at clojure.lang.Namespace.reference(Namespace.java:86) at clojure.lang.Namespace.refer(Namespace.java:109) at clojure.core$refer__4345.doInvoke(core.clj:2433) at clojure.lang.RestFn.invoke(RestFn.java:415) at redis$loading__5572__auto____1.invoke(redis.clj:3) at redis__init.load(Unknown Source) at redis__init.<clinit>(Unknown Source) If I only package the clj files (not class files), it works. This is what build.xml currently does. Best regards, Ragnar Dahlén --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---