Also added a namespace dependency analyzer example using sci: https://github.com/borkdude/sci/blob/688a4addda7cb9e630a49042743ae254571ac5f0/examples/sci/examples/ns_tree.clj
@djblue I just pushed IAtom to babashka / sci (both still in the IDeref branch):
$ rlwrap lein bb
Babashka v0.2.1-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (def x (reify clojure.lang.IAtom (swap [_ f] (f 1))))
#'user/x
user=> (swap! x inc)
2
1💯reify works for me, but I can't get defrecord working
Also, is it possible to implement both interfaces at the same time?
I have tests for defrecord, so in theory it should work. Also implementing both interfaces should also work, but there could be bugs still
Maybe you can make a repro for me and post it in the issue: https://github.com/borkdude/sci/issues/401
Will do!
https://github.com/borkdude/sci/issues/401#issuecomment-691732506
Ah, I didn't yet add compareAndSet
If I remove compareAndSet, it still happens
Are you sure you updated the sci branch as well?
also run lein clean
if you have done any graalvm compilation
So I cd into the sci directory of babashka and pulled the IDeref branch (fe4637c821fea0d5972c5b99fa6279ef79d3f1ad)
ohh, will do then
Anyway, I'm getting errors on swap as well. I'll fix it tomorrow, thanks for the repro
deref and reset do work for me
1👍I'll see what I'm doing wrong on my end 👌
Thanks for all the hard work!
It's a nice challenge
Ah I see what's wrong.
This works:
(defrecord Example []
clojure.lang.IDeref
(deref [this] :deref)
clojure.lang.IAtom
(reset [this new-value] :reset)
(swap [this f] :swap)
#_(swap [this f a] :swap)
#_(swap [this f a b] :swap)
#_(swap [this f a b args] :swap)
#_(compareAndSet [this oldv newv] :compare-and-set))
(prn @(->Example))
(prn (reset! (->Example) 1))
(prn (swap! (->Example) inc))
But there is a problem with multi-arity implementations :)