[plt-scheme] Problem with (... ...) pattern

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Thu Nov 15 07:22:01 EST 2007

Hi all,

I am trying to write a formals-arity procedure that
given a syntax-object representing the formals (formal arguments)
of an abstraction returns the arity. The arity of a function
receiving 3 or more arguments are -3.

 > (formals-arity #'(a b c))
3

 > (formals-arity #'(a b c ...))
-3


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.


Shouldn't have worked? Am I missing something?

-- 
Jens Axel Søgaard



Posted on the users mailing list.