[movitz-cvs] CVS update: movitz/losp/muerte/arithmetic-macros.lisp

Frode Vatvedt Fjeld ffjeld at common-lisp.net
Fri Jul 23 15:35:23 UTC 2004


Update of /project/movitz/cvsroot/movitz/losp/muerte
In directory common-lisp.net:/tmp/cvs-serv7818

Modified Files:
	arithmetic-macros.lisp 
Log Message:
Made + compiler-macro a bit smarter about constant sub-forms.

Date: Fri Jul 23 08:35:23 2004
Author: ffjeld

Index: movitz/losp/muerte/arithmetic-macros.lisp
diff -u movitz/losp/muerte/arithmetic-macros.lisp:1.4 movitz/losp/muerte/arithmetic-macros.lisp:1.5
--- movitz/losp/muerte/arithmetic-macros.lisp:1.4	Tue Jul 20 01:53:50 2004
+++ movitz/losp/muerte/arithmetic-macros.lisp	Fri Jul 23 08:35:23 2004
@@ -10,7 +10,7 @@
 ;;;; Author:        Frode Vatvedt Fjeld <frodef at acm.org>
 ;;;; Created at:    Sat Jul 17 13:42:46 2004
 ;;;;                
-;;;; $Id: arithmetic-macros.lisp,v 1.4 2004/07/20 08:53:50 ffjeld Exp $
+;;;; $Id: arithmetic-macros.lisp,v 1.5 2004/07/23 15:35:23 ffjeld Exp $
 ;;;;                
 ;;;;------------------------------------------------------------------
 
@@ -57,7 +57,13 @@
 		  finally (return (if (zerop constant-term)
 				      non-constant-operands
 				    (cons constant-term non-constant-operands))))))
-	 `(+ (+ ,(first operands) ,(second operands)) ,@(cddr operands))))))
+	 (cond
+	  ((null operands)
+	   0)
+	  ((not (cdr operands))
+	   (check-type (car operands) integer)
+	   (car operands))
+	  (t `(+ (+ ,(first operands) ,(second operands)) ,@(cddr operands))))))))
 
 (define-compiler-macro 1+ (number)
   `(+ 1 ,number))





More information about the Movitz-cvs mailing list