SETF of GETF maxima bug



Your patch looks fine to me after a cursory examination. Do you have any
idea why the clisp people made the change?

--Jim

On Tue, 2003-02-18 at 20:56, Wolfgang Jenkner wrote:
> Maxima's TRACE is broken with newer CVS versions of Clisp.  This is
> due to what I think is an ANSI CL compatibility bug, which might turn
> up again elsewhere or with another Lisp implementation, so perhaps it
> is of some interest to other people, too.
> 
> The following artificial example (not involving Maxima) gives the
> gist.
> 
> (let* ((list-1 (list 'foo t))
>        (list-2 list-1))
>   (setf (getf list-1 'bar) t)
>   list-2)
> 
> => (FOO T) in SBCL, ECL and Clisp 2.28
> 
> but
> 
> => (BAR T FOO T) in the current CVS version of Clisp.
> 
> I think both results conform to ANSI CL, since the HyperSpec (GETF)
> states
> 
>   setf of getf is permitted to either write the value of place itself,
>   or modify of any part, car or cdr, of the list structure held by
>   place.
> 
> (In the example above, the place is the variable LIST-1, and Maxima
> behaves like it relied on SETF `writing' the value.)
> 
> In any case, I think it is easy to fix the TRACE bug.
> 
> MACSYMA-TRACE-SUB: Binding TEMP to some tail of FUN's MPROPS property
> (as possibly returned by MACSYMA-FSYMEVAL) is bad because the call to
> PUT-TRACE-INFO may modify it.  Just bind TEMP to the CAR of the tail
> instead (the type of FUN, something like MEXPR).
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Index: mtrace.lisp
> ===================================================================
> RCS file: /cvsroot/maxima/maxima/src/mtrace.lisp,v
> retrieving revision 1.3
> diff -C2 -r1.3 mtrace.lisp
> *** mtrace.lisp	2 Jul 2002 14:17:28 -0000	1.3
> --- mtrace.lisp	18 Feb 2003 04:27:39 -0000
> ***************
> *** 219,222 ****
> --- 219,223 ----
>   
>   (defun macsyma-trace-sub (fun handler ilist &aux temp)
> +   (declare (symbol temp))		; pathetic
>     (cond ((not (symbolp fun))
>   	 (mtell "~%Bad arg to TRACE: ~M" fun)
> ***************
> *** 232,246 ****
>   	  fun)
>   	 nil)
> ! 	((null (setq temp (macsyma-fsymeval fun)))
>   	 (mtell "~%~@:M has no functional properties." fun)
>   	 nil)
> ! 	((memq (car temp) '(mmacro translated-mmacro))
>   	 (mtell "~%~@:M is a macro, won't trace well, so use ~
>   		     the MACROEXPAND function to debug it." fun)
>   	 nil)
> ! 	((get (car temp) 'shadow)
> ! 	 (put-trace-info fun (car temp) ilist)
> ! 	 (trace-fshadow fun (car temp)
> ! 			(make-trace-hook fun (car temp) handler))
>   	 (list fun))
>   	(t
> --- 233,247 ----
>   	  fun)
>   	 nil)
> ! 	((not (setq temp (car (macsyma-fsymeval fun))))
>   	 (mtell "~%~@:M has no functional properties." fun)
>   	 nil)
> ! 	((memq temp '(mmacro translated-mmacro))
>   	 (mtell "~%~@:M is a macro, won't trace well, so use ~
>   		     the MACROEXPAND function to debug it." fun)
>   	 nil)
> ! 	((get temp 'shadow)
> ! 	 (put-trace-info fun temp ilist)
> ! 	 (trace-fshadow fun temp
> ! 			(make-trace-hook fun temp handler))
>   	 (list fun))
>   	(t
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Wolfgang
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
-- 
James Amundson <amundson@fnal.gov>