Below two versions of a very stripped version of a macro I have made.
In version 1 background expansion and check-syntax show binding arrows
within macro stx-case.
However, in version 2 the arrows are not shown.
How come?
Thanks, Jos
 
#lang racket
 
(require (for-syntax racket))
 
;;; version 1
 
(begin-for-syntax
 (define-syntax (stx-case stx) ; Here background expansion and macro stepper
  (syntax-case stx ()          ; do show binding arrows in stx-case.
   ((_ stx-expr clause ...)
    (with-syntax
     ((+ (datum->syntax stx '+))
      (- (datum->syntax stx '-))
      (* (datum->syntax stx '*))
      (/ (datum->syntax stx '/)))
   #'(syntax-case stx-expr (+ - * /) clause ...))))))
 
(define-syntax (a stx)
 (stx-case stx
  ((_ +) #''plus)
  ((_ -) #''minus)
  ((_ *) #''mult)
  ((_ /) #''div)
  ((_ x) #''x)))
 
;;; version 2
 
(define-syntax (b stx)
 (define-syntax (stx-case stx) ; Here background expansion and macro stepper
  (syntax-case stx ()          ; do NOT show binding arrows in stx-case.
   ((_ stx-expr clause ...)
    (with-syntax
     ((+ (datum->syntax stx '+))
      (- (datum->syntax stx '-))
      (* (datum->syntax stx '*))
      (/ (datum->syntax stx '/)))
   #'(syntax-case stx-expr (+ - * /) clause ...)))))
 (stx-case stx
  ((_ +) #''plus)
  ((_ -) #''minus)
  ((_ *) #''mult)
  ((_ /) #''div)
  ((_ x) #''x)))
 
; Both a and b work correctly:
 
(a +)
(a else)
(b -)
(b else)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to