[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 13:55:13 +0200 |
User-agent: |
Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.3 (gnu/linux) |
Nikita Karetnikov <address@hidden> skribis:
>> I think it’d be nice to have a ‘warning’ procedure 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’re right.
> Here is a simplified version:
>
> (define-syntax define-output-macro
Rather: ‘define-diagnostic’.
> (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 ‘warning’ macro, though.
> (define-output-macro warning "warning: ")
> (define-output-macro error* "error: ")
You could use ‘report-error’ to avoid name clashes.
But I think ‘leave’ should be enough, no?
> scheme@(guile-user)> (warning (_ "foo"))
> warning: foo
>
> scheme@(guile-user)> (error* (N_ "foo" "bar"))
> error: foobar
Note that ‘N_’ is meant to be an alias for ‘ngettext’, 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’.
- 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 <=
- Re: Enhanced 'warning', Nikita Karetnikov, 2013/04/18
- Re: Enhanced 'warning', Ludovic Courtès, 2013/04/18
- [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