所以我有这个功能:
(define (try try-block catch-block finally-block)
; Implements try/catch/finally like in most other languages
)
为此,我想创建一个“助手”宏,以避免(lambda () ...)
一遍又一遍地说,有点像set
和setq
:
(define-macro (tryq try-block catch-block finally-block)
(try
(lambda () (eval try-block))
(lambda () (eval catch-block))
(lambda () (eval finally-block))))
然而,由于lambda
延迟了它的参数,上面的程序不起作用——在它被评估时try-block
内部eval
是空的,因为它在一个lambda
.
如何正确实现此功能?