chicken-janitors
[Top][All Lists]
Advanced

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

Re: [Chicken-janitors] #944: Macro-renamed definitions in begin bodies d


From: Chicken Trac
Subject: Re: [Chicken-janitors] #944: Macro-renamed definitions in begin bodies don't get seen by later forms (but only in modules)
Date: Wed, 31 Oct 2012 20:54:04 -0000

#944: Macro-renamed definitions in begin bodies don't get seen by later forms
(but only in modules)
-----------------------+----------------------------------------------------
  Reporter:  sjamaan   |       Owner:  sjamaan                           
      Type:  defect    |      Status:  new                               
  Priority:  major     |   Milestone:  4.9.0                             
 Component:  expander  |     Version:  4.8.x                             
Resolution:            |    Keywords:  expander, macros, hygiene, modules
-----------------------+----------------------------------------------------

Comment(by sjamaan):

 Replying to [comment:8 megane]:
 > Replying to [comment:7 megane]:
 >
 > Works inside a module:
 > ;; Warning: reference to possibly unbound identifier `bar'
 >
 > ;; Error: module unresolved: m1

 It looks like we're all equally confused... That's the original bugreport!

 Also, I re-tested and it turns out MIT Scheme has a similar bug:

 {{{
 1 ]=> (define-syntax foo (syntax-rules () ((_) (begin (define bar 1)
 (display bar) (newline)))))

 ;Value: foo

 1 ]=> (foo)

 ;Unbound variable: bar
 }}}

 And Gauche behaves like Chicken:

 {{{
 gosh> (define-syntax foo (syntax-rules () ((_) (begin (define bar 1)
 (display bar) (newline)))))
 #<undef>
 gosh> (foo)
 1
 #<undef>
 gosh> bar
 1
 }}}

 Chibi and Scheme48 print 1 and then raise an exception that bar is
 undefined after typing "bar".
 I'm still debating what the correct behavior is.  Maybe (define bar 1)
 should really define bar at toplevel, which should be visible to the user?
 It doesn't feel right, though.

 R5RS says: "Note that a define at top level may or may not introduce a
 binding; see section 5.2"

 If we allow the definition to leak out and overwrite the user's code, the
 "fix" is actually rather trivial.  I'll attach one shortly.

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/944#comment:9>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

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