51 lines
2.4 KiB
Racket
51 lines
2.4 KiB
Racket
#lang racket
|
|
(require (for-syntax syntax/parse))
|
|
#;(define-syntax (test stx)
|
|
(syntax-parse stx
|
|
[(_ x)
|
|
#:with (_ (x2) x3) (local-expand #'(λ (x) (test2 x)) 'expression null)
|
|
#:with (_ (x4) x5) (local-expand #'(λ (x) x) 'expression null)
|
|
#:when (printf "test1: ~a\n" (free-identifier=? #'x2 #'x3))
|
|
#'(void)]))
|
|
#;(define-syntax (test2 stx)
|
|
(syntax-parse stx
|
|
[(_ x)
|
|
#:with xx (local-expand #'x 'expression null)
|
|
#:when (printf "test2: ~a\n" (bound-identifier=? #'x #'xx))
|
|
#:with (lam (xxx) xxxx) (local-expand #'(λ (x) xx) 'expression null)
|
|
#:when (printf "test2 post: ~a\n" (bound-identifier=? #'xxx #'xxxx))
|
|
(local-expand #'x 'expression null)]))
|
|
#;(test x)
|
|
|
|
(define x 1)
|
|
(define-for-syntax (f y)
|
|
(printf "f: ~a\n" (bound-identifier=? y #'x)))
|
|
(define-syntax (test stx)
|
|
(syntax-parse stx
|
|
[(_ y)
|
|
#:when (printf "test: ~a\n" (bound-identifier=? #'x #'y))
|
|
#:when (printf "test: ~a\n" (bound-identifier=? (syntax-local-introduce #'x) #'y))
|
|
#:when (printf "test: ~a\n" (bound-identifier=? ((make-syntax-delta-introducer #'y #'x) #'x) #'y))
|
|
#:when (printf "test: ~a\n" (bound-identifier=? ((make-syntax-delta-introducer #'x #'y) #'x) #'y))
|
|
#:when (printf "test: ~a\n" (bound-identifier=? (syntax-local-introduce #'y) #'x)) ; negates mark?
|
|
#:when (printf "test: ~a\n" (bound-identifier=? ((make-syntax-delta-introducer #'y #'x) #'y) #'x))
|
|
#:when (printf "test: ~a\n" (bound-identifier=? ((make-syntax-delta-introducer #'x #'y) #'y) #'x))
|
|
#:when (printf "test: ~a\n" (bound-identifier=? (syntax-local-introduce (syntax-local-introduce #'y)) #'x)) ; double negation means no again
|
|
#:when (f #'x)
|
|
#:when (local-expand #'(test3 y) 'expression null)
|
|
#'(test2 y)]))
|
|
(define-syntax (test2 stx)
|
|
(syntax-parse stx
|
|
[(_ z)
|
|
#:when (printf "test2: ~a\n" (bound-identifier=? #'x #'z))
|
|
#:when (printf "test2: ~a\n" (bound-identifier=? #'x (syntax-local-introduce #'z)))
|
|
#:when (printf "test2: ~a\n" (bound-identifier=? #'z (syntax-local-introduce #'x)))
|
|
#'(void)]))
|
|
(define-syntax (test3 stx)
|
|
(syntax-parse stx
|
|
[(_ z)
|
|
#:when (printf "test3: ~a\n" (bound-identifier=? #'x #'z))
|
|
#:when (printf "test3: ~a\n" (bound-identifier=? #'x (syntax-local-introduce #'z)))
|
|
#:when (printf "test3: ~a\n" (bound-identifier=? #'z (syntax-local-introduce #'x)))
|
|
#'(void)]))
|
|
(test x) |