Hello,

I'm trying to create a "factory" method for Java classes, however I'm
doing something wrong.

(import '(java.util Dictionary HashMap))

(def *containers* { :dict Dictionary :hash HashMap})
(defn new-container
  [type]
  (new (*containers* type)))

(def d (new-container :dict))

The above gives me
Exception in thread "main" java.lang.IllegalArgumentException: Unable
to resolve classname: (*containers* type) (t.clj:6)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4599)
        at clojure.lang.Compiler.analyze(Compiler.java:4405)
        at clojure.lang.Compiler.analyze(Compiler.java:4366)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3942)
        at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3777)
        at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3654)
        at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3024)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4590)
        at clojure.lang.Compiler.analyze(Compiler.java:4405)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4580)
        at clojure.lang.Compiler.analyze(Compiler.java:4405)
        at clojure.lang.Compiler.access$100(Compiler.java:35)
        at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:373)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4592)
        at clojure.lang.Compiler.analyze(Compiler.java:4405)
        at clojure.lang.Compiler.analyze(Compiler.java:4366)
        at clojure.lang.Compiler.eval(Compiler.java:4646)
        at clojure.lang.Compiler.load(Compiler.java:4972)
        at clojure.lang.Compiler.loadFile(Compiler.java:4939)
        at clojure.main$load_script__7423.invoke(main.clj:211)
        at clojure.main$script_opt__7460.invoke(main.clj:263)
        at clojure.main$main__7484.doInvoke(main.clj:338)
        at clojure.lang.RestFn.invoke(RestFn.java:413)
        at clojure.lang.Var.invoke(Var.java:359)
        at clojure.lang.AFn.applyToHelper(AFn.java:173)
        at clojure.lang.Var.applyTo(Var.java:476)
        at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Unable to resolve
classname: (*containers* type)
        at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2243)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4592)
        ... 26 more

What is the right way to do this?

Thanks,
--
Miki

-- 
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

Reply via email to