From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: Enhanced 'warning' (was: [PATCH] Add 'guix hash'.) Date: Thu, 18 Apr 2013 09:01:51 +0400 Message-ID: <871ua85t4w.fsf@karetnikov.org> References: <87li92alhe.fsf@karetnikov.org> <874nforp12.fsf@gnu.org> <8762015b0w.fsf@karetnikov.org> <874nflx8e3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USgwM-0006H6-Pm for bug-guix@gnu.org; Thu, 18 Apr 2013 00:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USgwK-000222-4Q for bug-guix@gnu.org; Thu, 18 Apr 2013 00:59:22 -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: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: bug-guix@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > I think it=E2=80=99d be nice to have a =E2=80=98warning=E2=80=99 procedur= e 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.) Here is a simplified version: (define-syntax define-output-macro (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")))))))))) ;; (Is there a way not to repeat 'with-syntax'?) (define-output-macro warning "warning: ") (define-output-macro error* "error: ") scheme@(guile-user)> (warning (_ "foo")) warning: foo scheme@(guile-user)> (error* (N_ "foo" "bar")) error: foobar 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'? Here is an example with a function: (define (error**) (display "Error!\n")) (define (error-n-exit) (begin (error**) (exit 1))) --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJRb35GAAoJEM+IQzI9IQ38iKYP/RCFoCPdrKZ4+SjvvNkskNo4 I08LOSUhXwO/PKlvt2+24z3nFPNdubmBetdlfWi/87ODp/ygn/H+X3uscWAwtok7 cSysr97j6tnZ6p+Q3OJ6+l4vEIySjnuIKNFEn5ZxXUVN2EurDQNlfWfPe9Ywf5FC f0gdgdmUK029kacddUEE8lNLEWW59xtEMhJMDyRUhDeaBplObfvMZJu9A0p2LQZC d3yzPW7j5xnVf/zn8SGzHQqr7KNm6BEIFlFW1JNGowga4MnQRCFcjjS9sy2aLcXp 5S7gZ7rZVI2QXVDishSnPl8P06S0LXHUf7FJvExiNbqFupbQKKnxacX6OdQZ8gsG JVNQVJFicG4g2MPtvJTPvTkC7qCnZ4nJlvmtaOBxUEqs1u8ipnHnMTHu6PdHczdk x7g7sXBxlQwOrVDSpgfE4sIHlVqWnJzCxy8mJexND46wqFDTT4rUn4wTfjHR2tNm tQxQDj+x32t2X915Y9MriYSUSRyfg3H3HRKAmUpmaXhLgrpg1Ha6QBvysS1+PIXM hfItioNBxGV/g49P+OzlPUd+HkiB+MupE+PG5k1VlOY1UWkTC3LjrlKg+jgB9l9l xqk1BHsFJHdBdLv8O2ud9K70zYuY/1Wdut/K1Si+GoBKLJVCKQz4P+SqaFALTYES +ZBEyXQ1DdKS1aUl6+mM =Whok -----END PGP SIGNATURE----- --=-=-=--