Ticket #178 (writing defect)

Opened 12 months ago

Last modified 10 months ago

Shadowing with internal definitions

Reported by: arcfide Owned by: alexshinn
Priority: major Milestone:
Component: WG1 - Core Keywords:
Cc:

Description

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
definition.

    (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)))

Change History

comment:1 Changed 10 months ago by alexshinn

  • Status changed from new to decided

We voted for the R6RS semantics.

comment:2 Changed 10 months ago by alexshinn

  • Status changed from decided to writing
Note: See TracTickets for help on using tickets.