Fork me on GitHub
#clojure
<
2020-06-14
>
jsyrjala06:06:49

What is a good pattern to do this with core.async. I have a producer that writes to a bounded channel and consumer that reads from the channel, if either of the processes fails, then also the another process should stop. Also there should be two threads, so that simultaneously a new message is beeing produced while earlier messages are processed by the consumer.

lispyclouds08:06:19

Hello, I might be missing something obvious, but why does (println :a.b.c/1) produces a

Syntax error reading source at (a.clj:1:18).
Invalid token: :a.b.c/1
but (keyword "a.b.c/1") produces the keyword as expected?

dominicm09:06:12

@rahul080327 the keyword function is more lenient than the reader

dominicm09:06:21

Neither is a valid keyword though.

noisesmith16:06:39

:1 is accepted because it once accidentally worked and they don't like breaking existing code

noisesmith16:06:00

it was never meant to

seancorfield17:06:46

There are libraries out there that assume :1 works. They changed Clojure at one point in an alpha to disallow such keywords and it broke code so they decided to continue allowing them (even tho' they are not "legal").

nthd3gr3309:06:46

Does anyone know why Rich Hickey choose the boolean logic system that Clojure has? I would be interested in knowing not only his reasoning for this choice, but also the advantages and tradeoffs of this choice.

nthd3gr3312:06:48

Assuming you are referring to the recent one [here](https://download.clojure.org/papers/clojure-hopl-iv-final.pdf). Yes, unfortunately, he doesn’t mention it.

✔️ 3
sveri12:06:05

Yep, that's the one, I opened the page, copied the link, but forgot to paste it.

noisesmith16:06:40

it might be useful to compare scheme (has #t and #f for booleans, empty list is truthy), and common lisp (empty list is nil is falsey)

noisesmith16:06:28

clojure's approach is very similar to scheme, except it adds a nil that can be used both as empty list and as falsey

andy.fingerhut16:06:39

Clojure for Lisp programmers talk has some discussion by Rich of the choices, targeted at an audience of people who know Common Lisp and Scheme

andy.fingerhut17:06:47

If I recall correctly, true/false come from the JVM, and easier interop strongly calls out for having a representation for those in Clojure explicitly. nil as another falsey value is I believe something that Rich considers so useful for if , when , and cond conditional expressions, that he wanted to have that in the language as falsey, too.

andy.fingerhut19:06:51

That Clojure for Lisp Programmers talk does have some other disccusion by Rich for at least some other design decisions in the Clojure language.

rgm23:06:37

I just re-watched the ants simulation demo yesterday, and he did mention it was Common Lisp semantics plus Java’s true/false for simplifying interop.

nthd3gr3311:06:04

Thank you all so much 🙏 Got what I needed now

adam18:06:40

I am configuring Ring's site-defaults and setting the session store to cookie but it's requiring a a byte array. How can I convert my string to that? Full error: WARNING: The secret key for the session cookie store should be a byte array. String secret keys have been deprecated. Execution error (AssertionError) at ring.middleware.session.cookie/cookie-store (cookie.clj:124). Assert failed: the secret key must be exactly 16 bytes (valid-secret-key? key)

dominicm18:06:33

Call .getBytes on it

adam18:06:38

Worked, thank you

colliderwriter22:06:11

someone had a blog post a couple of weeks ago abut sorting sets by a map value which is proving to be pretty google-proof. does anyone #rememberaurl ?

andy.fingerhut22:06:00

Not sure if you are thinking of this http://clojure.org guide article, or something else? https://clojure.org/guides/comparators

seancorfield22:06:47

I went searching in Zulip for sort and set but they get mentioned a lot across a lot of topics so I couldn't find anything obviously related... can you provide anything more precise @U0GFU866B?

colliderwriter22:06:01

it was not the comparators guide @U0CMVHBL2, it was a blog post which appeared in my clojure RSS feed. I wish I had more to go on than that. And yes, @U04V70XH6 it's pretty search-proof. I'm sure i can get a naive answer by REPL-grinding but I recall this post as having done the thinking for me