[racket] Using ... as a keyword in syntax-rules
On 1/13/12 3:53 PM, David Van Horn wrote:
> On 1/13/12 3:45 PM, Patrick Li wrote:
>> Hello everyone,
>>
>> I'm trying to write a simple macro using syntax-rules, and couldn't find
>> an answer to this problem in the faqs. If I want to use '... as a
>> keyword for matching in syntax-rules, how would I do this? I've tried
>> various combinations of (...) and (... ...), etc... but couldn't get it
>> to work.
>
> #lang racket
> (define-syntax is-dots?
> (syntax-rules (... ...)
> [(is-dots? (... ...)) #t]
> [(is-dots? _) #f]))
>
> (is-dots? ...)
> (is-dots? dots)
Actually, this works just fine:
#lang racket
(define-syntax is-dots?
(syntax-rules (...)
[(is-dots? (... ...)) #t]
[(is-dots? _) #f]))
(is-dots? ...)
(is-dots? dots)