Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macros 如何扩展'Classname/staticField'宏语法_Macros_Clojure_Static_Interop_Expand - Fatal编程技术网

Macros 如何扩展'Classname/staticField'宏语法

Macros 如何扩展'Classname/staticField'宏语法,macros,clojure,static,interop,expand,Macros,Clojure,Static,Interop,Expand,从中,这是如何访问Java类的静态字段: Classname/staticField Math/PI -> 3.141592653589793 这就是扩展: 扩展如下: Classname/staticField ==> (. Classname staticField) 我无法使用macroexpand*: > (macroexpand 'Math/E) Math/E 我用什么来展开类名/staticField 这是Clojure v1.6.0 *尽管这确实有

从中,这是如何访问Java类的静态字段:

Classname/staticField

Math/PI
-> 3.141592653589793
这就是扩展:

扩展如下:

   Classname/staticField ==> (. Classname staticField)
我无法使用
macroexpand
*:

> (macroexpand 'Math/E)
Math/E
我用什么来展开
类名/staticField

这是Clojure v1.6.0


*尽管这确实有效:

> (macroexpand '(Math/E))
(. Math E)

文件在这方面有点不准确。宏展开仅适用于列表表单,而不适用于裸符号,因此在宏展开时仅处理列出的前三个特殊表单(对象和类上的实例方法、类上的静态方法)。
Classname/staticField
语法在宏扩展后解析为静态字段访问,当符号解析为变量、类或let绑定名称时,如中所述。

谢谢,这正是我想要的!