[plt-scheme] Problem with (... ...) pattern
Matthew Flatt skrev:
> At Thu, 15 Nov 2007 13:22:01 +0100, Jens Axel Soegaard wrote:
>> I tried this definition:
>>
>> (define (formals-arity stx)
>> (syntax-case stx ()
>> [(a ... (... ...))
>> (- (length (syntax->list #'(a ... ))))]
>> [(a ...)
>> (length (syntax->list stx))]
>> [else
>> (error 'formals-arity "not-yet implemented arity for " stx)]))
>>
>> Alas, I get the error:
>>
>> syntax: missing ellipses with pattern variable in template in: a
>>
>> and the a in #'(a ...) is colored red.
>
> Tricky!
>
> The `(... ...)' in the pattern means that `...' gets bound as a pattern
> variable. In the scope of that binding, `(a ...)' as a template is the
> `a' pattern variable followed by the `...' pattern variable.
Ah! Thanks for the explanation.
--
Jens Axel Søgaard