On Mon, Dec 8, 2008 at 3:40 PM, J. McConnell <[EMAIL PROTECTED]> wrote:
>
> Attached is a patch that adds doc-string and metadata support to
> defmulti. It does not generate arglists metadata automatically like
> defn does since the arglists are not supplied in the defmulti form as
> they are in defn. One possibility would be to see if the dispatch
> function has an :arglists entry in its metadata and use that if it
> does, but I did not include that here since it opens up the
> possibility that the :arglists and :doc entries could get out of sync.
>
> Below is a sample usage of the new doc-string support. I'd be
> interested to hear people's thoughts.
This is a breaking change for some (granted rather unsual) cases:
(defmulti foo {:a 1 :b 2})
(defmethod foo 1 [_] "got a1")
(defmethod foo 2 [_] "got b2")
Before patch:
user=> (foo :a)
"got a1"
user=> (foo :b)
"got b2"
After patch:
user=> (foo :a)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (foo :b)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
You can see what happened to our dispatch map:
user=> ^#'foo
{:tag clojure.lang.MultiFn, :name foo, :file "NO_SOURCE_FILE", :ns
#<Namespace user>, :line 1, :b 2, :a 1}
I'm not offering an opinion here on whether or not it's a good patch,
just wanted to point out it changes currently defined behavior.
--Chouser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---