Since it's impossible (correct me if I'm wrong) to portably hide all
those little auxiliary libraries in a single file, I prefer the eval
approach (actually I don't even want to have to have a separate
library just for free-identifier-bound?, but if I'm willing to import
(rnrs eval) I can simply define free-identifier-bound? where I need
it)

Is this version better (i.e. correct as far as you can tell)? I
haven't bothered with phasing annotations - let me know what they
should be, if you know.


(library (free-identifier-bound?)
  (export free-identifier-bound?)
  (import (rnrs) (rnrs eval))
  (define free-identifier-bound?
    (let ((a:syntax (eval '(a:syntax a:syntax) (environment '(prefix
(only (rnrs) syntax) a:))))
          (b:syntax (eval '(b:syntax b:syntax) (environment '(prefix
(only (rnrs) syntax) b:)))))
      (lambda (id)
        (unless (identifier? id) (assertion-violation
'free-identifier-bound? "not an identifier" id))
        (or
          (free-identifier=? id a:syntax)
          (free-identifier=? id b:syntax)
          (let ((sym (syntax->datum id)))
            (not (or
                   (free-identifier=? id (datum->syntax a:syntax sym))
                   (free-identifier=? id (datum->syntax b:syntax sym))))))))))

On Mon, Jun 22, 2009 at 7:35 PM, Derick
Eddington<[email protected]> wrote:
>
>> (library (some suitable name)
>>   (export free-identifier-bound?)
>>   (import (rnrs) (rnrs eval))
>>   (define free-identifier-bound?
>>     (let ((empty-ctxt (eval '(syntax id) (environment '(only (rnrs) 
>> syntax)))))
>>       (lambda (id)
>>         (unless (identifier? id)
>>           (assertion-violation 'free-identifier-bound? "not an identifier" 
>> id))
>>         (or (free-identifier=? id #'syntax)
>>           (not (free-identifier=? id
>>                  (datum->syntax empty-ctxt
>>                    (syntax->datum id)))))))))

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

Reply via email to