Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Problem with multimethods #1

Closed
chrisbetz opened this issue Jun 29, 2012 · 2 comments
Closed

Problem with multimethods #1

chrisbetz opened this issue Jun 29, 2012 · 2 comments

Comments

@chrisbetz
Copy link

Please check out this code in LightTable:

(defn dispatch-updates [entity-type & _] entity-type)

(defmulti updates dispatch-updates)

(defmethod updates :default [entity-type context known-versions & uids]
:anything-else
)

(defmethod updates :Edition [entity-type context known-versions & uids]
:asking-for-a-single-edition
)

(updates :Edition nil nil)

Results in

defn dispatch-updates [entity-type & _] entity-type)

(defmulti updates dispatch-updates)|| => nil||

(defmethod updates :default [entity-type context known-versions & uids]
:anything-else
)|| => clojure.lang.MultiFn@4f3e9f6f||

(defmethod updates :Edition [entity-type context known-versions & uids]
:asking-for-a-single-edition
)|| => clojure.lang.MultiFn@4f3e9f6f||

(updates :Edition nil nil)|| => :anything-else||

However, the call to (updates :Edition nil nil) should result in (and it does in any other Clojure 1.3 REPL) :asking-for-a-single-edition.

@twiddles
Copy link

Multi-method don't seem to work at the moment

(defmulti foo identity)
(defmethod foo 1 [_] :long)
(defmethod foo 2 [_] :longer)
(defmethod foo :default [_] :endless)
(foo 1) => :long
(foo 2) => :long
(foo 2) => :long

Whereas in the regular REPL the output is:

(defmulti foo identity)
(defmethod foo 1 [_] :long)
(defmethod foo 2 [_] :longer)
(defmethod foo :default [_] :endless)

(foo 1) => :long
(foo 2) => :longer
(foo 3) => :endless

@ibdknox
Copy link
Member

ibdknox commented Dec 13, 2012

This is fixed in the latest

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants