[r6rs-discuss] [Formal] Violation of lexical scoping
On Tue, 24 Oct 2006, AndrevanTonder wrote:
A small erratum. I forgot to include that identifiers must also be
compared with bound-identifier=?. Here is the corrected statement:
Modified specification:
-----------------------
It is a syntax violation if an identifier whose meaning is needed
during the original left-to-right expansion of declarations and
definitions is subsequently redefined by a definition in the
same body. To detect this error, the expander records each
identifier whose denotation is requested during expansion
of the body, together with its denotation.
Before an identifier is bound, its current denotation is compared
against denotations already used for the same (in the sense of
bound-identifier=?) identifier in the current scope, if any, to
determine if the identifier has already been used with the current
denotation. If so, a syntax violation is thrown.
------------------------
That it is not enough to just compare the identifiers, but that we also need to
compare the denotations, is shown by considereing the examples:
(let ()
(define-syntax foo (lambda (e) (+ 1 2)))
(define + 2)
(foo)) ; Syntax violation: Redefinition of identifier + that has
; already been used during expansion
;; This should give no error:
(let ()
(define-syntax foo (lambda (e) (let ((+ -)) (+ 1 2))))
(define + 2)
(foo)) ;==> -1
The second example must give no error because the denotations are different,
even though the identifiers are bound-identifier=?
Andre
Received on Tue Oct 24 2006 - 19:39:19 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC