ruricolist / serapeum

Utilities beyond Alexandria
MIT License
425 stars 42 forks source link

STABLE-SORT of reader literal #44

Closed fiddlerwoaroof closed 4 years ago

fiddlerwoaroof commented 4 years ago

In types.lisp, the symbol *vref-by-type* is initialized like this:

(defparameter *vref-by-type*
  (stable-sort
   '((simple-bit-vector . sbit)
     (bit-vector . bit)
     (string . char)
     (simple-string . schar)
     (simple-vector . svref)
     (t . aref))
   #'proper-subtype-p
   :key #'car))

Since STABLE-SORT is a destructive operation, invoking it on a reader literal is undefined and sbcl 1.5.7 issues a warning when compiling this code. The simplest fix is to switch to:

(defparameter *vref-by-type*
  (stable-sort
   (list '(simple-bit-vector . sbit)
         '(bit-vector . bit)
         '(string . char)
         '(simple-string . schar)
         '(simple-vector . svref)
         '(t . aref))
   #'proper-subtype-p
   :key #'car))

Which sorts a freshly-consed list.