Re: dispatching on a resulting range

2010-12-23 Thread David Nolen
On Wed, Dec 22, 2010 at 9:40 PM, Alex Baranosky < alexander.barano...@gmail.com> wrote: > Hi > > I've been playing with multimethods, and trying to see if there was a way > to dispatch on a non-specific result of the dispatching function, such as a > range, like this: > > (defn how-to-move [map1 m

Re: dispatching on a resulting range

2010-12-23 Thread Alyssa Kwan
I completely disagree. If arbitrary load order were sufficient, there wouldn't be (prefer-method). (And CL wouldn't have a complex heuristic for ordering.) In reality, you may be extending someone else's library by calling (defmethod) on their (defmulti). And you could be using someone else's l

Re: dispatching on a resulting range

2010-12-23 Thread Ken Wesson
On Thu, Dec 23, 2010 at 1:37 PM, Jay Fields wrote: > 2010/12/23 Ken Wesson  >> >> It most certainly is not. > > Yes, it is. Is not! >> Unlike cond clauses, methods might be >> scattered in different parts of a large code base > > _might_ be. But they don't need to be. It suffices for my argumen

Re: dispatching on a resulting range

2010-12-23 Thread Jay Fields
2010/12/23 Ken Wesson > It most certainly is not. > Yes, it is. > Unlike cond clauses, methods might be > scattered in different parts of a large code base _might_ be. But they don't need to be. I'd rather group my methods, know what I'm doing, and have to configure less. Anything that requi

Re: dispatching on a resulting range

2010-12-23 Thread Ken Wesson
On Thu, Dec 23, 2010 at 8:51 AM, Jay Fields wrote: > Ken said: > "That seems sucky. What about adding a priority parameter to your > defmethod-analogue? The predicates are kept sorted by priority." > I disagree. To use your terms, I think your solution is equally "sucky". It most certainly is not

Re: dispatching on a resulting range

2010-12-23 Thread Jay Fields
Ken said: "That seems sucky. What about adding a priority parameter to your defmethod-analogue? The predicates are kept sorted by priority." I disagree. To use your terms, I think your solution is equally "sucky". Sometimes adding config parameters makes sense and sometimes it adds noise. In th

Re: dispatching on a resulting range

2010-12-22 Thread Sunil S Nandihalli
yea Ken I agree with you.. but it was just an exercise .. you could definitely add a priority option to every method.. Thanks for your comments.. besides the code was tested.. Sunil. On Thu, Dec 23, 2010 at 11:45 AM, Ken Wesson wrote: > On Thu, Dec 23, 2010 at 1:09 AM, Ken Wesson wrote: > > An

Re: dispatching on a resulting range

2010-12-22 Thread Ken Wesson
On Thu, Dec 23, 2010 at 1:09 AM, Ken Wesson wrote: > An untested implementation: Yeah, there's a bug or two. > (def qlzqqlzuup (Object.)) > > (defmacro my-defmulti [name] >  `(def name Should be ~name. >     (let [dtable (atom (sorted-map))] Should be dtable#, and likewise the rest of the loc

Re: dispatching on a resulting range

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 11:36 PM, Sunil S Nandihalli wrote: > the caveat is that the order in which you specify the methods would matter > .. since that is the order in which it is going to check for the appropriate > method to call.. Just like condp again. That seems sucky. What about adding a p

Re: dispatching on a resulting range

2010-12-22 Thread Sunil S Nandihalli
the caveat is that the order in which you specify the methods would matter .. since that is the order in which it is going to check for the appropriate method to call.. Just like condp again. On Thu, Dec 23, 2010 at 10:04 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hi Alex, >

Re: dispatching on a resulting range

2010-12-22 Thread Sunil S Nandihalli
Hi Alex, I have come across a similar need and I wrote the following macro which dispatches in a style similar to condp which can achieve what you are asking for .. https://gist.github.com/752567 basically instead of just having the dispatch-fn apply only on the

dispatching on a resulting range

2010-12-22 Thread Alex Baranosky
Hi I've been playing with multimethods, and trying to see if there was a way to dispatch on a non-specific result of the dispatching function, such as a range, like this: (defn how-to-move [map1 map2] (+ (:cats map1) (:dogs map2))) (defmulti move how-to-move) (defmethod move 1 [map1 map2] (