Shadowing with internal definitions
|Reported by:||arcfide||Owned by:||alexshinn|
|Component:||WG1 - Core||Keywords:|
From Andre Von Tonder:
On p 19, some shadowing problems that would break lexical scope are declared to
be errors. However, I believe there are otehr examples that shold be errors
that are not covered by the report.
In R6RS a more general criterion was used - please see R6RS for details.
Here is an example that does not violate the WG1 report but should be an error
becasue it violates lexical scoping. It does not violate the WG1 criterion
because the meaning of x is not needed to determine whether (foo x p ) is a
(let ((x #f)) (let-syntax ((foo (syntax-rules (x) ((_ x y) (define y 'outer)) ((_ _ y) (define y 'inner))))) (let () (foo x p) (define x #f) ;; this should be an error because ;; it shadows the previous line where ;; x has already been used in its outer sense ;; during expansion p)))
Here is another example that WG1 allows but that would cause violation of
lexical scoping, because the macro would be evaluated first and treat ... as a
placeholder in a region where it is shadowed to be the variable bound to 1:
(let () (define-syntax list-macro (syntax-rules () ((_ x ...) (list x ...)))) (define ... 1) ;; This shadows ... in previously expanded macro ;; body and will be a violation of lexical scoping (list-macro 1 2)) ;; if the last line evaluates to (1 2)
OTOH, it is unclear to me if WG1 allows this or not.
(let ((x #f)) (let-syntax ((foo (syntax-rules (x) ((_ x y) (define y 'outer)) ((_ _ y) (define y 'inner))))) (let () (define x #f) (foo x p) p)))