Mercurial > hg > xemacs-beta
diff lisp/cl-macs.el @ 225:12579d965149 r20-4b11
Import from CVS: tag r20-4b11
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:11:40 +0200 |
parents | 2c611d1463a6 |
children | 57709be46d1b |
line wrap: on
line diff
--- a/lisp/cl-macs.el Mon Aug 13 10:10:55 2007 +0200 +++ b/lisp/cl-macs.el Mon Aug 13 10:11:40 2007 +0200 @@ -451,12 +451,18 @@ Key values are compared by `eql'." (let* ((temp (if (cl-simple-expr-p expr 3) expr (gensym))) (head-list nil) + (last-clause (car (last clauses))) (body (cons 'cond (mapcar (function (lambda (c) - (cons (cond ((memq (car c) '(t otherwise)) t) + (cons (cond ((memq (car c) '(t otherwise)) + (or (eq c last-clause) + (error + "`%s' is allowed only as the last case clause" + (car c))) + t) ((eq (car c) 'ecase-error-flag) (list 'error "ecase failed: %s, %s" temp (list 'quote (reverse head-list)))) @@ -474,10 +480,19 @@ (if (eq temp expr) body (list 'let (list (list temp expr)) body)))) +;; #### CL standard also requires `ccase', which signals a continuable +;; error (`cerror' in XEmacs). However, I don't think it buys us +;; anything to introduce it, as there is probably much more CL stuff +;; missing, and the feature is not essential. --hniksic + ;;;###autoload (defmacro ecase (expr &rest clauses) "(ecase EXPR CLAUSES...): like `case', but error if no case fits. `otherwise'-clauses are not allowed." + (let ((disallowed (or (assq t clauses) + (assq 'otherwise clauses)))) + (if disallowed + (error "`%s' is not allowed in ecase" (car disallowed)))) (list* 'case expr (append clauses '((ecase-error-flag))))) ;;;###autoload