From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Enhanced 'warning' Date: Thu, 18 Apr 2013 22:59:52 +0200 Message-ID: <87r4i7wo53.fsf@gnu.org> References: <87li92alhe.fsf@karetnikov.org> <874nforp12.fsf@gnu.org> <8762015b0w.fsf@karetnikov.org> <874nflx8e3.fsf@gnu.org> <871ua85t4w.fsf@karetnikov.org> <87sj2o59zy.fsf@gnu.org> <877gjzd4gb.fsf@karetnikov.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USvw3-0001dv-Kx for bug-guix@gnu.org; Thu, 18 Apr 2013 17:00:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USvw2-0005sR-86 for bug-guix@gnu.org; Thu, 18 Apr 2013 17:00:03 -0400 Received: from [2a01:e0b:1:123:ca0a:a9ff:fe03:271e] (port=34330 helo=xanadu.aquilenet.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USvw2-0005m7-14 for bug-guix@gnu.org; Thu, 18 Apr 2013 17:00:02 -0400 In-Reply-To: <877gjzd4gb.fsf@karetnikov.org> (Nikita Karetnikov's message of "Thu, 18 Apr 2013 23:27:48 +0400") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Nikita Karetnikov Cc: bug-guix@gnu.org Nikita Karetnikov skribis: >> You should reuse the body of the current =E2=80=98warning=E2=80=99 macro= , though. > > What's wrong with this macro? > > (define-syntax define-diagnostic > (syntax-rules () > ((define-diagnostic name prefix) Since there=E2=80=99s a single rule, you should use =E2=80=98define-syntax-= rule=E2=80=99 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, y= eah... > ((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 =E2=80=98...=E2=80=99. But these ellipse= s 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=E2=80=99s always surprising at first. ;-) Ludo=E2=80=99.