chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

#1804: compare doesn't compare if name is already bound


From: Chicken Trac
Subject: #1804: compare doesn't compare if name is already bound
Date: Sun, 05 Jun 2022 12:37:29 -0000

#1804: compare doesn't compare if name is already bound
---------------------------------------+----------------------
            Reporter:  Idiomdrottning  |       Type:  defect
              Status:  new             |   Priority:  major
           Milestone:  someday         |  Component:  expander
             Version:  5.2.0           |   Keywords:
Estimated difficulty:  medium          |
---------------------------------------+----------------------
 {{{
 (define-syntax frob-bad
   (ir-macro-transformer
    (lambda (exp inject compare)
      (let ((body (cdr exp)))
        `',(let desc ((friends '()) (body body))
            (cond
             ((null? body)
              friends)
             ((pair? body) (append (desc friends (car body)) (desc friends
 (cdr body))))
             ((any (cut compare body <>) '(x y z rest args))
              (cons (strip-syntax body) friends))
             (else '())))))))


 (equal?
  ((lambda (x) (frob-bad (reverse x))) 'foo) ; unexpected behavior. Since x
 is bound in the scope.
  ((lambda (p) (frob-bad (reverse x))) 'foo) ; expected behavior. Since x
 is not bound in the scope.
 )

 (define-syntax frob-good
   (ir-macro-transformer
    (lambda (exp inject compare)
      (let ((body (cdr exp)))
        `',(let desc ((friends '()) (body body))
             (cond
              ((null? body)
               friends)
              ((pair? body) (append (desc friends (car body)) (desc friends
 (cdr body))))
              ((memq (strip-syntax body) '(x y z rest args))
               (cons (strip-syntax body) friends))
              (else '())))))))

 (equal?
  ((lambda (x) (frob-good (reverse x))) 'foo) ; working workaround by eq?
 after strip-syntax instead of compare
  ((lambda (p) (frob-good (reverse x))) 'foo))
 }}}

-- 
Ticket URL: <https://bugs.call-cc.org/ticket/1804>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]