From 4eeaf67c8cd0ca792d9021b5bca2be5cfc010cd5 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 11 Jun 2010 11:17:44 +0200 Subject: [PATCH] error in terms of case-lambda * module/ice-9/boot-9.scm (error): Redefine using case-lambda. --- module/ice-9/boot-9.scm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index dae879ac0..56c7d734f 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -845,16 +845,15 @@ If there is no handler at all, Guile prints an error and then exits." ;;; {Error Handling} ;;; -(define (error . args) - (save-stack) - (if (null? args) - (scm-error 'misc-error #f "?" #f #f) - (let loop ((msg "~A") - (rest (cdr args))) - (if (not (null? rest)) - (loop (string-append msg " ~S") - (cdr rest)) - (scm-error 'misc-error #f msg args #f))))) +(define error + (case-lambda + (() + (save-stack) + (scm-error 'misc-error #f "?" #f #f)) + ((message . args) + (save-stack) + (let ((msg (string-join (cons "~A" (make-list (length args) "~S"))))) + (scm-error 'misc-error #f msg (cons message args) #f))))) ;; bad-throw is the hook that is called upon a throw to a an unhandled ;; key (unless the throw has four arguments, in which case