[racket] Confusion with syntax marks

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Sat Oct 1 04:11:36 EDT 2011

I am playing around with syntax marks and have a program whose output
confuses me.

#lang racket

(require (for-syntax racket/syntax))

(define-for-syntax marker (make-syntax-introducer))
(define-syntax (mark stx)
  (syntax-case stx ()
    ((_ arg ...) (marker #'(begin arg ...)))))

(define foo 'a)
 (define foo 'b)
 (mark foo))
(mark foo)
(mark (mark foo))

This outputs 5 values depending on which foo a binding refers to.
Racket outputs 'b 'b 'a 'a 'a. But when I use the macro stepper and
look at the marks on the uses line up with the bindings they alternate
'b 'a 'a 'b 'a, which is what I was expecting, but the arrows line up
with the output. Can someone explain why I am getting these results?

Posted on the users mailing list.