Opened 6 years ago

Closed 4 years ago

#178 closed defect (wontfix)

Shadowing with internal definitions

Reported by: arcfide Owned by: alexshinn
Priority: major Milestone:
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

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)

Change History (4)

comment:1 Changed 6 years ago by alexshinn

  • Status changed from new to decided

We voted for the R6RS semantics.

comment:2 Changed 6 years ago by alexshinn

  • Status changed from decided to writing

comment:3 Changed 4 years ago by cowan

None of the editors understand how to implement this one, and it's the Very Last Ticket, so I'm closing it.

comment:4 Changed 4 years ago by cowan

  • Resolution set to wontfix
  • Status changed from writing to closed
Note: See TracTickets for help on using tickets.