I have several maps with different combinations of keys for each map. I
want to process each map but do different work depending on the set of keys
available, basically dispatch on key availability. I thought clojure.spec
might be a good fit for doing the classification step. So for each key, I
could define a spec. Next, I would use clojure.spec.alpha/keys to define a
spec for each set of keys I'd like to match. Finally, I would dispatch like
so:
(fn [m]
(condp clojure.spec.alpha/valid? m
::foo-map-spec :do-foo-stuff
::bar-map-spec :do-bar-stuff))
Does this seem reasonable?
The advantage in my mind is its thorough, explicit, and easy to read.
Possible downsides is performance if it mattered.
What are the advantages/disadvantages to this approach compared to other
methods?
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.