This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-13
Channels
- # announcements (12)
- # babashka (88)
- # beginners (60)
- # biff (10)
- # calva (56)
- # clerk (9)
- # clj-kondo (5)
- # clojure (70)
- # clojure-austin (3)
- # clojure-conj (2)
- # clojure-dev (69)
- # clojure-europe (53)
- # clojure-nl (1)
- # clojure-norway (28)
- # clojure-uk (1)
- # clojurescript (27)
- # copenhagen-clojurians (3)
- # cursive (10)
- # datascript (1)
- # datomic (10)
- # fulcro (3)
- # funcool (1)
- # garden (7)
- # helix (5)
- # holy-lambda (5)
- # hyperfiddle (39)
- # introduce-yourself (6)
- # jobs-discuss (15)
- # lsp (3)
- # malli (5)
- # membrane (19)
- # missionary (1)
- # nrepl (6)
- # off-topic (44)
- # pathom (17)
- # pomegranate (3)
- # react (7)
- # releases (1)
- # shadow-cljs (39)
- # tools-deps (16)
- # xtdb (28)
I want this same result:
(->> {:one "one" :two "two" :three "three"} vec flatten)
;; => (:one "one" :two "two" :three "three")
I feel like I might be missing a single function that does this?(mapcat seq {:one "one" :two "two" :three "three"})
also does it - but still seems like it should be more simple.
iterleave its keys and values. but be aware that you are going from an unordered structure to an ordered one. The way you "see" the map or think it should order might not be what you end up with.
well, what I do care about is that the pairs stay next to each other. I don’t care about the order of the pairs themselves.
Oh yeah - ok, cool. I’m finding lots of ways to do this I see. I haven’t run into interleave yet - thanks for pointing it out!
I'm getting [nRepl] Connection closed unexpectedly (connection broken by remote peer)
when I do cider-eval-buffer
. At that point bb --nrepl-server
quits with exit status 1
and no message.
I'm using babashka v1.1.172
from Homebrew on the latest macOS.
What's up with that?
Haha I'm a moron. You're right. It's doing arguments check 🙈
Thanks.
but will exit with exit code 1 if the exception isn't caught, without printing an error report
Nice, I like that.
Are there no structs in Babashka?
Can't see it mentined in BB book, but getting Could not resolve symbol: create-struct
.
No. What is it with people and structs lately :) Clojure has defrecord
which replaces structs in 99.9% of the cases
Please let me know why you are trying to use structs. There's been a flux of people lately and it's mystery where this is coming from
No good reason: I'm rather new the Clojure and I'm still confused between vectors/iseqs, structs/records and the likes.
So if you say use record, that's fair enough for me.
Where did you read about structs? I'm trying to detect the "beginner's source" that tries to teach this to people. It's not a co-incidence anymore that people are asking about this in various places
I think I want something more "formal" than a record. There's a lot of data and all the vectors and maps are getting way too complex, so I wanted like a custom type.
Well coming from OOP languages you go like "OK, if there ain't no objects, then what would a custom type be?" and knowing structs from other languages, you go like oh yeah, that must be it.
None at all.
Hi. Where I can find bb builds with loom virtual threads? Any plans to build bb with loom in next releases?
Out of interest what's your usecase with loom threads? You can have 10,000s of Java threads already and with core.async
you can have millions of go blocks.
I'm working on library of SWIM implementation protocol in JVM and every UDP packet is processed in Virtual Thread. I want to make this library bb compatible and I need to test it with Loom threads. core.async has limits of using I/O in go blocks and limited by OS threads. Loom Virtual Threads is free of that limits. I can make 100K I/O parallel operations without any problems.
Thanks, sounds good. I can see that loom threading model would help simplify the design of protocols like that.
we have this branch https://github.com/babashka/babashka/tree/jdk19-loom and tried out experimenting with it with some good results. but we are waiting on some more issues to resolve before moving to jdk 19+
i can try triggering the ci on that branch again to produce some binaries, but note that the branch isnt upto date
@U04V15CAJ should i get the loom branch upto date? have some newer CI builds?
You should be able to try the jdk19-loom branch and compile locally. For some reason there was a failing Windows test which I haven't dug into. There is GraalVM 19 22.3.1 (previous I tried was 22.3.0)
@U7ERLH6JX Feel free to make the branch up to date, preferably via a PR to the jdk-19 branch
If people want to speed up progress around getting this released into bb investigating the Windows issue should help too
I made bb build from https://github.com/babashka/babashka/tree/jdk19-loom branch using GraalVM 19 22.3.1. Now it works!
I made a build with spec flag export BABASHKA_FEATURE_SPEC_ALPHA=true
. Why s/and is not supported? Is there workaround?
@U097654L8 You don't need this anymore. spec is included with bb in the latest version. before those you have to include this dependency: https://github.com/babashka/spec.alpha
I made a build with loom v1.0.165. Is there any bb branches with loom for newer versions of bb?
I need Loom and spec together
Like i mentioned before, that branch isn’t upto date. You can rebase master on it maybe
I'll try. Thanks.
@U097654L8 if you’re already on it, might as well raise a PR if it works 😄 i can do it in a bit as well
Well I made rebase loom branch on 1.0.174-SNAPSHOT and Loom works. But I still struggle with spec. s/and still could not be resolved
Ah, I will recompile without this flag. Thanks!
I'm not sure whether this has to do with babashka or something else, but I'm running babashka, so I'll try here.
I have a custom text representation of my type: (defmethod print-method QID [qid out] (.write out (str "m[QID: " (.toString qid) "]")))
When I put (println (QID. 4 0 0 1))
into my script and run it in the console, it prints out the correct custom representation. All good there.
However in bb --nrepl-server
this is not respected. That is, I evaluate the method definition, then I evaluate the println
sexp, it returns nil as it should, but if I go to the cider buffer, where it shows standard output, it's not formatted by the custom formatter but rather by the default one.
Anyway in the context of REPL, more important than the standard output is what I see as the inspect value when I evaluate a sexp in the code buffer.
If I understand how things work, this requires to define print-dup
in the same way as I defined the print-method
. I did so, evaluated in REPL, but it's still out returning the expected formatting.
What am I doing wrong?
Let me see what it does in normal Clojure.
Oh wow it probably is a bug, it works in Clojure.
Let me verify to make sure I'm not doing something stupid, but if I'm not, I'll report it.
It's there.
I'm using Clojure in the REPL for now and it works there as expected.
Really I just need it in the REPL, so it doesn't bother me that much, but of course it's more pleasant running Babashka REPL so I don't have to define all those constants that Clojure doesn't have defined, fs
, str
etc.
A little bit more explanation in the issue might be good. There's just screenshots without any guiding text how to repro. I have this code, merged the snippet into one snippet:
(defprotocol Version (stringify [this] "Get string representation"))
(deftype QID [a b c d] Version (stringify [_] "test"))
(defmethod print-method QID [object out]
(.write out (stringify object)))
(println "HERE")
(println (.stringify (QID. 4 0 0 1)))
(println (.toString (QID. 4 0 0 1)))
(println (QID. 4 0 0 1))
And here is the difference between bb and clj:
borkdude@m1 ~/dev/greglook-clj-multiformats (babashka) $ bb /tmp/dude.clj
HERE
nil
nil
test
borkdude@m1 ~/dev/greglook-clj-multiformats (babashka) $ clj -M /tmp/dude.clj
HERE
test
user.QID@7c8326a4
test
Is there anything more I need to know? I also see an NPE in the issue, how to repro that?The other one is probably not 100% related (it doesn't have print-method
defined, but also behaves weird, so I thought it might be possibly somewhat related, I don't know, take a look and see.
What's NPE?
I think you don't need to know anything more.
Those are probably more idiomatic Clojure ways of doing the same and what bb is optimized for
OK, it does. That makes me even more perplexed. Isn't a method supposed to be called with a dot?
Hahaha I'm sure about that 😄
So foo is a proper var. That there is a generated Java method under the hood is not something you should be concerned with I'd say
Right. The way to access the generated Java method is via the dot notation? And I shouldn't be doing that then you say. Just leaving the dot out then?
Really appreciate your help and your work on Babashka! Such an awesome project!