chicken-janitors
[Top][All Lists]
Advanced

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

Re: [Chicken-janitors] #1441: Macro keywords unexpectedly match against


From: Chicken Trac
Subject: Re: [Chicken-janitors] #1441: Macro keywords unexpectedly match against imported identifiers
Date: Mon, 15 Jan 2018 21:10:13 -0000

#1441: Macro keywords unexpectedly match against imported identifiers
-------------------------------------+-------------------------------------
            Reporter:  sjamaan       |      Owner:  sjamaan
                Type:  defect        |     Status:  new
            Priority:  major         |  Milestone:  someday
           Component:  expander      |    Version:  4.13.0
          Resolution:                |   Keywords:  hygiene, syntax-rules,
Estimated difficulty:  hard          |  capture
-------------------------------------+-------------------------------------
Description changed by sjamaan:

Old description:

> As reported by Joerg Wittenberger, Al Petrofsky's "unhygienic extraction"
> of identifiers via `syntax-rules` keywords list fails when the identifier
> was imported from another module.
>
> A simplified example:
>
> {{{
> (module break (break)
>   (import scheme)
>   (define break "elsewhere"))
>

> (module unhygienic-loop (loop)
>   (import scheme)
>
> (define-syntax find-identifier
>   (syntax-rules ()
>     ((_ ident (x . y) sk fk)
>      (find-identifier ident x sk (find-identifier ident y sk fk)))
>     ((_ ident #(x ...) sk fk)
>      (find-identifier ident (x ...) sk fk))
>     ((_ ident form sk fk)
>      (let-syntax
>          ((check
>            (syntax-rules (ident)
>              ((_ ident ident* (s-f . s-args) fk_) (s-f ident* . s-args))
>              ((_ x y sk_ fk_) fk_))))
>        (check form form sk fk)))))
>

> (define-syntax loop
>   (syntax-rules ()
>     ((_ . exps)
>      (let-syntax
>          ((l (syntax-rules ()
>                ((_ ident exps_)
>                 (call-with-current-continuation
>                  (lambda (ident)
>                    (let f ()
>                      (begin 'prevent-empty-begin . exps_)
>                      (f))))))))
>        (find-identifier break exps (l exps) (l bogus exps)))))))
>

> (module foo ()
>
> (import scheme break unhygienic-loop)
>
> ;; Uncomment these and comment the above to see the differing behaviour:
> ;; (import scheme unhygienic-loop)
>
> ;; This definition is not required
> ;; (define break "local")
>
> (display (loop (break 'foo))))
> }}}
>
> This appears to be incorrect, at least when compared to Chibi on an
> equivalent set of R7RS modules, it behaves identically in the case where
> the identifier is defined locally, undefined, or defined by another
> module.

New description:

 As reported by Joerg Wittenberger, Al Petrofsky's "unhygienic extraction"
 of identifiers via `syntax-rules` keywords list fails when the identifier
 was imported from another module.

 A simplified example:

 {{{
 (module break (break)
   (import scheme)
   (define break "elsewhere"))


 (module unhygienic-loop (loop)
   (import scheme)

 (define-syntax find-identifier
   (syntax-rules ()
     ((_ ident (x . y) sk fk)
      (find-identifier ident x sk (find-identifier ident y sk fk)))
     ((_ ident #(x ...) sk fk)
      (find-identifier ident (x ...) sk fk))
     ((_ ident form sk fk)
      (let-syntax
          ((check
            (syntax-rules (ident)
              ((_ ident ident* (s-f . s-args) fk_) (s-f ident* . s-args))
              ((_ x y sk_ fk_) fk_))))
        (check form form sk fk)))))


 (define-syntax loop
   (syntax-rules ()
     ((_ . exps)
      (let-syntax
          ((l (syntax-rules ()
                ((_ ident exps_)
                 (call-with-current-continuation
                  (lambda (ident)
                    (let f ()
                      (begin 'prevent-empty-begin . exps_)
                      (f))))))))
        (find-identifier break exps (l exps) (l bogus exps)))))))


 (module foo ()

 (import scheme break unhygienic-loop)

 ;; Uncomment these and comment the above to see the differing behaviour:
 ;; (import scheme unhygienic-loop)

 ;; This definition is not required
 ;; (define break "local")

 (display (loop (break 'foo))))
 }}}

 This appears to be incorrect, at least when compared to Chibi on an
 equivalent set of R7RS modules, it behaves identically in the case where
 the identifier is defined locally, undefined, or defined by another
 module.

 In CHICKEN 4.12 and earlier, this code behaves the same regardless of
 where the identifier came from.

--

--
Ticket URL: <https://bugs.call-cc.org/ticket/1441#comment:1>
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]