【发布时间】:2018-10-26 03:11:51
【问题描述】:
Elixir 中是否有类似于 lisp 中的 trace 宏的东西,它显示函数调用的输入和返回值。取自Common Lisp HyperSpec网站:
(defun fact (n) (if (zerop n) 1 (* n (fact (- n 1)))))
=> FACT
(trace fact)
=> (FACT)
;; Of course, the format of traced output is implementation-dependent.
(fact 3)
>> 1 Enter FACT 3
>> | 2 Enter FACT 2
>> | 3 Enter FACT 1
>> | | 4 Enter FACT 0
>> | | 4 Exit FACT 1
>> | 3 Exit FACT 1
>> | 2 Exit FACT 2
>> 1 Exit FACT 6
=> 6
【问题讨论】:
标签: elixir