Christian,

defmulti has defonce-like semantics which I guess is to prevent the
associated defmethods from being wiped out when the form is recompiled.

Cite -
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L1622

-BG


On Wed, Nov 21, 2012 at 11:45 PM, Christian Sperandio <
[email protected]> wrote:

> Thank you !
> I became crazy because I didn't see the problem in my code.
>
> Why is there this issue with multi-methods? (and not with standard
> functions)
>
>
> Chris
>
> Le 22 nov. 2012 à 02:34, grinnbearit <[email protected]> a
> écrit :
>
> Hi Chris,
>
> If you change multimethod arities you'll have to def the multimethod to
> nil or restart the swank/nrepl server. It doesn't update that on
> recompilation.
>
> Sidhant
>
> On Thursday, November 22, 2012 3:44:10 AM UTC+5:30, Christian Sperandio
> wrote:
>>
>> Hi,
>>
>> I try to define multi-methods but when I call one I get an exception.
>>
>> I declared the multi-methods like below:
>>
>> (defmulti new-food-item (fn [food expiration]
>>                           (if (number? expiration)
>>                             ::duration
>>                             ::expiration-date)))
>>
>> (defmethod new-food-item ::duration [food expiration-duration]
>>   (let [expiration-date (GregorianCalendar.)]
>>     (.add expiration-date GregorianCalendar/DAY_OF_MONTH
>> expiration-duration)
>>     {:name food :expiration-date expiration-date}))
>>
>> (defmethod new-food-item ::expiration-date [food expiration-date]
>>   {:name food :expiration-date expiration-date})
>>
>>
>> And when I do: (new-food-item "tomatoes" 5)
>> I get this exception:
>> ArityException Wrong number of args (2) passed to: core$class
>>  clojure.lang.AFn.throwArity (AFn.java:437)
>>
>> I don't understand where is the problem :/
>>
>> Some help?
>>
>> Thank you.
>>
>> Chris
>>
>>  --
> 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 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
>



-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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

Reply via email to