safely.lisp: SAFE-COPY shouldn't make two copies under CLisp.
[lisp] / mdw-base.lisp
index 2c1a79c..95b79de 100644 (file)
@@ -66,7 +66,7 @@
   "Debugging tool: print the expression X and its values."
   (let ((tmp (gensym)))
     `(let ((,tmp (multiple-value-list ,x)))
-       (format t "~&")
+       (fresh-line)
        (pprint-logical-block (*standard-output* nil :per-line-prefix ";; ")
         (format t
                 "~S = ~@_~:I~:[#<no values>~;~:*~{~S~^ ~_~}~]"
        t)
     (t nil)))
 
+(defmacro defconstant* (name value &key doc test)
+  "Define a constant, like `defconstant'.  The TEST is an equality test used
+   to decide whether to override the current definition, if any."
+  (let ((temp (gensym)))
+    `(eval-when (:compile-toplevel :load-toplevel :execute)
+       (let ((,temp ,value))
+        (unless (and (boundp ',name)
+                     (funcall ,(or test ''eql) (symbol-value ',name) ,temp))
+          (defconstant ,name ,value ,@(and doc (list doc))))
+        ',name))))
+
 (declaim (ftype (function nil ()) slot-unitialized))
 (defun slot-uninitialized ()
   "A function which signals an error.  Can be used as an initializer form in