Re: Nested Multimethods

2008-10-14 Thread mb
Hello, On 14 Okt., 16:58, Randall R Schulz <[EMAIL PROTECTED]> wrote: > I have heard it claimed (on one of the Scala lists, I think) > that patterns themselves are an anti-pattern... I think there are always patterns. They are just different. In Clojure there is maybe the "Driver Function" patte

Re: Nested Multimethods

2008-10-14 Thread CuppoJava
That's a very elegant solution Rich. I'm so obvious when someone tells you how to do it. Clojure amazes me more every day. All the painfully accumulated knowledge of Java design patterns are so trivial in Clojure. It doesn't even seem like there's any need for design "patterns" at all anymore cau

Re: Nested Multimethods

2008-10-14 Thread Randall R Schulz
On Tuesday 14 October 2008 07:48, CuppoJava wrote: > That's a very elegant solution Rich. I'm so obvious when someone > tells you how to do it. > > Clojure amazes me more every day. All the painfully accumulated > knowledge of Java design patterns are so trivial in Clojure. It > doesn't even seem

Re: Nested Multimethods

2008-10-14 Thread Rich Hickey
On Mon, Oct 13, 2008 at 11:14 PM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > Hi Patrick, > > How about: > > (defmulti length (fn [x] > (if (= :stateMachine (:class x)) >(:state x) >(:class x > > (defmethod length :yardstick [x] 36)

Re: Nested Multimethods

2008-10-14 Thread Rich Hickey
On Oct 13, 11:01 pm, CuppoJava <[EMAIL PROTECTED]> wrote: > Is there anyway to do the following with the existing multi-method > facilities? > > There is a general multi-method length(object) that splits off to > different methods depending on the :class of the object. > > And then specifically

Re: Nested Multimethods

2008-10-13 Thread Stuart Halloway
Hi Patrick, How about: (defmulti length (fn [x] (if (= :stateMachine (:class x)) (:state x) (:class x (defmethod length :yardstick [x] 36) (defmethod length :walking [x] "short") (defmethod length :running [x] "long") user=> (lengt

Nested Multimethods

2008-10-13 Thread CuppoJava
Is there anyway to do the following with the existing multi-method facilities? There is a general multi-method length(object) that splits off to different methods depending on the :class of the object. And then specifically for objects with :class = :stateMachine, I want to define it's method to