So I have this function:
(define (try try-block catch-block finally-block)
; Implements try/catch/finally like in most other languages
)
for which I would like to create a "helper" macro that avoids the need for saying (lambda () ...)
over and over again, kind of like set
and setq
:
(define-macro (tryq try-block catch-block finally-block)
(try
(lambda () (eval try-block))
(lambda () (eval catch-block))
(lambda () (eval finally-block))))
However, because lambda
delays its arguments, the above program doesn't work -- the try-block
inside eval
is empty by the time it is evaluated, since it is inside a lambda
.
How do I go about implementing this functionality correctly?
'expand' will do the job and you may also look into 'letex' which is a combination of 'let' and 'expand'.