This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-17
Channels
- # aleph (3)
- # announcements (12)
- # beginners (80)
- # boot (3)
- # braveandtrue (16)
- # calva (3)
- # cider (82)
- # clojure (100)
- # clojure-art (3)
- # clojure-dev (79)
- # clojure-estonia (1)
- # clojure-europe (4)
- # clojure-finland (15)
- # clojure-indonesia (1)
- # clojure-italy (20)
- # clojure-nl (4)
- # clojure-spec (24)
- # clojure-sweden (2)
- # clojure-switzerland (1)
- # clojure-uk (99)
- # clojurescript (145)
- # cursive (8)
- # data-science (7)
- # datomic (26)
- # emacs (4)
- # figwheel-main (20)
- # fulcro (8)
- # graphql (3)
- # hoplon (2)
- # jobs (1)
- # kaocha (5)
- # leiningen (2)
- # liberator (19)
- # off-topic (16)
- # pathom (9)
- # perun (1)
- # portkey (2)
- # re-frame (17)
- # reitit (1)
- # shadow-cljs (26)
- # spacemacs (7)
- # vim (49)
The function prompt-move
calls itself at the end. Does that ultimately risk the stack? Or if not, how do I know that’s fine?
(page 122; https://github.com/flyingmachine/pegthing/blob/master/src/pegthing/core.clj line 223
Theoretically, it could blow the stack. In this case, that’s unlikely, because it only calls itself when there’s an invalid move. If the move is valid, it takes the other branch of the if-let
instead.
It’s probably still ok, stacks these days are usually pretty big, and you can probably get through enough moves to finish a game before it filled up.
(I’m saying this based on a rushed reading of the code, so I might be missing something here)
If I were going to write a turn-taking game, I’d find another way to do it other than writing mutually-recursive calls, because I don’t like trusting that the stack will be big enough, so your instincts are correct IMO.
Cool 🙂
I’m sure I”m going to be blowing up #beginners and #clojurescript while I do. Thanks for your response!
:thumbsup: