Welcome @slack1304 and @seminioni!
thank you @borkdude im newcomer in clojure(script) world, so hope will find a lot of interesting here 🙂
Hi all. Is it possible to extend protocols to clojure maps and functions with bb? I'm having a look at getting tick library working and it does
(extend-protocol Foo
clojure.lang.Fn
...
in a few places@henryw374 Do you have an isolated small example for me?
@henryw374 This works in bb:
(defprotocol Foo
(foo [_]))
(extend-protocol Foo
Number
(foo [x] (prn :x x)))
(foo 1)
But some classes aren't available (yet) which can be potentially fixed in the next version
ok so I found clojure.lang.IFn
is there, so tick could use that instead of clojure.lang.Fn I think, but for maps,
#!/usr/bin/env bb
(defprotocol Foo
(bar [_] ))
(extend-protocol Foo
clojure.lang.IFn
(bar [f] (f))
clojure.lang.APersistentMap
(bar [x] x))
(bar (fn [] "yay!"))
(bar {})
so I guess clojure.lang.APersistentMap
would need adding, unless there's an alternative
a map is also an IFn, so not sure which one would take priority there
interesting!
yeah good point, I'll dig in. thanks
there is IPersistentMap in bb btw
:thumbsup:
@henryw374 This works:
#!/usr/bin/env bb
(defprotocol Foo
(bar [_] ))
(extend-protocol Foo
clojure.lang.IPersistentMap
(bar [x] [:map x])
clojure.lang.IFn
(bar [f] [:fn (f)]))
(prefer-method bar clojure.lang.IPersistentMap clojure.lang.IFn)
(prn (bar (fn [] "yay!")))
(prn (bar {}))
but it leaks the implementation detail that bb uses multi-methods to implement protocols ;P🙂
cool. I'm fairly sure I can get tick working then
if we added clojure.lang.Fn to bb then you could leave out the impl detail
hmm, that'd be nicer for sure
ok, I'll include that in 0.2.7, let me know when you want to release tick for bb, so I can push a new release
great thanks. no great hurry really 🙂
Babashka 0.2.7 released We are re-introducing Alpine images along with the main Ubuntu image (thanks @rahul080327) https://hub.docker.com/repository/registry-1.docker.io/babashka/babashka/tags?page=1&ordering=last_updated And various other small improvements (like the one discussed earlier today).
Someone got babashka to work on Raspberry: https://github.com/babashka/babashka/issues/241#issuecomment-763976749
@franquito the default rasberry pi OS, or something else like the post?
It's the Raspberry Pi OS, but a 64 bit beta, I downloaded based on what I read https://www.raspberrypi.org/forums/viewtopic.php?t=275370
perfect
Nice, works fine on my Pi 🙂 (And I'm using the 64 bit version of the OS)