I am writing some software that is essentially an interpreter for 
structures called plans, which are either:

- steps, maps that have a specific way of handling them based on their 
:type. Examples include e.g. make a http request, which would look like 
{:type :http :url "http://whatever"; :method :put}.
- sets of plans (recursive)
- vectors of plans (recursive)

So, eventually, it's steps at the "leaves", and then there's a recursive 
tree-like structure organizing them (except that some branches are ordered, 
and some are unordered).

For example:

[#{{:type :x :temperature 30}
   {:type :y :color "#dfcdfc"}}
 {:type :log :message "Success!"}]

... which means "do :x with temperature 30 and :y with color #dfcdfc 
concurrently. When you're done with both, log a success message.". It's a 
little trickier than that (failure etc), but that's the gist of it.

Right now, I'm doing this with a multimethod. Dispatching happens based on 
if it's a set, vector or a step:

  (fn [x] (cond (set? x) ::unordered-plans
               (vector? x) ::ordered-plans
               :else (:type x)))

That works, but implementations are in different namespaces, so I find 
myself requiring namespaces for the side-effect. It works, but it's not 
great. I guess maybe I'm abusing multimethods. Additional considerations:

- I would like to not have to manage a manual list of things I'm 
:require-ing, but instead just automagically :require all the stuff in 
myproject.handlers.* namespaces.
- I would like people to be able to write their own implementations; so I 
guess I need to be able to namespaces as configuration as well.
- I *think* I want these handlers to be configurable so that people can 
choose to drop support for some of them, in which case "works if it has 
been :require'd" sounds like it maybe isn't the best API.

Any guidance is appreciated. Maybe I should make it register all 
*available* handlers in an atom-wrapped map internally, or something.

thanks in advance,
lvh

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to