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 13:55:13 +0200 Message-ID: <87sj2o59zy.fsf@gnu.org> References: <87li92alhe.fsf@karetnikov.org> <874nforp12.fsf@gnu.org> <8762015b0w.fsf@karetnikov.org> <874nflx8e3.fsf@gnu.org> <871ua85t4w.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]:51293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USnR5-0007DZ-B0 for bug-guix@gnu.org; Thu, 18 Apr 2013 07:55:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USnQy-0000md-AV for bug-guix@gnu.org; Thu, 18 Apr 2013 07:55:31 -0400 Received: from [2a01:e0b:1:123:ca0a:a9ff:fe03:271e] (port=53658 helo=xanadu.aquilenet.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USnQy-0000l4-4u for bug-guix@gnu.org; Thu, 18 Apr 2013 07:55:24 -0400 In-Reply-To: <871ua85t4w.fsf@karetnikov.org> (Nikita Karetnikov's message of "Thu, 18 Apr 2013 09:01:51 +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: >> I think it=E2=80=99d be nice to have a =E2=80=98warning=E2=80=99 procedu= re in (guix ui), so >> things are uniform. > > It think it might be better to have a single 'warning' macro which could > handle several cases (errors, warnings and similar things). (Actually, > 'guix hash' should use errors, not warnings.) Yes, you=E2=80=99re right. > Here is a simplified version: > > (define-syntax define-output-macro Rather: =E2=80=98define-diagnostic=E2=80=99. > (syntax-rules () > ((_ name prefix) > (define-syntax name > (lambda (x) > (syntax-case x (_ N_) > ((name (_ str)) > (with-syntax ((prefix (datum->syntax x prefix))) > #'(display (string-append prefix str "\n")))) > ((name (N_ str1 str2)) > (with-syntax ((prefix (datum->syntax x prefix))) > #'(display (string-append prefix str1 str2 "\n")))))))))) You should reuse the body of the current =E2=80=98warning=E2=80=99 macro, t= hough. > (define-output-macro warning "warning: ") > (define-output-macro error* "error: ") You could use =E2=80=98report-error=E2=80=99 to avoid name clashes. But I think =E2=80=98leave=E2=80=99 should be enough, no? > scheme@(guile-user)> (warning (_ "foo")) > warning: foo > > scheme@(guile-user)> (error* (N_ "foo" "bar")) > error: foobar Note that =E2=80=98N_=E2=80=99 is meant to be an alias for =E2=80=98ngettex= t=E2=80=99, so the above form is invalid. > And here is a problem... Is it possible to compose a macro (e.g., > 'error*') with (exit 1) without touching the internals of > 'define-output-macro'? What about: (define-syntax-rule (leave args ...) (begin (error* args ...) (exit 1))) Thanks, Ludo=E2=80=99.