Lexical scope of pattern variables is not strictly respected in the sample implementation Marc Nieper-WiÃkirchen 01 Sep 2020 08:35 UTC
In the specification section of SRFI 204, it says "identifiers will match anything, and make the corresponding binding available in the body", which I read as that the identifiers are lexically bound in an extended environment, in which the body is evaluated. The sample implementation, however, fails to respect the correct lexical scoping in some cases: (match '1 ((and odd (? odd)) odd)) The expected value of this expression (and according to how match is specified in SRFI 204) is 1. The sample implementation, however, fails with an error because the binding of odd is introduced too early, namely in a scope surrounding the pattern `(? odd)` as well. To make the sample implementation do the correct thing, it has to defer all actual bindings or bind to temporary variables first. Marc