Skip to content

Instantly share code, notes, and snippets.

@dyoo
Created October 26, 2012 21:39
Show Gist options
  • Save dyoo/3961723 to your computer and use it in GitHub Desktop.
Save dyoo/3961723 to your computer and use it in GitHub Desktop.
playing with expand and bound-identifier=?
#lang racket/base
(require (for-template '#%kernel))
(define a-stx #'(define-values (f) (#%plain-lambda (x)
(let-values ([(x) 42]) x))))
(syntax-case a-stx ()
[(d-v (fun) (lam (id-0) (l-v (((id-1) v)) id-2)))
(begin
(printf "free-identifier=? ~s\n" (free-identifier=? #'id-1 #'id-2))
(printf "bound-identifier=? ~s\n" (bound-identifier=? #'id-1 #'id-2))
(printf "bound-identifier=? ~s\n" (bound-identifier=? #'id-0 #'id-1))
(printf "bound-identifier=? ~s\n" (bound-identifier=? #'id-0 #'id-2)))])
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(newline)(newline)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define an-expanded-stx (parameterize ([current-namespace (make-base-namespace)])
(expand a-stx)))
(syntax-case an-expanded-stx ()
[(d-v (fun) (lam (id-0) (l-v (((id-1) v)) id-2)))
(begin
(printf "free-identifier=? ~s\n" (free-identifier=? #'id-1 #'id-2))
(printf "bound-identifier=? ~s\n" (bound-identifier=? #'id-1 #'id-2))
(printf "bound-identifier=? ~s\n" (bound-identifier=? #'id-0 #'id-1))
(printf "bound-identifier=? ~s\n" (bound-identifier=? #'id-0 #'id-2)))])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment