This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-11
Channels
- # adventofcode (52)
- # announcements (3)
- # aws (2)
- # babashka (36)
- # babashka-sci-dev (4)
- # beginners (69)
- # biff (45)
- # calva (9)
- # cider (3)
- # clara (8)
- # clj-kondo (24)
- # clojure (20)
- # clojure-dev (12)
- # clojure-europe (12)
- # clojurescript (2)
- # conjure (1)
- # emacs (17)
- # lsp (69)
- # malli (12)
- # off-topic (32)
- # polylith (2)
- # re-frame (4)
- # releases (2)
- # scittle (6)
- # shadow-cljs (21)
- # tools-deps (10)
- # vim (11)
- # xtdb (11)
Is it possible to step through code that includes an infinite lazy sequence without crashing the debugger??
clj꞉rich4clojure.hard.problem-073꞉>
#dbg
(defn tic-tac-toe [board]
(some identity (flatten
(for [winner [:x :0]]
(or (map (partial row-winner winner)
(take 2 (iterate flip-board board)))
(diagonal-winner winner board))))))
Debugger is not liking that (iterate flip-board board) and the REPL stops responding.I’m not aware of an issue with this, but I do know the breakpoint finding logic for where to place the cursor is not perfect. It’s likely that there’s an issue in the function for finding the breakpoint. https://github.com/BetterThanTomorrow/calva/blob/5e124de90c70770a080d766351703c631c3699f6/src/debugger/util.ts#L20 If you’re interested in digging in, you can try running Calva in development mode and setting a breakpoint in that function and seeing if there’s an issue there. A GH issue is welcome too, and then if you or someone else who uses the debugger wants to look more into later, I’m happy to help and review a PR.
"I’m not aware of an issue with this" Yeah, I guess this behaviour is what you would expect. If you step through code that includes lazy infinite sequences and the debugger evaluates the whole sequence to display the value then you are going to get an error were as the code is valid.
Just to whittle down an example to essentials.
#dbg
(defn something [] (take 5 (repeat 1)))
(comment (something)
;; => Execution error (OutOfMemoryError) at java.util.Arrays/copyOf (Arrays.java:3537).
;; Java heap space
)
Ah, cool. I found the entry in the manual about this>
https://calva.io/debugger/#debugger-hangs-when-stepping-over-infinite-seqsCursive doesn't display values of un-realized lazy sequences I think