#1152 closed defect (wontfix)
Reserved pattern symbols break when a binding of the same name exists
Reported by: | Moritz Heidkamp | Owned by: | Alex Shinn |
---|---|---|---|
Priority: | major | Milestone: | someday |
Component: | extensions | Version: | 4.9.x |
Keywords: | matchable egg | Cc: | |
Estimated difficulty: |
Description
When reserved pattern symbols like ?
or _
are bound in the lexical environment of a match
expression, they don't work anymore:
(import matchable) (let ((? 1)) (match '(x y) ((? odd?) (print ?)))) (match '(x y) ((_ _) (print 'ok))) (let ((_ 1)) (match '(x y) ((_ _) (print 'ok))))
Output:
$ csc matchbug.scm && ./matchbug x ok Error: (match) no matching pattern Call history: matchbug.scm:5: print matchbug.scm:8: print matchbug.scm:10: failure391 matchbug.scm:10: error <--
Change History (3)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is basically just hygiene working as expected, and gives
that result for the same reason that
(let ((else #f))
(cond (else #t) (#t #f)))
returns #f.
Admittedly this is one of those cases where it's not useful to
match the operator position id against the current lexical scope
and one might be tempted to deliberately match unhygienically.
However, this may change in future versions. Moreover,
other macros which expand into match may depend on the
fact that inserted identifiers match hygienically.
comment:3 Changed 10 years ago by
Indeed, we just discussed this issue on IRC and came to the same conclusion. I guess it's just a fact of lifeWScheme we have to live with, then. Perhaps it would be worthwhile to add a caveat section about this to the manual?
Anyhow, thanks for the quick response!
Just for the record: The same happens with Chibi 0.7.