This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-18
Channels
- # announcements (6)
- # babashka (16)
- # beginners (194)
- # calva (20)
- # cider (34)
- # clj-kondo (38)
- # clojure (89)
- # clojure-europe (10)
- # clojure-finland (15)
- # clojure-italy (2)
- # clojure-nl (15)
- # clojure-sg (7)
- # clojure-spec (15)
- # clojure-uk (86)
- # clojurebridge (1)
- # clojurescript (60)
- # community-development (11)
- # conjure (13)
- # core-async (48)
- # core-typed (3)
- # cursive (22)
- # datascript (8)
- # datomic (40)
- # duct (11)
- # emacs (3)
- # figwheel-main (22)
- # fulcro (45)
- # graphql (1)
- # helix (9)
- # hoplon (15)
- # hugsql (7)
- # jobs-discuss (47)
- # juxt (7)
- # kaocha (21)
- # luminus (1)
- # malli (13)
- # meander (2)
- # off-topic (52)
- # parinfer (19)
- # re-frame (66)
- # reagent (1)
- # reitit (3)
- # ring-swagger (1)
- # rum (2)
- # shadow-cljs (72)
- # spacemacs (5)
- # sql (4)
- # timbre (5)
- # tools-deps (15)
- # vim (5)
- # vrac (7)
Funny, following works in Babashka but not in Clojure
(defn non-tail-recur []
(loop [i 100]
(try
(if (> i 10)
(throw (ex-info "foo" {}))
i)
(catch Exception e
(recur (dec i))))))
Clojure says: Can only recur from tail position
No, I think itβs ok. I was just debugging something and thought maybe was the cause, but it was something else
Clojure is pretty clear about it, in Babashka you are just lucky π
I guess the check would need to happen at the analyzer level, right?
what happens at runtime is that this loop is running within a function and when you call recur, it recurs the function call.
Maybe analysing a function is enough:
(fn [] (try 1 (catch Exception e (recur))))
Syntax error (UnsupportedOperationException) compiling recur at (REPL:1:34).
Can only recur from tail position
π (in clojure)haha wow no, i never had a usecase for that π
cool, thanks