我希望能够写:
(nota E2 82)
代替:
(define E2
(network ()
[sunet <= sine-wave 82]
[out = (+ sunet)]))
我知道我可以使用宏来做到这一点,并试图写这个:
(define-syntax (nota stx)
(syntax-case stx ()
[(nota x) #'(network ()
[sunet <= sine-wave x]
[out = (+ sunet)])]))
但我收到此错误:
nota: bad syntax in: (nota E2 82)
最佳答案
最简单的解决方案是
(define-syntax-rule (nota x y)
(define x
(network ()
[sunet <= sine-wave y]
[out = (+ sunet)])))