First cut: Contracts check cross-module invariants. That's why they establish boundaries:
http://doc.racket-lang.org/guide/contract-boundaries.html?q=contracts When a module M provides a function f with a contract, calls w/i M to f are not checked. Second cut: if you know about contract regions, you can break modules into several contract regions and thus force contract checks within a module. On Nov 16, 2012, at 6:59 PM, Harry Spier wrote: > Dear list members, > > Can someone explain why in the following cases only two out of the three > cases and not all of them cause a contract violation. > Thanks, > Harry Spier > > #lang racket > (provide/contract (amount positive?)) > (define amount -7) > > > contract > promised: positive? > produced: -7 > in: positive? > contract from: anonymous-module > blaming: anonymous-module > > BUT-------------------------------------- > > #lang racket > (provide/contract [amount (-> positive?)]) > (define (amount) -7) > (amount) > > > No contract violation > > AND------------------------------------------- > > #lang racket > > (provide/contract [amount (-> positive?)]) > (define (amount) -7) > > (module* main racket > (require (submod "..")) > (amount)) > > > > amount: broke its contract > promised: positive? > produced: -7 > in: the range of > (-> positive?) > contract from: > c:\users\harry\ocr_project\contract-test.rkt > blaming: > c:\users\harry\ocr_project\contract-test.rkt > at: c:\users\harry\ocr_project\contract-test.rkt:3.20 > ____________________ > Racket Users list: > http://lists.racket-lang.org/users
smime.p7s
Description: S/MIME cryptographic signature
____________________ Racket Users list: http://lists.racket-lang.org/users