[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Enhanced 'warning'
From: |
Ludovic Courtès |
Subject: |
Re: Enhanced 'warning' |
Date: |
Thu, 18 Apr 2013 22:59:52 +0200 |
User-agent: |
Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.3 (gnu/linux) |
Nikita Karetnikov <address@hidden> 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’.
- Re: [PATCH] Add 'guix hash'., (continued)
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/05
- Re: [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/09
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/11
- master: FAIL: tests/guix-package.sh (was: [PATCH] Add 'guix hash'.), Nikita Karetnikov, 2013/04/12
- Re: master: FAIL: tests/guix-package.sh, Nikita Karetnikov, 2013/04/12
- Re: master: FAIL: tests/guix-package.sh, Ludovic Courtès, 2013/04/12
- Enhanced 'warning' (was: [PATCH] Add 'guix hash'.), Nikita Karetnikov, 2013/04/18
- Re: Enhanced 'warning', Nikita Karetnikov, 2013/04/18
- Re: Enhanced 'warning', Ludovic Courtès, 2013/04/18
- Re: Enhanced 'warning', Nikita Karetnikov, 2013/04/18
- Re: Enhanced 'warning',
Ludovic Courtès <=
- [PATCH] ui: Add a 'define-diagnostic' macro. (was: Enhanced 'warning'), Nikita Karetnikov, 2013/04/19
- Re: [PATCH] ui: Add a 'define-diagnostic' macro., Nikita Karetnikov, 2013/04/20
- Re: [PATCH] ui: Add a 'define-diagnostic' macro., Ludovic Courtès, 2013/04/20
- Re: [PATCH] ui: Add a 'define-diagnostic' macro., Nikita Karetnikov, 2013/04/20
- Re: [PATCH] ui: Add a 'define-diagnostic' macro., Ludovic Courtès, 2013/04/20
- Re: [PATCH] ui: Add a 'define-diagnostic' macro., Ludovic Courtès, 2013/04/20
- Re: [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/21
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/21