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: Sat, 24 Feb 2018 09:59:47 -0000

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

Comment (by sjamaan):

 Correction to avoid confusion: The "identifier used twice" error in match-
 foo is caused by the {{{?whatever}}} appearing twice.

 The correct definition would be:

 {{{
 (module match-it (match-foo)
  (import scheme)

  (define-syntax match-foo
    (syntax-rules ()
      ((_ ?input)
       (let-syntax ((match-identifier
                     (syntax-rules (foo)
                       ((_ foo foo) #t)
                       ((_ foo ?whatever) 'mismatch)
                       ((_ ?whatever ?whatever2) #f))))
         (match-identifier foo ?input))))))

 (module myfoo (foo)
   (import scheme)
   (define foo 1))

 (import match-it)
 (print (match-foo foo))

 (import myfoo)
 (print (match-foo foo))
 }}}

 This will indeed print #t twice in both Chibi and Gauche.

 Nevertheless, the fixed definition in Scheme48 prints:

 {{{
 Welcome to Scheme 48 1.9 (made by binet on 2017-03-16)
 See http://s48.org/ for more information.
 Please report bugs to address@hidden
 Get more information at http://www.s48.org/.
 Type ,? (comma question-mark) for help.
 > ,config ,load packages.scm
 > ,open match-it-s48
 > (match-foo foo)

 warning: invalid variable reference [get-location]
          match-foo
          #{package 284 user}

 assertion-violation: undefined variable [global]
                      foo
                      user
 1> ,open myfoo-s48
 Newly accessible in user: (foo)
 1> (match-foo foo)

 warning: invalid variable reference [get-location]
          match-foo
          #{package 284 user}

 assertion-violation: undefined variable [global]
                      match-foo
                      match-it-s48
 }}}

 And Racket:

 {{{
 Welcome to Racket v6.7.
 > (require "./match-it-racket.scm")
 > (match-foo foo)
 #t
 > (require "./myfoo-racket.scm")
 > (match-foo foo)
 'mismatch
 > (define foo 2)
 > (match-foo foo)
 #t
 }}}

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