Re: Surprising behaviour related to records, protocols and AOT
I guess extend-type does changes only to generated java class and the var defrecordissue.arecord-ARecord contains the 'old' version of ARecord constructor. Obviously it would be weird for defprotocol to change the variable in another namespace. Especially when you can extend a record from anywhere. So If you want to create a record that implements your protocol via var from record namespace, you should do some hackery to update that variable. I've done a pull-request for you, but using direct constructor will be more idiomatic ; ; this won't work unless you update manualy a variable -ARecord in the namespace ; ;(defrecordissue.aprotocol/afn (defrecordissue.arecord/-ARecord)) ; ; like (defmacro from-ns[nmsps body] launches body from namespace `(binding [*ns* (find-ns ~nmsps)] (eval (quote (do ~@body) (from-ns 'defrecordissue.arecord (import '(defrecordissue.arecord.ARecord)) (alter-var-root ('-ARecord (ns-publics 'defrecordissue.arecord)) (fn[x] (fn[] (new ARecord) (println (defrecordissue.aprotocol/afn (defrecordissue.arecord/-ARecord))) ; 42 ndrw -- -- 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/groups/opt_out.
Re: Surprising behaviour related to records, protocols and AOT
I guess you have to import defrecord generated class before you want to use it, check the sample from clojuredocs about defrecord ; If you define a defrecord in one namespace and want to use it ; from another, first require the namespace and then import ; the record as a regular class. ; The require+import order makes sense if you consider that first ; the namespace has to be compiled--which generates a class for ; the record--and then the generated class must be imported. ; (Thanks to raek in #clojure for the explanations!) ; Namespace 1 in my/data.clj, where a defrecord is declared (ns my.data) (defrecord Employee [name surname]) ; Namescape 2 in my/queries.clj, where a defrecord is used (ns my.queries (:require my.data) (:import [my.data Employee])) (println Employees named Albert: (filter #(= Albert (.name %)) [(Employee. Albert Smith) (Employee. John Maynard) (Employee. Albert Cheng)])) -- -- 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/groups/opt_out.
Re: documentation for clojure core extension points - multimethods and protocols?
I guess you should just grep clojure core source for defprotocol, defmulti and so on. -- -- 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/groups/opt_out.