clojure - Clojure 中的自省(introspection)

标签 clojure introspection

在 Clojure 中进行自省(introspection)的最佳方法是什么?有没有类似 Python 的 dir功能?我对查找与我交互操作的 java 类上可用的方法特别感兴趣,但我也有兴趣找出 Clojure 中与自省(introspection)相关的任何可用方法。

最佳答案

Michiel Borkent 和 Dave Ray 涵盖了互操作选项。

为了发现 Clojure 函数,clojure.repl 中有几个选项。命名空间(默认情况下可能已经引用到您的 REPL 中)。

dir :

=> (require 'clojure.set)
nil
=> (dir clojure.set)
difference
index
intersection
join
map-invert
project
rename
rename-keys
select
subset?
superset?
union

apropos :
=> (apropos #"^re-")
(re-pattern re-matches re-matcher re-groups re-find re-seq)

find-doc :
=> (find-doc #"^re-")
-------------------------
clojure.core/re-find
([m] [re s])
  Returns the next regex match, if any, of string to pattern, using
  java.util.regex.Matcher.find().  Uses re-groups to return the
  groups.
-------------------------
clojure.core/re-groups
([m])
  Returns the groups from the most recent match/find. If there are no
  nested groups, returns a string of the entire match. If there are
  nested groups, returns a vector of the groups, the first element
  being the entire match.
-------------------------
....

关于clojure - Clojure 中的自省(introspection),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8435555/

相关文章:

ruby - 用代理对象愚弄 Ruby 的 case 运算符 ===

javascript - 如何进行 JavaScript 对象自省(introspection)?

macros - 口齿不清/克洛朱尔 : Is it a good idea to write function generating macros?

Swift:检查字典值的类型

objective-c - 使用反射/内省(introspection)调用参数数量未知的选择器

clojure - 为什么不能 RSeq 一个 RSeq?

java - 我如何找出我需要从 Java 库中导入的 namespace ?

java - 在 Clojure 中捕获系统/输出

java - 如何在Tapestry5应用程序中实现类似django的管理命令?

http - 如何在 Clojure 中使用 POST 处理程序接收 edn? (以及如何发送)