> It's impossible to redefine the dispatch function within
>  the definition of the multimethod after the first call to 'defmulti'. 

That is a funny way to word it. I think you are saying that there is no way 
to have the multiple arities? 




On Wednesday, September 30, 2015 at 8:45:25 PM UTC-4, Gary Trakhman wrote:
>
> It works for me, for '(intent {} "yes" :yes "WAT")'
>
> I get the error: IllegalArgumentException No method in multimethod 
> 'intent' for dispatch value: WAT  clojure.lang.MultiFn.getFn 
> (MultiFn.java:156)
>
> You're probably being bitten by a different issue.  It's impossible to 
> redefine the dispatch function within the definition of the multimethod 
> after the first call to 'defmulti'.  In order to do so, you would have to 
> first ns-unmap that var.
>
> An alternative for development is to use the dispatch function's Var as 
> the dispatch function:
> (defn intent-dispatch [& args]
>     (apply discern args))
> (defmulti intent #'intent-dispatch)
>
>
> On Wed, Sep 30, 2015 at 8:33 PM Lawrence Krubner <lawr...@rollioforce.com 
> <javascript:>> wrote:
>
>> For maximum flexibility I wanted to use a multimethod, defined like this: 
>>
>>
>> (defmulti intent
>>   (fn [& args]
>>     (apply discern args)))
>>
>> This is how discern is defined: 
>>
>> (defn- discern
>>   
>>   ([this-users-conversation]
>>    {:pre [(map? this-users-conversation)]}
>>    (:intent this-users-conversation)) 
>>
>>   ([this-users-conversation salesforce-object-name]
>>    {:pre [(map? this-users-conversation)
>>           (string? salesforce-object-name)]}
>>    (:intent this-users-conversation))
>>
>>   ([this-users-conversation salesforce-object-name name-of-attribute]
>>    {:pre [(map? this-users-conversation)
>>           (string? salesforce-object-name)
>>           (string? name-of-attribute)]}
>>    (:intent this-users-conversation))
>>
>>   ([this-users-conversation salesforce-object-name name-of-attribute 
>> name-of-intent]
>>    {:pre [(map? this-users-conversation)
>>           (string? salesforce-object-name)
>>           (keyword? name-of-attribute)
>>           (string? name-of-intent)]}
>>    name-of-intent))
>>
>> but then I call the multimethod like this:
>>
>> (intent this-users-conversation "Opportunity" :Name 
>> "query-salesforce-for-attribute")
>>
>> and I get: 
>>
>> :class clojure.lang.ArityException,
>> :message "Wrong number of args (4) passed to: query/fn--65",
>>
>> Should I give up on this idea, or is there a way to make this work? 
>>
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> 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 clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to