Skip to content

Less expensive lazy seq forcing #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/special/core.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns special.core)
(ns special.core
(:require [clojure.walk :refer [postwalk]]))

(defonce ^:dynamic *-special-condition-handlers-* {})

Expand All @@ -24,15 +25,16 @@
(binding [*-special-condition-handlers-* (merge *-special-condition-handlers-* restarts)]
(apply f args))))

(defn- eager [v]
(postwalk (constantly nil) v))

(defn- eagerize
"Turns a lazy function into an eager function, at the
run-time cost of using pr-str to fully realize the
function result."
[f]
(fn [& args]
(let [res (apply f args)
_ (pr-str res)]
res)))
(eager (apply f args))))

(defn manage
"Takes a function f and an \"inlined\" map of conditions and keywords.
Expand Down