Nikita Karetnikov <[email protected]> skribis: >> You should reuse the body of the current ‘warning’ macro, though. > > What's wrong with this macro? > > (define-syntax define-diagnostic > (syntax-rules () > ((define-diagnostic name prefix)
Since there’s a single rule, you should use ‘define-syntax-rule’ instead, for conciseness. > (define-syntax name > (lambda (x) > (define (augmented-format-string fmt) > (string-append "~:[~*~;guix ~a: ~]~a" (syntax->datum fmt))) > > (syntax-case x (N_ _) ; these are literals, > yeah... > ((name (_ fmt) args ...) > (string? (syntax->datum #'fmt)) > (with-syntax ((fmt* (augmented-format-string #'fmt)) > (prefix (datum->syntax x prefix))) > #'(format (guix-warning-port) (gettext fmt*) > (program-name) (program-name) prefix > args ...))) > ((name (N_ singular plural n) args ...) > (and (string? (syntax->datum #'singular)) > (string? (syntax->datum #'plural))) > (with-syntax ((s (augmented-format-string #'singular)) > (p (augmented-format-string #'plural)) > (prefix (datum->syntax x prefix))) > #'(format (guix-warning-port) > (ngettext s p n %gettext-domain) > (program-name) (program-name) prefix > args ...))))))))) > > I'm getting the "extra ellipsis in form" error. This is a macro-generating macro. In the body of the generated macro, above, there are 4 occurrences of ‘...’. But these ellipses have no meaning in the outer macro; they are just meaningful in the context of the generated macro, hence the error. Instead, you should replace all 4 occurrences with (... ...). Yes, it’s always surprising at first. ;-) Ludo’.
