Re: defmulti and defmethods in separate namespaces without circular references?

2012-03-02 Thread Daniel E. Renfer
I use a lot of multimethods with my framework, Ciste[0] and it can work, the only thing is you have to be very careful about what you put where, and it helps to have a lot of namespaces. What I do is try to keep all of my defmulti's in one namespace and have only defmethod's in another namespace.

Re: defmulti and defmethods in separate namespaces without circular references?

2012-03-02 Thread Cymen Vig
On Friday, March 2, 2012 7:03:10 AM UTC-6, tim.visher wrote: > > I will not in any way claim to know how or why this works. I'm just > starting to use multimethods myself, but I'll give you my set up that > appears to be working at the moment. > > I have a namespace: > > (ns store.store) > >

Re: defmulti and defmethods in separate namespaces without circular references?

2012-03-02 Thread lambdatronic
I built a modeling system that uses the multi-method namespace separation you are talking about. The solution that I use simply leverages the difference between require, use, and refer. In each namespace that implements the multi-method, put (refer 'parent) after the ns form. In the parent name

Re: defmulti and defmethods in separate namespaces without circular references?

2012-03-02 Thread Tim Visher
On Thu, Mar 1, 2012 at 8:33 PM, Cymen Vig wrote: > I attempted to do something like this: > > (ns parent) > (defmulti my-method (fn [x] (:method x)) > > (ns child1) > (defmethod my-method :zzz >   ...) > > (ns child2) > (defmethod my-method :aaa >   ...) > > However the problem is the children nee

defmulti and defmethods in separate namespaces without circular references?

2012-03-01 Thread Cymen Vig
I attempted to do something like this: (ns parent) (defmulti my-method (fn [x] (:method x)) (ns child1) (defmethod my-method :zzz ...) (ns child2) (defmethod my-method :aaa ...) However the problem is the children need to use the parent namespace in order to have the method definition and

Re: circular references

2010-12-29 Thread Todd
a reference (pointer) to ref1 user=> (dosync (ref-set aref2 {:a aref1})) {:a # {:java.lang.StackOverflowError 4. So, I've got a stack overflow... What's the proper way to deal with this? Are circular references like this not allowed? Circular references are allowed, the problem is with

Re: circular references

2010-12-29 Thread Ken Wesson
ror >> >> >> >> 4. So, I've got a stack overflow... What's the proper way to deal with >> this? Are circular references like this not allowed? > > Circular references are allowed, the problem is with the repl trying to > print them.  You can set the

Re: circular references

2010-12-29 Thread Alex Osborne
Todd writes: > 3. alter ref2 to have a reference (pointer) to ref1 > > user=> (dosync (ref-set aref2 {:a aref1})) > {:a # # # # > > > {:java.lang.StackOverflowError > > > > 4. So, I've got a stack overflow... What's the proper way to deal with

Re: circular references

2010-12-29 Thread Mark Engelberg
Just a guess here, but it sounds like the infinite loop is in the printing, because you entered this in at the REPL, and not a problem with the actual creation of the circular reference. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

circular references

2010-12-29 Thread Todd
Are circular references supported in clojure? 1. create two refs user=> (def aref1 (ref {})) #'user/aref1 user=> (def aref2 (ref {})) #'user/aref2 user=> aref1 # user=> aref2 # 2. alter ref1 to have a reference to ref2 user=> (dosync (ref-set aref1 {:a aref2})) {:a