简体   繁体   English

Cnjure中的IFn代表什么?

[英]What does IFn in Clojure stand for?

In the Java source code for Clojure, I have seen: 在Clojure的Java源代码中,我看到:

import clojure.lang.RT;
import clojure.lang.IFn;

RT seems to stand for "run-time" (although no official source is given in the answer: In the clojure source code, what does RT stand for? ) RT似乎代表“运行时”(虽然答案中没有官方消息来源: 在clojure源代码中,RT代表什么?

But what does IFn stand for? IFn代表什么?

IFn means I nterface F u n ction. IFN意味着 ˚F覆盖整个院落加利 ction。 Clojure uses the capital "I" prefix for Java interfaces and "A" for Java abstract classes. Clojure使用Java接口的大写“I”前缀和Java抽象类的“A”。

See also IFn Javadoc and IFn source 另请参见IFn JavadocIFn源

in clojure's terms there is also one more difference between fn and ifn : 在clojure的术语中, fnifn之间还有一个区别:

user> (defn f [x] x)
#'user/f

user> (map fn? [f #(list %) :keyword 'sym {:a 10} #{123} [1 2 3] 10 "asd"])
(true true false false false false false false false)

user> (map ifn? [f #(list %) :keyword 'sym {:a 10} #{123} [1 2 3] 10 "asd"])
(true true true true true true true false false)

so, as you can see fn? 所以,你可以看到fn? is true for actual functions only, while ifn? 仅适用于实际功能,而ifn? if true for anything, that could be called as a function (like keywords, maps etc) 如果对任何事情都是真的,可以将其称为函数 (如关键字,地图等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM