Hello group, First I'd like to thank Rich for such a great new tool. The assertion in Programming Clojure that it "feels like a general-purpose language beamed back from the near future" really sums things up very nicely. Homoiconicity + FP + STM + JVM = epic win.
Anyway, thought I'd say hi, and solicit opinions on my first "non- trivial" (that's a relative term ;)) Clojure program, a toy server which opens a listening socket and prints a message to each connecting client: ;;; (ns seq-server #^{:author "Ross Thomas <halfacan...@gmail.com>"} (:import (java.net ServerSocket))) (def listen-port 8555) (def num-agents 32) (def message "Hello, world!\r\n") (def server-sock (ServerSocket. listen-port)) (def clients (repeatedly #(.accept server-sock))) (def agent-pool (take num-agents (repeatedly #(agent nil)))) (def agents (cycle agent-pool)) (def work-seq (map vector clients agents)) (declare handle-client) (defn run [] (doseq [[c a] work-seq] (send-off a handle-client c))) (defn handle-client [_ client] (.. client getOutputStream (write (.getBytes message))) (doto client .shutdownInput .shutdownOutput .close)) (run) ;;; I can't decide if doing it that way is a bit too weird or not, but it was fun to write. Anyway, interested to hear comments/criticisms, how I could make it more idiomatic, etc. :) -Ross -- 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