Difference between free identifier =? and bound-identifier =?

Trying to understand free id =? and bound-identifier = ?. Can someone give me equivalent code examples that use the free id =? will return true and use bound-identifier =? will return false.

thanks

+7
source share
1 answer

Here is an example:

(define-syntax (compare-with-x stx) (syntax-case stx () [(_ x-in) (with-syntax ([free=? (free-identifier=? #'x-in #'x)] [bound=? (bound-identifier=? #'x-in #'x)]) #'(list free=? bound=?))])) (define-syntax go (syntax-rules () [(go) (compare-with-x x)])) (go) ;; => '(#t #f) 

x entered by go has a label from this extension step on it, but x in compare-with-x does not, therefore bound-identifier=? considers them different.

Here is another example:

 (define-syntax (compare-xs stx) (syntax-case stx () [(_ x1 x2) (with-syntax ([free=? (free-identifier=? #'x2 #'x2)] [bound=? (bound-identifier=? #'x1 #'x2)]) #'(list free=? bound=?))])) (define-syntax go2 (syntax-rules () [(go2 x-in) (compare-xs x-in x)])) (go2 x) ;; => '(#t #f) 

Here go2 also enters x with a label, while x given by go2 as an argument has no label. The same story.

+5
source

All Articles