The difficulty with the when-bound approach is that I have to manually go through and find the identifiers in every test expression... there are lots of them and that seems like something that should be done automatically. Of course I could write a program to do it once, but I'm not sure what the problem is with my current solution...
On Mon, Jun 15, 2009 at 6:18 AM, Abdulaziz Ghuloum<[email protected]> wrote: > > On Jun 14, 2009, at 10:46 PM, Abdulaziz Ghuloum wrote: > >> BTW, this is not a 100% correct definition of when-bound, but ... > > The more I stare at it, the more it looks correct. > Here's a more self-documenting version of the same code: > > (define-syntax when-bound > (lambda (x) > (define unbound? > (let ([empty-ctxt (car (generate-temporaries '(t)))]) > (lambda (id) > (let ([unbound-id > (datum->syntax empty-ctxt (syntax->datum id))]) > (free-identifier=? id unbound-id))))) > (syntax-case x () > [(_ (id) e* ...) > (if (unbound? #'id) > #'(begin) > #'(begin e* ...))]))) > > Aziz,,, > > >
