4 ms·
(require '[foo :refer [f]]) ; edit f in foo.clj (require '[foo :reload]) (f 1) ; should call NEW f. Node doesn’t have a reload construct. If you ha
by brandonbloom 9y ago
(require '[foo :refer [f]])
; edit f in foo.clj
(require '[foo :reload])
(f 1) ; should call NEW f.
Node doesn’t have a reload construct. If you hack it in by mucking with the module cache, you still won’t get the new f in your module’s local copy of it.
- tome 9y agoBut doesn't the same apply for integer too, as in my example? After reloading y should refer to the NEW x? And what should happen in your example if f were deleted?
- brandonbloom 9y agoIf f were deleted, it would still be in memory unless you explicitly call ns-remove to clean it up. In practice, this is rarely an issue, but I do wish the experience was a little cleaner there. The same things do apply to integers, but if you use them at the top level (outside a function) then they will be dereferenced immediately (there is no delayed function body to wait for) and so you will get the initial value only once. If you want to enforce a delay, you can use (var x) or the shorthand #’x and later derefence that with @