Hey Ramana,

On Sat, 20 Jun 2009 03:46:51 -0400, Ramana Kumar <[email protected]>  
wrote:

> How would you write bound-identifier? in R6RS? (A function that takes
> an identifier and returns a boolean indicating whether that identifier
> is bound.)

A quick read over the R6RS stuff indicates that it is similar and/or the  
same as the Chez implementation of 'free-identifier=?', which I think is  
sufficient in this case to make the 'bound-identifier?' form you desire.

> I'm interested in
> 1. A clearly portable and clean definition in R6RS, if it exists, or
> 2. Any reasons why including a primitive bound-identifier? (in the
> syntax-case library, say) would be a bad idea (presuming there is no
> solution to 1).

I do not know if this is really clearly portable, but to me it is not  
obviously importable either. Since this can be done at any point in  
general outside of the top-level with 'free-identifier=?' I don't see a  
real reason to put another predicate in there.

(define-syntax bound-identifier?
   (lambda (x)
     (syntax-case x ()
       [(k y) (identifier? #'y)
        #`#,(not (free-identifier=? #'y
                   (datum->syntax #'a (syntax->datum #'y))))])))

I think the choice for #'a may be important, but if this form is defined  
at the top level and 'a' is undefined, this should work. I think it works  
regardless so long as this form is defined at the top level. This form  
will only find bound identifiers in lexical scopes, since everything is  
free-identifier=? when we reach the top level in this case. However, I  
think this should work pretty well.

Sincerely,

        Aaron W. Hsu

-- 
Of all tyrannies, a tyranny sincerely exercised for the good of its  
victims may be the most oppressive. -- C. S. Lewis

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to