<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi PLTers,<div><br></div><div>I've often thought an equivalent of "eq?" or "equal?" to be a useful addition for the match library. "?" does more or less what I want but it's a little verbose:</div><div><br></div><div><font class="Apple-style-span" face="Monaco"> (define x 'a)</font></div><div><div><font class="Apple-style-span" face="Monaco"> (define y 'b)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div></div><div><font class="Apple-style-span" face="Monaco"> (match x</font></div><div><font class="Apple-style-span" face="Monaco"> [(? (cut eq? <> y)) "X is the same as Y."])</font></div><div><br></div><div>What I'd like to see is something like this:</div><div><br></div><div><div><font class="Apple-style-span" face="Monaco"> (match x</font></div><div><font class="Apple-style-span" face="Monaco"> [(eq? y) "X is the same as Y."])</font></div></div><div><br></div><div>I had a play this afternoon and wrote the a module called "my-match.ss" (attached) that redefines eq?, eqv? and equal? to do what I've described above:</div><div><br></div><div><font class="Apple-style-span" face="Monaco"> #lang scheme</font></div><div><span class="Apple-style-span" style="font-family: Monaco; "> </span></div><div><span class="Apple-style-span" style="font-family: Monaco; "> (require (file "my-match.ss"))</span></div><div><font class="Apple-style-span" face="Monaco"> </font></div><div><font class="Apple-style-span" face="Monaco"> ; and so on...</font></div><div><br></div><div>Now for my question. By supplying my own versions of these identifiers, I have also changed how they are treated in an expression context (although the end result of using them should be the same). Is it a "Bad Thing" (TM) to do this to identifiers that are so fundamental to the core of Scheme? Should I rename these guys, or make sure I only ever require them with a prefix?</div><div><br></div><div>Many thanks,</div><div><br></div><div>-- Dave</div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">; my-match.ss ====================================</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><div><font class="Apple-style-span" face="Monaco">#lang scheme</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">(require srfi/26)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">; Match expanders --------------------------------</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">; (_ expr pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco">(define-match-expander match:eq?</font></div><div><font class="Apple-style-span" face="Monaco"> (syntax-rules ()</font></div><div><font class="Apple-style-span" face="Monaco"> [(_ value pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco"> (? (cut eq? <> value) pattern ...)])</font></div><div><font class="Apple-style-span" face="Monaco"> eq?)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">; (_ expr pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco">(define-match-expander match:eqv?</font></div><div><font class="Apple-style-span" face="Monaco"> (syntax-rules ()</font></div><div><font class="Apple-style-span" face="Monaco"> [(_ value pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco"> (? (cut eqv? <> value) pattern ...)])</font></div><div><font class="Apple-style-span" face="Monaco"> eqv?)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">; (_ expr pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco">(define-match-expander match:equal?</font></div><div><font class="Apple-style-span" face="Monaco"> (syntax-rules ()</font></div><div><font class="Apple-style-span" face="Monaco"> [(_ value pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco"> (? (cut equal? <> value) pattern ...)])</font></div><div><font class="Apple-style-span" face="Monaco"> equal?)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">; Provide statements -----------------------------</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">(provide (rename-out [match:eq? eq?]</font></div><div><font class="Apple-style-span" face="Monaco"> [match:eqv? eqv?]</font></div><div><font class="Apple-style-span" face="Monaco"> [match:equal? equal?]))</font></div></div><div><br></div></body></html>