Here's another bit of strangeness. I tried putting my interfaces file at the root (see https://github.com/migae/datastore/tree/master/src/clojure); this seems to work ok. Then I fooled around with profiles etc. to try to avoid having Interfaces.clj ever be reloaded - it's only needed once, for aot compilation. So I created src/clj-compile/Interfaces.clj, configured a profile to compile that and excluded it from the :dev profile; even though it is in clj-compile, it generates class files in src/clojure. Then I compile once, and when I start the repl the Interfaces.clj file is not touched. Seemed to work ok - but the dynamic reloading stopped working. BTW the deftype files that implement the generated interfaces are src/clojure/migae/datastore/Persistent*. The reloading stops working just for those deftypes.
Even weirder: reloading the deftypes only works if I reload something else first. datastore.clj loads the Persistent*.clj files (containing deftype) first, then defines some stuff, then loads some other files (which use in-ns). It is only after I edit and reload one of those other files (e.g. ctor_local.clj) that reloading the deftype stuff works. Thanks, Gregg On Sat, Sep 12, 2015 at 10:21 AM, Gregg Reynolds <d...@mobileink.com> wrote: > > > On Sat, Sep 12, 2015 at 7:17 AM, Alex Miller <a...@puredanger.com> wrote: > >> This is a tricky area and one that has seen changes lately - what version >> of Clojure are you using? >> > > Clojure 1.7.0 > Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 > > A little more background info in case it helps: I've got two > gen-interfaces, and three typedefs. I want the typedefs in separate files > (to void editing confusion) but same namespace, so I have: > > ;; foo/core.clj > (ns foo.core...) > ... > (load "bar/mytype") > > ;; foo/bar/mytype.clj > (in-ns 'foo.core) > ... > (typedef MyType > foo.bar.IMyInterface > ...) > > ;; foo/interfaces.clj (aot-compiled) > (gen-interface :name foo.bar.IMyInterface > :extends [clojure.lang.IFn > clojure.lang.IPersistentMap > ...]) > > > Then I use ns-tracker to handle reloading. Then the problem is that > ns-tracker that when I edit foo/mytype.clj, ns-tracker picks up the quote > in (in-ns 'foo.core) and throws > > java.lang.Exception: Found lib name 'foo.core' containing period > with prefix 'quote'. lib names inside prefix lists must not contain periods > > My workaround is: > > (def mod-namespaces (ns-tracker [ ...blah blah ...])) > (doseq [ns-sym (mod-namespaces)] > (let [sym (if (symbol? ns-sym) > ns-sym > (last ns-sym))] ;; if foo/bar/mytype.clj is the > changed file, ns-sym is (quote foo.core), of type clojure.lang.Cons > (require sym :reload))) > > Works great so far, as long as my typedefs specify an interface generated > by gen-interface. > > Thanks, > > Gregg > > > >> >> >> On Friday, September 11, 2015 at 10:42:32 PM UTC-5, Gregg Reynolds wrote: >>> >>> Here's something a little perplexing that I discovered by trial and >>> error: if you reload (using require :reload) a clj file containing a >>> deftype implementing clojure interfaces (e.g. ISeq, etc.) plus some >>> functions, the functions will be reloaded but not the deftype >>> implementation code. That is, the clj file will be reloaded, but changes >>> in the deftype implementation code will not take effect. >>> >>> But if you use gen-interface (in another file, aot-compiled) to create >>> your interface using your own namespace, and then list that custom >>> interface (rather than the clojure interfaces) in the deftype, then the >>> implementation code gets reloaded. I don't really see why this is so, and >>> haven't found any relevant documentation. Can anybody explain what's >>> happening behind the curtain? >>> >>> Note: I'm running this on the Gooble AppEngine dev server, but I >>> shouldn't think that makes any difference. >>> >>> Thanks, >>> >>> -Gregg >>> >>> Example: >>> >>> A. This does not support code reloading for the deftype implementation >>> code: >>> >>> ;; in foo/bar.clj: >>> (ns foo.bar...) >>> ... other functions... >>> (deftype baz >>> clojure.lang.Seq >>> (first [_] ...) >>> (next [_] ...) >>> ....) >>> >>> >>> B. This does support reloading of the detype: >>> >>> ;; in some/other/namespace.clj: >>> (ns some.other.namespace ...) >>> (gen-interface :name foo.bar.Baz >>> :extends [clojure.lang.Seq ...] >>> ...) >>> >>> ;; in foo/bar.clj: >>> (ns foo.bar ...) >>> ... other functions ... >>> (deftype baz >>> foo.bar.Baz >>> ... implementations as before ... >>> ) >>> >> -- >> 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. >> > > -- 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.