First, an aside: I was pleasantly surprised to find that the defmulti
dispatch function could itself be polymorphic. Well, surprised isn't
the right word - I half expected it to work. But it's always nice when
new tools follow POLA.
Which leads to a question where Clojure doesn't seem to follow POLA. I
want to have a multimethod dispatch on structure types. Specifically,
if I define two structures:
(defstruct A :a :b :c)
(defstruct B :b :d :e)
I want a multimethod that uses different methods for A & B. I'd *like*
to be able to write them like:
(defmethod meth A ...)
(defmethod meth B ...)
That doesn't seem to be possible - I can't find a function that
accepts a PersistentStructMap and returns the symbol passed to struct
so it knows the keylist to use for the arguments. Nor could I find the
magic incantation to let me use those symbol names with derive, which
would let me use keywords for them. I got something working by having
the dispatch function use sets of keys from the maps, but that seems
fragile. Writing defFOO and FOO macros that attached the appropriate
metadata to each struct seem possible, but sorta ugly.
Anyone got a suggestion here?
Thanks,
<mike
--
Mike Meyer <[email protected]> http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
--
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