Mar*_*ari 3 functional-programming clojure
我有这段代码:
(ns mylib-clojure.core)
(defn doWhatever2 [x]
(doWhatever1 x))
(defn doWhatever1 [x]
(inc x))
Run Code Online (Sandbox Code Playgroud)
除非我将doWhatever1函数定义移到上面,否则此代码不起作用doWhatever2.由于我处于相同的命名空间,因此我必须这样做很奇怪.有没有办法在命名空间中声明我的函数而不必考虑订单?
Kyl*_*yle 10
Clojure编译器执行单次传递,因此顺序很重要.
Clojure确实提供了一种指定前向声明的方法:
(declare doWhatever1)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |