Summary

replace ##sys#strip-syntax with version that handles cyclic structures

Metadata

Description

Alex Shinn contributed this enhanced version (verify and replace):

 (define (##sys#strip-syntax exp #!optional se alias)
  ;; if se is given, retain bound vars
  (let ((seen '()))
    (let walk ((x exp))
      (cond ((assq x seen) => cdr)
            ((symbol? x)
             (let ((x2 (if se
                           (lookup x se)
                           (get x '##core#macro-alias) ) ) )
               (cond ((get x '##core#real-name))
                     ((and alias (not (assq x se)))
                      (##sys#alias-global-hook x #f))
                     ((not x2) x)
                     ((pair? x2) x)
                     (else x2))))
            ((pair? x)
             (let ((cell (cons #f #f)))
               (set! seen (cons (cons x cell) seen))
               (set-car! cell (walk (car x)))
               (set-cdr! cell (walk (cdr x)))
               cell))
            ((vector? x)
             (let ((vec (make-vector (vector-length x))))
               (set! seen (cons (cons x vec) seen))
               (do ((ls (map walk (vector->list x)) (cdr ls)) (i 0 (+ i 1)))
                   ((null? ls) vec)
                 (vector-set! vec i (car ls)))))
            (else x)))))

Changes and comments

[2009-04-23 10:33:42 UTC] felix changed status from new to closed

[2009-04-23 10:33:42 UTC] felix set resolution to fixed

[2009-04-23 10:33:42 UTC] felix wrote:

Has been replaced in r14398.