On Thu, 2009-06-18 at 22:55 +0300, Abdulaziz Ghuloum wrote: > On Jun 18, 2009, at 4:42 PM, Ramana Kumar wrote: > > >> I already said I don't think it's 100% correct, but it works > >> on most implementations, and it satisfies your requirements. > >> If you don't want to use it, that's absolutely fine. > > > Oh I do want to use it =) But I also want to see the 100% correct > > version =P > > Okay. We ditch generate-temporaries which had underspecified > behavior. How about the following? [An idea clicked in my > head, I wrote it down, and it worked the first time, and when > I read the solution (2 lines really), it made no sense at all! > This is bizarre! Thanks Ramana! Maybe someone can explain it > to me. :-)]
> (define (unbound-identifier? x) > (and > (free-identifier=? x (datum->syntax a.ctxt (syntax->datum x))) > (free-identifier=? x (datum->syntax b.ctxt (syntax->datum x)))))) That's clever, but it's broken: $ cat b/t2.sps #!r6rs (import (rnrs) (for (b bound) expand)) (define-syntax if-unbound (lambda (x) (syntax-case x () [(_ (id) then else) (if (unbound-identifier? #'id) #'then #'else)]))) (if-unbound (a.cons) (display "a.cons unbound\n") (display "a.cons bound (incorrect)\n")) $ IKARUS_LIBRARY_PATH=. ikarus --r6rs-script b/t2.sps a.cons bound (incorrect) $ plt-r6rs ++path . b/t2.sps a.cons unbound $ larceny --path . --r6rs --program b/t2.sps a.cons bound (incorrect) $ ypsilon --sitelib . --r6rs b/t2.sps a.cons unbound It seems PLT and Ypsilon are broken about this because an unbound a.cons and a bound a.cons must not be free-identifier=?. I'm thinking there should be a standard (or common and portable with compat libraries) primitive identifier-bound? predicate. -- : Derick ----------------------------------------------------------------