This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-01
Channels
- # adventofcode (2)
- # announcements (3)
- # babashka-sci-dev (79)
- # beginners (76)
- # biff (2)
- # calva (32)
- # cider (2)
- # clj-kondo (42)
- # clj-on-windows (17)
- # clojure (28)
- # clojure-belgium (1)
- # clojure-berlin (1)
- # clojure-europe (95)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-uk (5)
- # clojurescript (27)
- # conjure (5)
- # cursive (3)
- # data-science (16)
- # datomic (67)
- # graalvm (12)
- # hyperfiddle (36)
- # jobs (3)
- # jobs-discuss (1)
- # kaocha (2)
- # klipse (1)
- # leiningen (28)
- # lsp (16)
- # luminus (3)
- # malli (10)
- # nrepl (3)
- # off-topic (57)
- # other-languages (18)
- # re-frame (4)
- # reitit (8)
- # releases (1)
- # remote-jobs (1)
- # scittle (4)
- # shadow-cljs (7)
- # test-check (1)
- # tools-deps (4)
- # vim (11)
- # xtdb (25)
Morning!
Good (well) morning. Getting reminded the hard way why I don't fancy traveling by train. I'm not coping well with how the train moves... :face_vomiting:
Exactly like that. In the car I can counter by watching the road. Anyway, feeling a lot better now. And we should soon be at our destination.
Funny. Yesterday I was suggesting to my family that we should be taking the new train option for a trip to Hamburg. Just as a fun and exciting thing to do. Not so keen right now. And my kids have an even worse time with car sickness than I do.
That sucks. I believe trains are the future of intra-continental travel. Maybe you would feel differently in a high speed train though? It's a much smoother experience than a regular one. I've tried a bunch of them in China.
In Sweden the high speed trains are the worst in this respect. It was one of those I traveled with this morning. (Though Swedish ”high speed” trains would not be called that elsewhere. They are pretty slow. 😄)
But maybe the trains to Hamburg are not using these trains. I'll check. I really like the idea of a train adventure with the family.
Yeah, me too. It's really the only mode of transport, aside from boats, where you're not confined to a seat the whole time. I especially like sleeper trains.
I was traveling by plane yesterday. Perfect isolation, nothing to do but work. Got a weeks worth of work done in a couple of hours 🙂
I find the space in a plane too narrow compared to a train. I could barely open my macbook air 13" last time I was on a plane
At previous work we practiced no-meetings day (or at least 1/2). An official endorsement of plugging out and diving into work really helps to say no to all distractions. Nobody can complain about your slack and email being off during that period... (And they still have you ☎️ if a real crisis happens.)
Having said that, one could argue that with my role, it’s more important to unblock my colleagues than churning out new code. One might even say that I’ve failed if the situation is that I’m the only one available/capable of churning out said code.
mawning
Does anyone have any experience sticking core-async channels into stuartsierra.component system maps?
Well I want to use channels to communicate
but then if I stick them in a system-map then I want them to be re-usable
there's a question about lifecycle and idempotency
eg. a channel can be closed, so arguably it has lifecycle
but then how would you restart it?
I feel like I end up needing to wrap my channels in an object, a bit like a decorator pattern
exactly!
if they did that would be the solution
I could add all sorts of stuff round the sides
and easily provide instance-specific protocol implementations
Another trouble for me regarding channel life cycles is they are implicit sometimes
I think I need to wrap them in a defrecord
implicit how?
yes, they can get closed not as part of a system shutdown
I could do that, but I don't like it
makes sense for stop, ensure the channel is closed
but start means you need to know the circumstances of the channels construction
how does that survive a start -> stop -> start scenario?
no metadata means it's just an opaque async channel in the middle
you can't reclaim the constructor args for a new channel again
AFAIK you can't really restart a component system, can you? You need to make a new one anyway
I like my components to be restartable - it can help at the repl
ideally a started and stopped system should be functionally identical to an unstarted one
I think it's simpler just to create a record that holds the core.async channel though
yeah, a record with the constructor args (or fn), create a channel on start, close it on stop
then I want an idiomatic way to expose the channel though, so when I'm using it it's not a pain
IDeref
is syntactically light (with @
to access the channel) but I'm not sure it conveys the right meaning (plus I have to faff around with prefer-method
to stop it blowing up when trying to print a record that also implements IDeref at the repl
I actually have a gist for that which I want to make. a library out of, hang on I'll unprivate it
The idea is a generic state component has • start: take the component as argument and create a state which you can access later • stop: if you want to • step: if you want to thread the state as a first argument to a function, that's the function
interesting, thanks!
Good morning, folks!
Good morning! Back from vacation, I woke up at 5am today to do a pre-sunrise scuba dive.
So. I had this code:
(if whatever
(then ...)
(else ...))
Which I basically refactored into
(if whatever
(else ...)
(then ...))
The details of why are perhaps not so interesting, but what is interesting is that tests still passed.
Looking into this, it was because the code in else
function was very defensive and ended up doing what the then
fn was doing.
So I removed the defensive stuff in else
, and as expected, the tests blew up, and I could fix the if test properly.
But it begs the question. Which is better?As a general rule, I think avoiding negation in the condition is best. Otherwise, I usually just put the more code-heavy/happy path part in the first branch and the less code-heavy (= less stuff to follow) part in the second branch, since it makes it easier to ignore.
Yeah, I do that too @raymcdermott, but only in cases where either branch is of somewhat equal importance.
Oftentimes an if
will be more like (if condition? do-happy—path-stuff else-do-nothing-of-importance)
another pattern i quite like is (or (when () (when () (when () ...))) i-give-up-use-this)
to avoid having to return 'i give up' in several if
else positions
sometimes cond
yes, unless you need to wrap some let
stuff, if you don't want to use some cond-let
, better-cond
custom macros, or
+ when
is really convenient in that situation
yes, some of those when could be when-some