Hi all - <br><br>I am running into an interesting issue where an alist of procedures in REPL, the ones without a contract works with assoc, but the ones with contract do not work with assoc. <br><br>What I have is an alist where the keys are procedures. Some of these procedures have contracts attached to them, and some do not. Then I tried to use assoc to match the procedures. If the code are run within the module itself - both types match, but within REPL only the ones without contract matches. <br>
<br>Here's an simplified example, where foo.ss defines the procedures, and the test.ss uses foo.ss to construct the alist. <br><br><div style="text-align: left; margin-left: 40px;">;; foo.ss <br>#lang scheme<br>(define (test? v) #t) ;; provided with contract <br>
<br>(define (test2? v) #t) ;; provided without contract <br><br>(provide/contract <br> (test? (-> any/c boolean?))<br> )<br><br>(provide test2?) <br><br>;; test.ss <br>#lang scheme<br>(require "foo.ss")<br><br>
(define table `((,test2? . 1) (,test? . 2)))<br><br>(assoc test? table) ;; works in module setting but not in REPL <br><br>(assoc test2? table) ;; works in module setting AND in REPL <br></div><br>Both the assoc test above returns the correct result. But if I try to copy and run (assoc test? table) in REPL again, it will not match, whereas (assoc test2? table) continues to match. <br>
<br>Is there any particular reason for the divergence of the behaviors? I verified the behavior in both v4.2.5 and v5.0. Thanks. <br><br>yc<br><br><br><br><br>