Thanks a lot , Alex. So in order to working with defrecords , we have to use fully qualified name , or we can import them.
But the :require is needed before I can import the 'defrecord' classes.. [... :refer :all] will not import the classes.. On Thursday, September 11, 2014 10:46:17 PM UTC+8, Alex Miller wrote: > > Yeah, dt/Record1 is not a thing that is referenceable. > > dt/->Record1 is a constructor function > defrecord_example1.datatypes.Record1 is a class > > You can't use the ns alias dt to shorten the name of the class (those are > different naming contexts). > > > On Wednesday, September 10, 2014 8:44:18 PM UTC-5, Bin Li wrote: >> >> Yes , it is. >> >> Is it because that / is accessing the 'static' function/field ? so at >> core.clj: >> >> we can only have there constructors as follow ? >> >> dt/->Record1 >> dt/->Record2 >> dt/map->Record1 >> dt/map->Record2 >> >> On Wednesday, September 10, 2014 10:21:45 PM UTC+8, Alex Miller wrote: >>> >>> Is datatypes.clj at src/defrecord_example1/datatypes.clj ? (note _, not >>> - in directory name) >>> >>> >>> On Wednesday, September 10, 2014 6:01:25 AM UTC-5, Bin Li wrote: >>>> >>>> I have records defined at datatypes.clj: >>>> ```clojure >>>> (ns defrecord-example1.datatypes) >>>> >>>> (defrecord Record1 [f1]) >>>> >>>> (defrecord Record2 [f1 f2 f3]) >>>> >>>> ;; this is working at repl >>>> (def m-inside1 >>>> {Record1 >>>> (fn [] ({:a "A"})) >>>> Record2 >>>> (fn [] ({:n "B"}))}) >>>> >>>> And using at core.clj : >>>> ```clojure >>>> (ns defrecord-example1.core >>>> (:require >>>> [defrecord-example1.datatypes :as dt])) >>>> >>>> ``` >>>> >>>> ;; error at repl >>>> ;; CompilerException java.lang.RuntimeException: No such var: >>>> dt/Record1, compiling:(defrecord_example1\core.clj:7:1) >>>> (def m-in-core1 >>>> {dt/Record1 >>>> (fn [] ({:a "A"})) >>>> dt/Record2 >>>> (fn [] ({:n "B"}))}) >>>> >>>> ``` >>>> >>>> Any one can help on this ? >>>> My project.clj: >>>> ``` clojure >>>> (defproject defrecord-example1 "0.1.0-SNAPSHOT" >>>> :description "FIXME: write description" >>>> :url "http://example.com/FIXME" >>>> :license {:name "Eclipse Public License" >>>> :url "http://www.eclipse.org/legal/epl-v10.html"} >>>> :dependencies [[org.clojure/clojure "1.6.0"]]) >>>> >>>> ``` >>>> >>>> -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.