On Fri, 2009-06-19 at 18:54 +1000, Ramana Kumar wrote: > Does this code presume that define and syntax will always be bound at > the site of the call to unbound-identifier??
No. I'm guessing you're wondering about this case: (unbound-identifier? #'define) I.e., when the argument is a syntax template; otherwise the site of the call doesn't matter. In Aziz's new predicate, the first three checks against #'define, #'syntax, or #'ctxt are done because those identifiers are all that's in the lexical context of the #'here, and so they need to be checked before the last free-identifier=? because it won't work for them, but it will work for all other identifiers. If a #'define, #'syntax, or #'ctxt, which is bound to the same thing as imported in the (b bound) library, is given, then one of the first three checks will fail (because free-identifier=? will see it's bound to the same thing), and this is correct because it is bound. If a #'define, #'syntax, or #'ctxt, which is unbound or is bound to something different than imported in the (b bound) library, is given, then the first three checks will pass. If it is unbound, the last check will return #T because the same symbol in the lexical context of the #'here is not bound (else one of the first three checks would have already failed) and so the two identifiers are both unbound and so are compared according to symbolic spelling. If the given identifier is bound (as described at the start of this paragraph), the last check will return #F because the same symbol in the lexical context of the #'here is not bound to the same thing as the given identifier (even though they're spelling the same). The trick to the first three checks is that their identifiers refer to the same bindings as those in the lexical context of the #'here. -- : Derick ---------------------------------------------------------------- > On Fri, Jun 19, 2009 at 6:50 PM, Abdulaziz Ghuloum<aghul...@gmail.com> wrote: > > > > On Jun 19, 2009, at 2:27 AM, Derick Eddington wrote: > > > >> That's clever, but it's broken: > > > > Here's another attempt. All the (for ---) stuff is mocked up of course > > just so that larceny does not throw exceptions at uses of free-id=? and > > so that PLT does not mark things that are actually bound as unbound. > > > > Aziz,,, > > > > $ cat b/bound.sls b/bound-ctxt.sls > > #!r6rs > > (library (b bound) > > (export unbound-identifier?) > > (import (for (rnrs) (meta -1)) (for (b bound-ctxt) (meta -1) run)) > > (define (unbound-identifier? x) > > (and > > (not (free-identifier=? x #'define)) > > (not (free-identifier=? x #'syntax)) > > (not (free-identifier=? x #'ctxt)) > > (free-identifier=? x ;; for larceny, this must come last > > (datum->syntax ctxt (syntax->datum x)))))) > > > > #!r6rs > > (library (b bound-ctxt) > > (export ctxt) > > (import (only (rnrs) define syntax)) > > (define ctxt #'here)) > > > > > >