Re: ns :import / reflection
Yes, that did the trick. Thank you. Am 21.02.2012 02:53, schrieb Sean Corfield: On Sat, Feb 18, 2012 at 1:29 PM, ClusterCatcluster...@mail.com wrote: (ns test (:import (java.io File))) This says import the File class from the package java.io (ns test (:import (java.io.File))) Try: (ns test (:import java.io.File)) (let [filename (first *command-line-args*)] (println filename) (let [file (File. filename)]))) I get an Reflection warning, X:\workspace\ClojureTest\bin\test.clj:9 - call to java.io.File ctor can't be resolved. which I also don't understand. Clojure relies on type hints to avoid reflection - introspecting Java class types to figure out calls. If you add ^String in let binding for filename, it should remove the warning: (let [^String filename (first *command-line-args*)] ... HTH? -- 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
Re: ns :import / reflection
Wrong type of parens! This works for me: (ns test (:import [java.io File])) it's a bit of a gotcha, though. /Linus On 2/18/12 10:29 PM, ClusterCat wrote: Hello, I have two newbie questions: First - (ns test (:import (java.io File))) I can use File like this (let [file (File. filename)]))) When using this import (ns test (:import (java.io.File))) I get an Unable to resolve classname: File which I don't understand. Second -- With this small piece of code (ns test (:import (java.io File))) (set! *warn-on-reflection* true) (if (nil? *command-line-args*) (println No command line arguments given.) (let [filename (first *command-line-args*)] (println filename) (let [file (File. filename)]))) I get an Reflection warning, X:\workspace\ClojureTest\bin\test.clj:9 - call to java.io.File ctor can't be resolved. which I also don't understand. Thanks in advance, Marcel -- 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
Re: ns :import / reflection
On Sat, Feb 18, 2012 at 1:29 PM, ClusterCat cluster...@mail.com wrote: (ns test (:import (java.io File))) This says import the File class from the package java.io (ns test (:import (java.io.File))) Try: (ns test (:import java.io.File)) (let [filename (first *command-line-args*)] (println filename) (let [file (File. filename)]))) I get an Reflection warning, X:\workspace\ClojureTest\bin\test.clj:9 - call to java.io.File ctor can't be resolved. which I also don't understand. Clojure relies on type hints to avoid reflection - introspecting Java class types to figure out calls. If you add ^String in let binding for filename, it should remove the warning: (let [^String filename (first *command-line-args*)] ... HTH? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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