sci

https://github.com/babashka/SCI - also see #babashka and #nbb
borkdude 2020-09-13T10:08:25.051Z

https://github.com/borkdude/sci#repl

1👀
borkdude 2020-09-13T12:36:36.051800Z

Also added a namespace dependency analyzer example using sci: https://github.com/borkdude/sci/blob/688a4addda7cb9e630a49042743ae254571ac5f0/examples/sci/examples/ns_tree.clj

borkdude 2020-09-13T21:40:33.052100Z

@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💯
djblue 2020-09-13T22:01:56.052400Z

reify works for me, but I can't get defrecord working

djblue 2020-09-13T22:02:10.052600Z

Also, is it possible to implement both interfaces at the same time?

borkdude 2020-09-13T22:05:11.052900Z

I have tests for defrecord, so in theory it should work. Also implementing both interfaces should also work, but there could be bugs still

borkdude 2020-09-13T22:05:44.053100Z

Maybe you can make a repro for me and post it in the issue: https://github.com/borkdude/sci/issues/401

djblue 2020-09-13T22:06:06.053500Z

Will do!

borkdude 2020-09-13T22:12:23.054Z

Ah, I didn't yet add compareAndSet

djblue 2020-09-13T22:13:55.054200Z

If I remove compareAndSet, it still happens

borkdude 2020-09-13T22:16:14.054400Z

Are you sure you updated the sci branch as well?

borkdude 2020-09-13T22:17:13.054600Z

also run lein clean if you have done any graalvm compilation

djblue 2020-09-13T22:17:19.054800Z

So I cd into the sci directory of babashka and pulled the IDeref branch (fe4637c821fea0d5972c5b99fa6279ef79d3f1ad)

djblue 2020-09-13T22:17:23.055Z

ohh, will do then

borkdude 2020-09-13T22:19:01.055200Z

Anyway, I'm getting errors on swap as well. I'll fix it tomorrow, thanks for the repro

borkdude 2020-09-13T22:19:12.055400Z

deref and reset do work for me

1👍
djblue 2020-09-13T22:19:34.055700Z

I'll see what I'm doing wrong on my end 👌

djblue 2020-09-13T22:19:55.056Z

Thanks for all the hard work!

borkdude 2020-09-13T22:20:25.056200Z

It's a nice challenge

borkdude 2020-09-13T22:25:23.056400Z

Ah I see what's wrong.

borkdude 2020-09-13T22:25:31.056600Z

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))

borkdude 2020-09-13T22:26:18.057Z

But there is a problem with multi-arity implementations :)