melisgl / named-readtables

The official repo of named-readtables.
Other
66 stars 15 forks source link

%make-readtable-iterator broken on latest CCL #5

Closed fare closed 9 years ago

fare commented 9 years ago

CCL has recently changed its internal representation of readtables, and this broke named-readtables: http://trac.clozure.com/ccl/changeset/16442

It uses the sparse-vector data structure defined in level-1/sysutils.lisp, for which there is no defined iterator, even less so a publicly exported one.

The following code gets you further, but there are still failures in the test suite with it:

#+clozure
(defun %make-readtable-iterator (readtable)
  (flet ((ensure-alist (x)
           #.`(etypecase x
                (list x)
                ,@(uiop:if-let (sv (uiop:find-symbol* '#:sparse-vector :ccl nil))
                    `((,sv
                       (let ((table (uiop:symbol-call :ccl '#:sparse-vector-table x)))
                         (uiop:while-collecting (c)
                           (loop for i below (length table) do
                             (uiop:if-let ((v (svref table i)))
                               (loop with i8 = (ash i 8)
                                     for j below (length v) do
                                       (uiop:if-let ((datum (svref v j)))
                                         (c (cons (code-char (+ i8 j)) datum))))))))))))))
    (let ((char-macros
            (ensure-alist
             (#.(or (uiop:find-symbol* '#:rdtab.macros :ccl nil) (uiop:find-symbol* '#:rdtab.alist :ccl)) readtable))))
      (lambda ()
        (if char-macros
            (destructuring-bind (char . defn) (pop char-macros)
              (if (consp defn)
                  (values t char (car defn) t (ensure-alist (cdr defn)))
                  (values t char defn nil nil)))
            (values nil nil nil nil nil))))))
fare commented 9 years ago

I filed CCL ticket 1292 to get a stable interface from CCL: http://trac.clozure.com/ccl/ticket/1292

fare commented 9 years ago

PING?