Internal Definitions Edwin Zacharias 23 Jun 2006 08:32 UTC

I think the right way to handle internal definitions is that a
definition effects the entire lexical scope, but it does not take
effect until evaluated. Here is an example:

(define x 0)

(define (f)
  (set! x 1))

(define (g)
  (set! x 3))

(define-syntax foo
  (syntax-rules ()
    ((foo)
     (begin (define (pr) (write x))
            (pr)
            (f)
            (pr)
            (define x 2)
            (pr)
            (g)
            (pr)
            (define x 4)
            (pr)))))

(foo) (write x) (newline)

should write: 012243

With this there is no early scanning of left hand sides and no
restrictions on the placement of definitions or syntax
definitions.

--Edwin