Aw: Creating a Clojure Record from a string

2011-08-24 Thread Meikel Brandmeyer (kotarak)
Hi, maybe you just want a factory? (defrecord Foo [a b]) (defn make-Foo [a b] (Foo. a b)) (defn make [^String class args] (let [last-dot (.lastIndexOf class \.) factory (ns-resolve (symbol (subs class 0 last-dot)) (symbol (str make- (subs class (inc last-dot)] (when

Creating a Clojure Record from a string

2011-08-23 Thread Timothy Baldridge
Given: test=(defrecord Foo [A B]) test=(class (Foo. 1 2)) test.Foo How do I: test=(new test.Foo 1 2) #:test.Foo{:A 1, :B 2} Currently I get Unable to resolve classname: test/Foo. Thanks, Timothy -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no

Re: Creating a Clojure Record from a string

2011-08-23 Thread Stuart Halloway
Given: test=(defrecord Foo [A B]) test=(class (Foo. 1 2)) test.Foo How do I: test=(new test.Foo 1 2) #:test.Foo{:A 1, :B 2} Currently I get Unable to resolve classname: test/Foo. Thanks, Timothy (Class/forName java.lang.String) Be mindful of the performance... Stu

Re: Creating a Clojure Record from a string

2011-08-23 Thread Craig Andera
Given: test=(defrecord Foo [A B]) test=(class (Foo. 1 2)) test.Foo How do I: test=(new test.Foo 1 2) #:test.Foo{:A 1, :B 2} Currently I get Unable to resolve classname: test/Foo. Check out

Re: Creating a Clojure Record from a string

2011-08-23 Thread Craig Andera
(Class/forName java.lang.String) Oh, does that work in 1.3? Because (new (Class/forName user.Foo)) was the first thing I tried (under 1.2) and it doesn't work. Perhaps unsurprisingly given that new is a special form. -- You received this message because you are subscribed to the Google Groups

Re: Creating a Clojure Record from a string

2011-08-23 Thread Alan Malloy
On Aug 23, 3:39 pm, Craig Andera cand...@wangdera.com wrote: (Class/forName java.lang.String) Oh, does that work in 1.3? Because (new (Class/forName user.Foo)) was the first thing I tried (under 1.2) and it doesn't work. Perhaps unsurprisingly given that new is a special form. No. But you

Re: Creating a Clojure Record from a string

2011-08-23 Thread rfhayashi
test= (def foo-class-symbol (load-string test.Foo)) test= (def foo (eval (list 'new foo-class-symbol 1 2))) test= foo #:test.Foo{:A 1, :B 2} Is that what you want? On Aug 23, 6:24 pm, Timothy Baldridge tbaldri...@gmail.com wrote: Given: test=(defrecord Foo [A B]) test=(class (Foo. 1 2))