--- This message is a formal comment which was submitted to formal-comment_at_r6rs.org, following the requirements described at: http://www.r6rs.org/process.html --- Name : Andre van Tonder Email : andre at het.brown.edu Type : defect Priority : major Component : Expansion process Version : 5.91 Pages : 27-28 Dependencies: Sections 9.3 (Syntax definitions) Summary: -------- Lexical scoping violation for internal define-syntax. Description: ------------ In the following example, the expansion algorithm, as described in r6rs, will consider (bar x) an expression and throw a syntax violation stating that expressions may not precede definitions. (let ((bar 1)) (bar x) (define-syntax bar (syntax-rules () ((bar x) (define x 1)))) x) This syntax error violates lexical scoping, specifically the sentence "Keyword bindings established by define-syntax are visible throughout the body in which they appear, ..." on p. 29. By lexical scoping, the result should be 1. I think it can be made 1 if the expansion algorithm is made multi-pass (see below). I am unsure if this case is covered by the constraint on p.28, which reads: "It is a syntax violation if the keyword that identifies one of the body forms as a definition (derived or core) is redefined by the same definition or a later definition in the same body." When (bar x) is expanded, it is not yet known that bar will be a keyword. In any case, bar is never "re"-defined. Even if it is intended to be covered by the constraint, it will not be detected by the algorithm in the first paragraph on page 28. Suggestion: ----------- Perhaps lexical scoping with internal define-syntax can be better handled by a multipass expansion algorithm instead of single-pass. On each pass, the expansion process would restart, using syntax definitions discovered on previous passes, until no more syntax definitions are discovered. It seems that such an algorithm would give the result 1 above. The implied reprocessing of forms, however, may cause problems with macros that update expand-time state (e.g. record definitions).Received on Mon Oct 23 2006 - 15:54:31 UTC
This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC