]> git.jsancho.org Git - gacela.git/blobdiff - gacela_misc.lisp
(no commit message)
[gacela.git] / gacela_misc.lisp
index 9a017877b2391a30bd2fae934f760d8dea22c35a..e19f3a2fe5e4aa0213ee8fd9e7710ff312109244 100755 (executable)
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-(in-package :gacela)
+
+(eval-when (compile load eval)
+          (when (not (find-package 'gacela)) (make-package 'gacela :nicknames '(gg) :use '(lisp)))
+          (in-package 'gacela :nicknames '(gg) :use '(lisp)))
+
 
 (defconstant INFINITY MOST-POSITIVE-LONG-FLOAT)
 
     `(block secure
        (defun si::universal-error-handler (error-name correctable function-name continue-format-string error-format-string &rest args)
         ,(when output-stream
-           `(format ,output-stream
-                    (cond ((eq error-name :WRONG-TYPE-ARGUMENT) (string error-name))
-                          (t error-format-string))))
+           `(write-line
+             (cond ((eq error-name :WRONG-TYPE-ARGUMENT) (string error-name))
+                   (t error-format-string))
+             ,output-stream))
         (setf (symbol-function 'si::universal-error-handler) ,error-handler)
         (return-from secure))
        (let (result-eval)
         (setf (symbol-function 'si::universal-error-handler) ,error-handler)
         result-eval))))
 
+(defmacro persistent-let (name vars &rest forms)
+  (labels ((get-vars (vars)
+                    (cond ((null vars) nil)
+                          (t (cons (if (consp (car vars)) (caar vars) (car vars))
+                                   (get-vars (cdr vars)))))))
+   
+         `(let ,(cond ((functionp name)
+                       (let ((old-vars (funcall name)))
+                         (cond ((equal (get-vars vars) (get-vars old-vars)) old-vars)
+                               (t vars))))
+                      (t vars))
+            (defun ,name ()
+              ,(let ((lvars (get-vars vars)))
+                 `(mapcar (lambda (x y) (list x y)) ',lvars ,(cons 'list lvars))))
+            ,@forms)))
+
 ;Geometry
 (defun dotp (dot)
   (match-pattern dot '(0 0)))