On Fri, 11 Sep 2009 09:28:14 -0500, David Van Horn <[email protected]>
wrote:
> 1) Procedural macros (aka syntax-case macros) are hygienic so long as
> you do not explicitly bend hygiene. If you want to be a hygiene purist,
> you can still have procedural macros and outlaw `datum->syntax'. Eli's
> point is just as valid in such a context.
You'll also have to outlaw `syntax->datum'. Otherwise, it's still possible
to bind identifiers unhygienically:
#!r6rs
(import (rnrs base (6))
(rnrs io simple (6))
(for (rnrs base (6)) expand)
(for (rnrs syntax-case (6)) expand))
(define-syntax bind-it
(lambda (stx)
(syntax-case stx ()
((_ body ...)
(letrec ((find-it (lambda (stx)
(syntax-case stx ()
(it
(and (identifier? #'it)
(eq? (syntax->datum #'it) 'it))
(values #'it #t))
((a . b)
(let-values (((v found) (find-it #'a)))
(if found
(values v #t)
(find-it #'b))))
(z (values #f #f))))))
(let-values (((v found) (find-it stx)))
(with-syntax ((it (if found
v
#'it)))
#'(let ((it 42))
body ...))))))))
(display (let ((it 1))
(bind-it it)))
-> 42
Evaluating arbitrary Scheme at expansion time brings several issues into
play that would not exist otherwise: phasing semantics, the interaction
between phases and binding visibility, and the necessity of having an
interpreter in an otherwise cross-compiler-only implementation.
> 2) You can make a mess with syntax-rules. The idea that you can just
> look at the text of a Scheme program and determine the scope of an
> identifier is false in general. This is why I asked earlier, in what
> sense is Scheme lexically scoped? It is not the usual one.
No, but the way in which it is lexically scoped is useful and consistent.
--
Brian Mastenbrook
[email protected]
http://brian.mastenbrook.net/
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss