在CAD 中使用Lisp写代码时经常遇到,函数内部一部分代码多次执行,奈何lisp没有goto这一跳转语法。
(defun test ( / add a b)
(setq a 1)
(setq b 1)
(defun add()
(princ (+ a b))
)
(add)
)
########################
(test) ;打印结果2
其中 add 为test的内部函数,定义内部函数可以实现代码断在内部多次调用,达到goto效果
在CAD 中使用Lisp写代码时经常遇到,函数内部一部分代码多次执行,奈何lisp没有goto这一跳转语法。
(defun test ( / add a b)
(setq a 1)
(setq b 1)
(defun add()
(princ (+ a b))
)
(add)
)
########################
(test) ;打印结果2
其中 add 为test的内部函数,定义内部函数可以实现代码断在内部多次调用,达到goto效果