<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.&nbsp;"?" 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">&nbsp;&nbsp;(define x 'a)</font></div><div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp;(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">&nbsp;&nbsp;(match x</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;[(? (cut eq? &lt;> y))&nbsp;"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">&nbsp;&nbsp;(match x</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;[(eq? y)&nbsp;"X is the same as Y."])</font></div></div><div><br></div><div>I had a play&nbsp;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">&nbsp;&nbsp;#lang scheme</font></div><div><span class="Apple-style-span" style="font-family: Monaco; ">&nbsp;&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: Monaco; ">&nbsp;&nbsp;(require (file "my-match.ss"))</span></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp;</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp;;&nbsp;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">&nbsp;&nbsp;(syntax-rules ()</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;[(_ value pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; (? (cut eq? &lt;> value) pattern ...)])</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp;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">&nbsp;&nbsp;(syntax-rules ()</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;[(_ value pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; (? (cut eqv? &lt;> value) pattern ...)])</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp;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">&nbsp;&nbsp;(syntax-rules ()</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp;[(_ value pattern ...)</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; (? (cut equal? &lt;> value) pattern ...)])</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp;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? &nbsp; &nbsp;eq?]</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [match:eqv? &nbsp; eqv?]</font></div><div><font class="Apple-style-span" face="Monaco">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [match:equal? equal?]))</font></div></div><div><br></div></body></html>