emacs-devel
[Top][All Lists]
Advanced

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

Re: `assert' macro


From: John Paul Wallington
Subject: Re: `assert' macro
Date: Sun, 29 Jan 2006 19:17:00 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (berkeley-unix)

address@hidden (Johan Bockgård) writes:

> The `assert' macro from cl-macs is used in several files in Emacs. It
> expands into the following code.
>
>     (macroexpand '(assert x))
>      =>
>     (progn (or x (signal 'cl-assertion-failed (list 'x))) nil)
>
> Unless cl is loaded `cl-assertion-failed' is not a known error symbol
> though, so if the assertion fails it will produce a "peculiar error"
> that is impossible to catch. It should signal a known condition.

A minimal impact fix is to move the definition of that condition from
cl.el to subr.el.  Any objections ?


Index: lisp/subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.494
diff -u -r1.494 subr.el
--- lisp/subr.el        26 Jan 2006 17:54:27 -0000      1.494
+++ lisp/subr.el        29 Jan 2006 19:09:26 -0000
@@ -1831,6 +1831,12 @@
 This variable is meaningful on MS-DOG and Windows NT.
 On those systems, it is automatically local in every buffer.
 On other systems, this variable is normally always nil.")
+
+;; The `assert' macro from the cl package signals
+;; `cl-assertion-failed' at runtime so always define it.
+(put 'cl-assertion-failed 'error-conditions '(error))
+(put 'cl-assertion-failed 'error-message "Assertion failed")
+

 ;;;; Misc. useful functions.

Index: lisp/emacs-lisp/cl.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/cl.el,v
retrieving revision 1.46
diff -u -r1.46 cl.el
--- lisp/emacs-lisp/cl.el       6 Aug 2005 17:08:59 -0000       1.46
+++ lisp/emacs-lisp/cl.el       29 Jan 2006 19:09:27 -0000
@@ -580,9 +580,6 @@
 
 ;;; Miscellaneous.
 
-(put 'cl-assertion-failed 'error-conditions '(error))
-(put 'cl-assertion-failed 'error-message "Assertion failed")
-
 (defvar cl-fake-autoloads nil
   "Non-nil means don't make CL functions autoload.")
 




reply via email to

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