On Sat, Sep 12, 2015 at 7:17 AM, Alex Miller <[email protected]> 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 [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.