PATCH: Translating maxima macros



Hi,

The maxima translator currently expands maxima macros at compile time
not at run time. I think this should be corrected. Here is a patch to
expand macros at run time.

Andrej

Index: transl.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/transl.lisp,v
retrieving revision 1.42
diff -u -r1.42 transl.lisp
--- transl.lisp	1 Dec 2009 07:31:34 -0000	1.42
+++ transl.lisp	1 Dec 2009 10:03:15 -0000
@@ -748,15 +748,16 @@
 (defun toplevel-optimize-1 (form &aux (op (car form)) prop)
   (cond ((or (atom op)
 	     (member 'array op :test #'eq)) form)
-	((progn (setq op (car op))
-		(setq prop
-		      (if $transrun	; crock a minute.
-			  (or (get op 'translated-mmacro)
-			      (mget op 'mmacro))
-			  (or (mget op 'mmacro)
-			      (get op 'translated-mmacro)))))
-	 (mmacro-apply prop form))
-	((setq prop ($get op '$optimize))
+	;; DONT EXPAND MACROS AT TRANSLATION TIME
+	;((progn (setq op (car op)) nil))
+	;	(setq prop
+	;	      (if $transrun	; crock a minute.
+	;		  (or (get op 'translated-mmacro)
+	;		      (mget op 'mmacro))
+	;		  (or (mget op 'mmacro)
+	;		      (get op 'translated-mmacro)))))
+	; (mmacro-apply prop form))
+	((progn (setq op (car op)) (setq prop ($get op '$optimize)))
 	 ;; interesting, the MAPPLY here causes the simplification
 	 ;; of the form and the result.
 	 ;; The optimize property can be used to implement
Index: fcall.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/fcall.lisp,v
retrieving revision 1.14
diff -u -r1.14 fcall.lisp
--- fcall.lisp	1 Dec 2009 07:34:34 -0000	1.14
+++ fcall.lisp	1 Dec 2009 10:03:15 -0000
@@ -82,6 +82,9 @@
 	((macro-function f)
 	 (eval (cons f list-argl)))
 	((not (symbolp f)) (merror (intl:gettext "apply: expected symbol or
function; found: ~M") f))
+	;;; EXPAND MAXIMA MACROS
+	((setq f-prop (or (get f 'translated-macro) (mget f 'mmacro)))
+	 (meval (mmacro-apply f-prop `((,f) , at argl))))
 	((setq f-prop (get f 'mfexpr*))
 	 (funcall f-prop (cons nil argl)))
 	((setq f-prop (mget f 'mexpr))