I think I found a case where id-a binds id-b when (would-bind? id-a id-b) returns #f:
(define-syntax bind-test0 (lambda (stx) (define id #'x) (define shifted-id (syntax-shift-phase-level id -1)) (displayln (would-bind? id shifted-id)) (syntax-case stx () [(_ e) #`(let ([#,id e]) (displayln #,shifted-id))]))) (bind-test0 100) would print #f then 100. However, if shifted-ld and id are swapped in (let ...), an undefined identifier error will be raised, which is consistent with the return value of (would-bind? ...). Is there a bug in how (let ...) handles identifiers with shifted phase levels? Thanks, Yongming On Friday, July 26, 2019 at 7:07:49 AM UTC-4, Matthew Flatt wrote: > > At Thu, 25 Jul 2019 18:55:18 -0700 (PDT), Yongming Shen wrote: > > Based on my understanding, (bound-identifier=? id-a id-b) only returns > true > > if id-a would bind id-b AND id-b would bind id-a. Also based on my > > understanding, id-a will bind id-b doesn't imply that id-b will bind > id-a. > > So, if I only want to check whether id-a will bind id-b, which function > > should I use? > > There's not a predicate like that right now (I guess only because we > haven't needed it). > > Here's one way to implement the predicate: > > (define (would-bind? a b) > (subset? (list->set (hash-ref (syntax-debug-info a) 'context)) > (list->set (hash-ref (syntax-debug-info b) 'context)))) > > A built-in operation would work the same way, except that it could be > more efficient by not serializing scopes to a list in debugging > information and then converting the list back to a set. > > > Matthew > > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/b1a999bb-cc3a-4da8-ae31-11e5a3bff7d6%40googlegroups.com.