clojure-europe 2026-03-25

congrats to Denmark for having an election. I hope you have many more in the future.

πŸ˜† 6
🫑 1

Good morning!

good morning

Good contemplative morning

Good morning 😊

Anyone else getting πŸ¦„πŸ¦„πŸ¦„πŸ¦„πŸ¦„ from Microslopt GH?

What do you mean? An outage?

It was failing a while ago

just spent 15 minutes staring at this, just being confused. Am I catching it wrong? is ExceptionInfo not an Exception??

(try (map inc "confused")
     (catch Exception _ :exception-caught))
;; => Error printing return value (ClassCastException) at clojure.lang.Numbers/inc (Numbers.java:137).
;;    class java.lang.Character cannot be cast to class java.lang.Number (java.lang.Character and java.lang.Number are in module java.base of loader 'bootstrap')
(spoiler in thread)

2 arg mapv is eager, higher ones just call map underneath

Do the lazyness issues apply even when the resulting value is eager? The 3 arg version, for example, is

([f c1 c2]
     (into [] (map f c1 c2)))
Which issues to do with lazyness could occur here? Ah... reads https://clojure-goes-fast.com/blog/clojures-deadly-sin/ again some stuff like dynamic binding can break

Also, performance

lazyness and exceptions don't mix well!

There's no end to this rabbit hole!

(def x (list 1 2 (map inc "lol")))

;; first time
x
;; => (1Error printing return value (ClassCastException) at clojure.lang.Numbers/inc (Numbers.java:137).
;;    class java.lang.Character cannot be cast to class java.lang.Number (java.lang.Character and java.lang.Number are in module java.base of loader 'bootstrap')

;; second time
x
;; => (1 2 ())

(map inc "confused") succeeds and returns a lazy sequence. When you print it (in the REPL), it attempts to realize the sequence and that is when it tries to (inc \c)

Also ExceptionInfo is-a Exception is-a Throwable:

user=> (ancestors (class (ex-info "" {})))
#{clojure.lang.IExceptionInfo java.lang.Object java.lang.RuntimeException java.io.Serializable java.lang.Throwable java.lang.Exception}

πŸ‘ 1

Yup, I realized at last!

Was meant as a brainfart to share, hence "(spoiler in thread)" in the original post. Very small at the bottom.

I've long wished that Clojure's "stdlib" was eager-by-default from day one, with lazy fns as "day two" stuff and opt-in.

πŸ‘ 1
☝️ 1

Laziness is like a little surprise for yourself for later ☺️

πŸ₯ 3
πŸ˜‚ 2

maybe something clj-kondo could help with

πŸ€” 2

@imre mapv is lazy? But it returns a vector?

I must say, in spite of the good arguments for avoiding lazyness, it has bitten us surprisingly little at $workplace

Mapv for varargs is slightly pathological

I converted my failings to a Clojuredocs example: https://clojuredocs.org/clojure.core/try#example-69c3ff007955605a202df29a Hope it's understandable!

πŸ’ͺ 1
πŸ’ͺ🏻 1

😍 1
πŸ₯° 1