News for hackers. Stuff that matters.
Re:Java 21 VirtualThreads vs. Clojure Lazy Seqs (from Clojur... by avodonosov on Saturday October 07, 2023 @08:15AM (#37801064)
Strange that synchnronization is used at all in lazy-seq

The docs do not mention any synchronization: https://clojure.github.io/clojure/clojure.core-api.html#cloj...

Re:Java 21 VirtualThreads vs. Clojure Lazy Seqs (from Clojur... by lcedp on Saturday October 07, 2023 @11:48AM (#37802692)
> a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls.

To guarantee "only the first time", I suppose you need to have some kind of synchronization at some level.

Re:Java 21 VirtualThreads vs. Clojure Lazy Seqs (from Clojur... by avodonosov on Saturday October 07, 2023 @12:38PM (#37803179)
For multithreaded access yes.

I meant that the docs do not mention thread safety.

Re:Java 21 VirtualThreads vs. Clojure Lazy Seqs (from Clojur... by daveliepmann on Sunday October 08, 2023 @12:56PM (#37812203)
"All of the Clojure collections...are efficient and inherently thread-safe."

https://clojure.org/reference/data_structures#Collections

"Seqs differ from iterators in that they are persistent and immutable, not stateful cursors into a collection. As such, they are useful for much more than foreach - functions can consume and produce seqs, they are thread safe, they can share structure etc."

https://clojure.org/reference/sequences

I think it's a fundamental enough property of clojure data structures that it would be redundant to mention it in every docstring.

Re:Java 21 VirtualThreads vs. Clojure Lazy Seqs (from Clojur... by avodonosov on Monday October 09, 2023 @07:14AM (#37819143)
Thanks, that's convincing.

(why I was in doubt, is because while immutable functional collections that clojure embaces are naturally thread-safe, there is an imperative aspect in creation of a lazy sequence from user provided function, and I was not sure clojure has to provide synchronization guarantees here)