[plt-scheme] expansion of internal define v. set!

From: David Van Horn (dvanhorn at cs.uvm.edu)
Date: Tue Nov 11 00:14:40 EST 2003

(define-syntax f
  (syntax-rules ()
    ((f e) (define e 'by-syntax))))

(define-syntax f
  (syntax-rules ()
    ((f e) (set! e 'by-syntax))))

(let ((x 'undefined))
  (define (f _) (set! x 'by-procedure))
  (f x)

Using the first syntax definition of f results in 'by-syntax, but using the
second results in 'by-procedure.  I'm not sure what the right behavior is, but
it seems like either 'by-syntax or 'by-procedure should be returned in both
cases.  Is this a bug or am I missing some subtlety in macros that expand into
definitions?  (I tried this in a module and observed the same behavior.)

(The other Schemes I have lying around, MIT and 48, return 'by-procedure in
both cases.)


Posted on the users mailing list.