We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ec80266 commit d15a1f0Copy full SHA for d15a1f0
src/clj/clojure/core.clj
@@ -3447,11 +3447,14 @@
3447
"Expands into code that creates a fn that expects to be passed an
3448
object and any args and calls the named instance method on the
3449
object passing the args. Use when you want to treat a Java method as
3450
- a first-class fn."
+ a first-class fn. name may be type-hinted with the method receiver's
3451
+ type in order to avoid reflective calls."
3452
{:added "1.0"}
3453
[name & args]
- `(fn [target# ~@args]
3454
- (. target# (~name ~@args))))
+ (let [t (with-meta (gensym "target")
3455
+ (meta name))]
3456
+ `(fn [~t ~@args]
3457
+ (. ~t (~name ~@args)))))
3458
3459
(defmacro time
3460
"Evaluates expr and prints the time it took. Returns the value of
0 commit comments