fix to alphalessp.



Here is the broken alphalessp in clmacs.lisp

(defun alphalessp (x y)
   (cond ((numberp x)
	 (if (numberp y) (< x y)
	   t))
	((stringp x)
	 (cond ((numberp y) nil)
	       ((stringp y)
		(string-lessp x y))
	       (t t)))
	((symbolp x)
	 (cond ((or (numberp y) (stringp y)) nil)
	       ((symbolp y)
		(let ((nx (symbol-name x))
		      (ny (symbol-name y)))
		  (declare (string nx ny))
		  (cond ((string-lessp nx ny)
			 t)
			((string-equal nx ny)
			 (cond ((eq nx ny) nil)
			       ((null (symbol-package x)) nil)
			       ((null (symbol-package y)) nil)
			       (t (string-lessp
				   (package-name (symbol-package x))
				   (package-name (symbol-package y))))))
			(t nil))))
	       ((consp y) t)))
	((listp x)
	 (cond ((or (numberp y) (stringp y)(symbolp y )) nil)
	       ((listp y)
		(or (alphalessp (car x) (car y))
		    (and (equal (car x) (car y))
		    (alphalessp (cdr x) (cdr y)))))
	       (t nil)))
	((or (numberp y) (stringp y) (symbolp y)(consp y))
	 nil)
	(t ;neither is of known type:
	  (alphalessp (format nil "~s" x)(format nil "~s" y)))))

;; here is a minimal change to fix it.


(defun alphalessp (x y)
   (cond ((numberp x)
	 (if (numberp y) (< x y)
	   t))
	((stringp x)
	 (cond ((numberp y) nil)
	       ((stringp y)
		(string< x y))            ;;;;fix
	       (t t)))
	((symbolp x)
	 (cond ((or (numberp y) (stringp y)) nil)
	       ((symbolp y)
		(let ((nx (symbol-name x))
		      (ny (symbol-name y)))
		  (declare (string nx ny))
		  (cond ((string< nx ny)     ;;;fix
			 t)
			((string= nx ny)     ;;; fix
			 (cond ((eq nx ny) nil)
			       ((null (symbol-package x)) nil)
			       ((null (symbol-package y)) nil)
			       (t (string<    ;;;fix
				   (package-name (symbol-package x))
				   (package-name (symbol-package y))))))
			(t nil))))
	       ((consp y) t)))
	((listp x)
	 (cond ((or (numberp y) (stringp y)(symbolp y )) nil)
	       ((listp y)
		(or (alphalessp (car x) (car y))
		    (and (equal (car x) (car y))
		    (alphalessp (cdr x) (cdr y)))))
	       (t nil)))
	((or (numberp y) (stringp y) (symbolp y)(consp y))
	 nil)
	(t ;neither is of known type:
	  (alphalessp (format nil "~s" x)(format nil "~s" y)))))

;; this fixes xmaxima.

I suggest a simpler version. We are not likely to have identical
symbols in different packages, since there is no way for the user
to create them.

Something like this:

(defun al(x y)
   (typecase x
     (number
      (typecase y
        (number (< x y))
        (t nil)))
     ((string symbol) (typecase y
		       ((string symbol) (string< x y))
		       (list t)
		       (t nil)))
     (list (typecase y
	    (list (or (al (car x)(car y))
		      (and (equal (car x)(car x))
			   (al (cdr x)(cdr y)))))
	    (t nil)))
     ;; should never be used...
     (t (if (or (atom y)(consp y)) nil  ;; unknown > ordinary
	 (al (format nil "~s" x)(format nil "~s"y))))))



;; I think this interchange about expand etc suggests that
;; we need a better way of reporting/ taking responsibility for/ fixing
;; bugs.  At a minimum:
;; 1. reporting a bug so that it can be reproduced
;; 2. agreeing that it is, in fact a bug not a feature.
;; 3. localizing it
;; 4. providing a patch or workaround
;; 5. updating the source


Surely this has been done for other systems under sourceforge.
RJF