3 years of nbb 🎉 https://x.com/borkdude/status/1817142508133945627 https://mastodon.social/@borkdude/112857941495188434
I am trying to use https://github.com/deercreeklabs/baracus from nbb. The problem is that baracus extends some protocols to byte arrays to make them countable, etc. This doesn't seem to work in nbb, as shown by this repl session:
~/src/crisp/ground-up $ nbb
Welcome to nbb v1.2.191!
user=> (extend-protocol ICounted)
"#error {:message \"Protocol not found: ICounted\", :data {:type :sci/error, :line 1, :column 1, :message \"Protocol not found: ICounted\", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 1, :column 1, :ns #object[Is user], :file nil} {:line 1, :column 1, :ns #object[Is user], :file nil, :sci.impl/f-meta {:ns #object[Is clojure.core], :macro true, :sci/built-in true, :name extend-protocol, :arglists ([p & specs]), :doc \"Useful when you want to provide several implementations of the same\\n protocol all at once. Takes a single protocol and the implementation\\n of that protocol for one or more types. Expands into calls to\\n extend-type:\\n\\n (extend-protocol Protocol\\n AType\\n (foo [x] ...)\\n (bar [x y] ...)\\n BType\\n (foo [x] ...)\\n (bar [x y] ...)\\n AClass\\n (foo [x] ...)\\n (bar [x y] ...)\\n nil\\n (foo [x] ...)\\n (bar [x y] ...))\\n\\n expands into:\\n\\n (do\\n (clojure.core/extend-type AType Protocol \\n (foo [x] ...) \\n (bar [x y] ...))\\n (clojure.core/extend-type BType Protocol \\n (foo [x] ...) \\n (bar [x y] ...))\\n (clojure.core/extend-type AClass Protocol \\n (foo [x] ...) \\n (bar [x y] ...))\\n (clojure.core/extend-type nil Protocol \\n (foo [x] ...) \\n (bar [x y] ...)))\"}})}], :file nil}, :cause #error {:message \"Protocol not found: ICounted\", :data {:type :sci/error, :line 1, :column 1, :file nil}}}"
Any idea why this works fine in cljs, but not in nbb?It's currently a known limitation
Got it. Is the limitation that protocols can't be extended or that ICounted doesn't exist?
Most CLJS protocols can't currently be extended (only some like ISwap, IDeref). It's something which might be fixed but currently it's known not to work in the SCI interpreter
Cool. Thanks for the info and your great work on the sci/bb/nbb ecosystem!