This is a combination of our approaches, which is the best for my
purposes. Issue 2 is resolved thanks to your unbound? predicate -
thanks. And I don't have to clutter the test file with lists of the
identifiers that are clearly referenced in test expressions.
(define-syntax define-missing-exports
(lambda (o)
(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 o ()
((_ var ...)
#`(begin .
#,(let rec ((ls #'(var ...)))
(cond
((null? ls) '())
((unbound? (car ls))
(cons
#`(define-syntax #,(car ls)
(lambda (o)
(syntax-case o ()
(_ #'(raise (symbol->string '#,(car ls)))))))
(rec (cdr ls))))
(else (rec (cdr ls))))))))))
I also got rid of all the call/cc's I had before by using the guard
syntax (now it makes sense to me why the guard syntax is available).
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,,,
>
>
>