在Guile或使用SRFI-46中,有可能如指定自定义省略标识符所示。但是,在SISC还是“纯方案”R5RS中,这是可能的?
我知道不使用省略号是可能的,但如果我需要使用内部省略号,如下面的示例所示呢?
(define-syntax define-quotation-macros
(syntax-rules ()
((_ (macro-name head-symbol) ...)
(begin (define-syntax macro-name
(syntax-rules ::: ()
((_ x :::)
(quote (head-symbol x :::)))))
...))))
(define-quotation-macros (quote-a a) (quote-b b) (quote-c c))
(quote-a 1 2 3) ⇒ (a 1 2 3)发布于 2014-05-18 13:14:59
SISC中使用的宏扩展程序p语法,通过使用...宏支持一种不同的方法来处理内部椭圆。您可以通过将...宏应用于要使用的每个内部椭圆来编写:
(define-syntax define-quotation-macros
(syntax-rules ()
((_ (macro-name head-symbol) ...)
(begin (define-syntax macro-name
(syntax-rules ()
((_ x (... ...))
'(head-symbol x (... ...)))))
...))))或者你也可以把它应用到一个外部形式中,里面的所有椭圆都应该是内部的:
(define-syntax define-quotation-macros
(syntax-rules ()
((_ (macro-name head-symbol) ...)
(begin (define-syntax macro-name
(... (syntax-rules ()
((_ x ...)
'(head-symbol x ...)))))
...))))https://stackoverflow.com/questions/23718244
复制相似问题