绑定 "this" 上下文

Binding the "this" context

是否可以在 ClojureScript 中绑定 this 上下文? 现在,我无法将 this 传递给高阶函数,如:

(defn generateTransactFunction [this]
  (fn [item] (do stuff with this and item)))

这感觉不是最理想的!我只是在学习 ClojureScript,所以我想我缺少了一些东西。

编辑:

看起来 partial 可以胜任,如:

(defn abc [this arg1 arg2] ())

并通过

(partial abc this)

正如您提到的,如果函数参数列表开头的 this 参数和其余参数将在稍后绑定,则可以使用 partial

如果您的 this 参数位置阻止您使用 partial,您可以使用 anonymous function literal,这将比函数文字 ((fn [args...] body)) 更简洁:

(defn abc [arg1 arg2 this] ...)

(do-sth #(abc %1 %2 this))