20-CS-4003-001 Organization of Programming Languages Fall 2018

Lambda calculus, Type theory, Formal semantics, Program analysis

    Prev     Next     All lectures        Code

Macros in the Scheme language

;; accidental capture of identifiers
;; hygienic macro expansion

(define a 0)
(define b 0)

(define-syntax inci
  (syntax-rules ()
    ((inci i) (begin (set! a 0) (+ i 1)))))

(define main
  (lambda ()
    (let ((a 10) (b 10))
      (cons (inci a) (inci b)))))
 -  But macros are hygienic in Scheme as the example to the left shows.