bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Enhanced 'warning' (was: [PATCH] Add 'guix hash'.)


From: Nikita Karetnikov
Subject: Enhanced 'warning' (was: [PATCH] Add 'guix hash'.)
Date: Thu, 18 Apr 2013 09:01:51 +0400

> 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.)

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)))

Attachment: pgpDbQ_lGEHn1.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]