[racket] Dynamically Bind Functions

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Sat Dec 22 13:50:25 EST 2012

> Is there anything that would prevent me from having to wrap functions in
> make-parameter calls? Something like Clojure's binding special form (if
> you're familiar with it).

I'm not a Clojure expert so please correct me if I'm wrong but it
seems like you have to jump through similar hoops in Clojure?

Clojure 1.3.0
user=> (defn add1 [x] (+ x 1))
#'user/add1
user=> (add1 10)
11
user=> (binding [add1 #(+ % 2)] (add1 10))
IllegalStateException Can't dynamically bind non-dynamic var:
user/add1  clojure.lang.Var.pushThreadBindings (Var.java:339)
user=> (defn ^:dynamic add1 [x] (+ x 1))
#'user/add1
user=> (add1 10)
11
user=> (binding [add1 #(+ % 2)] (add1 10))
12



Posted on the users mailing list.