Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I notice that in test-define.rkt you have this line</p> <pre><code>(set! test3 (add1 test)) </code></pre> <p>Should <code>test3</code> be <code>test</code> ?</p> <p>This might explain why you saw that two zeros (test never changed).</p> <p>EDIT 2</p> <p>For convenience I put your two modules in the same file and changed the contract of test:</p> <pre><code>#lang racket (module test-define racket (provide test) ; (provide (contract-out [test integer?])) (provide get-test) (provide (contract-out [add-test! (-&gt; void)])) (define test 0) (define (add-test!) (set! test (add1 test))) (define (get-test) test)) (module ack racket (require (submod ".." test-define)) (printf "~a~%" test) (add-test!) (printf "~a~%" test)) (require (submod "." ack)) </code></pre> <p>Now I see the 0 1 vs 0 0 output as you do.</p> <p>Hmmm. Why?</p> <p>Well. If we change the provide forms to use no contracts at all, the output is 0 1.</p> <p>Adding a contract shouldn't change this behaviour (I think). Maybe a bug?</p> <p><a href="http://pre.racket-lang.org/docs/html/guide/contracts-gotchas.html?q=contract&amp;q=ignore" rel="nofollow">http://pre.racket-lang.org/docs/html/guide/contracts-gotchas.html?q=contract&amp;q=ignore</a></p> <p>Says:</p> <blockquote> <p>The contract library assumes that variables exported via contract-out are not assigned to, but does not enforce it. Accordingly, if you try to set! those variables, you may be surprised. ...snip... Moral: This is a bug that we will address in a future release.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload