This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-29
Channels
- # announcements (5)
- # beginners (25)
- # calva (53)
- # clj-kondo (9)
- # clojure (25)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (21)
- # clojure-uk (1)
- # conjure (2)
- # data-science (1)
- # datalevin (4)
- # datascript (6)
- # deps-new (5)
- # emacs (5)
- # etaoin (6)
- # figwheel-main (1)
- # fulcro (46)
- # gratitude (3)
- # hyperfiddle (8)
- # introduce-yourself (13)
- # lsp (13)
- # nextjournal (5)
- # off-topic (2)
- # pathom (4)
- # polylith (11)
- # re-frame (16)
- # releases (4)
- # scittle (67)
- # shadow-cljs (38)
- # slack-help (4)
- # specter (13)
- # sql (29)
- # squint (21)
- # test-check (3)
- # vim (13)
- # xtdb (15)
This belongs to #community-development but the answer is probably "no, as long as there's a free tier or a non-free tier that's been gifted by Slack-the-company".
is it correct to assume that reduced?
is part of the protocol clojure.lang.IReduce
and it is guarantied that on last run reduced?
is true?
if no - is there a way to know that it is a last run?
reduced?
is used when you want to exit early. The last item isn't guaranteed to have this value.
roger,thanks
When I use prewalk, is there a way I can skip drilling into the form I return? Like I want a leaf to be a list, but if I return a list prewalk will go down into the list again, and it stack overflows.
postwalk, though i remember prewalk having some protection against the thing you just stated
@U0K064KQV i shared a thread on this topic
user=> (clojure.walk/prewalk
(fn [x]
(prn "x" x)
(if (= x :b)
[:d]
x))
[:a [:b :c]])
"x" [:a [:b :c]]
"x" :a
"x" [:b :c]
"x" :b
"x" :d
"x" :c
[:a [[:d] :c]]
user=>
Hum, when I encounter a symbol I return (deref sym) and it seems like it then goes into this and encounters the symbol again return (deref sym) again, and it stackoverflows doing that
well, for starters you can't deref a symbol, you must mean resolving the symbol to a var and derefing the var
ah, you aren't derefing it, you are producing a form that when evaluated would deref it
Ya, sorry about that. So I want to be like, hey ignore the form I just returned, don't prewalk over it basically.
I think if you put in reduced it will stop at that branch Then postwalk and deref reduced
Hum, ya I guess I could do that with a second pass. But then I worry there could be an actual reduced in the code that's not from my macro.
And I can't wrap it in a list or vector to indicate termination either, so maybe I need my own custom type.
(defn prewalk
"Like prewalk, but skips forms that are reduced."
[f form]
(walk/walk
(partial prewalk f)
#(if (reduced? %) (deref %) %)
(f form)))
You can't have reduced?
values in macroexpansions and expect them to compile, so introducing them yourself should probably be fine, especially if your prewalk is occurring before other macroexpansions.
So such an implementation of a "prewalk-substitute" would probably be fine.