removed _contract_ language from _invariant-..._ as much as possible

added a hint as to why the error message uses the inappropriate contract language
This commit is contained in:
Matthias Felleisen 2014-05-31 15:45:43 -04:00
parent 9d94ef725e
commit 89dea63995
3 changed files with 14 additions and 14 deletions

View File

@ -1509,24 +1509,24 @@ The @racket[define-struct/contract] form only allows a subset of the
(make-salmon #f 'pacific) (make-salmon #f 'pacific)
]} ]}
@defform[(invariant-contract contract-expr expr)]{ @defform[(invariant-assertion invariant-expr expr)]{
Establishes an invariant of @racket[expr], determined by @racket[contract-expr]. Establishes an invariant of @racket[expr], determined by @racket[invariant-expr].
Unlike other ways to attach contracts to values, an Unlike the specification of a contract, an
@racket[invariant-contract] does not establish a boundary @racket[invariant-assertion] does not establish a boundary
between two parties. Instead, it simply puts the contract between two parties. Instead, it simply attaches a logical assertion
on the value, treating the module containing the to the value. Because the form uses contract machinery to check the
@racket[invariant-contract] expression as the party to be blamed assertion, the surround module is treated as the party to be blamed
for any violations of the contract. for any violations of the assertion.
This means, for example, that the contract is checked on This means, for example, that the assertion is checked on
recursive calls, when an invariant is used on the right-hand recursive calls, when an invariant is used on the right-hand
side of a definition. side of a definition:
@examples[#:eval @examples[#:eval
furlongs->feet-eval furlongs->feet-eval
(define furlongss->feets (define furlongss->feets
(invariant-contract (invariant-assertion
(-> (listof real?) (listof real?)) (-> (listof real?) (listof real?))
(λ (l) (λ (l)
(cond (cond

View File

@ -3,7 +3,7 @@
(provide contract (provide contract
(rename-out [-recursive-contract recursive-contract]) (rename-out [-recursive-contract recursive-contract])
current-contract-region current-contract-region
invariant-contract) invariant-assertion)
(require (for-syntax racket/base syntax/name syntax/srcloc) (require (for-syntax racket/base syntax/name syntax/srcloc)
racket/stxparam racket/stxparam
@ -89,7 +89,7 @@
(procedure-rename new-val vs-name)])] (procedure-rename new-val vs-name)])]
[else new-val]))) [else new-val])))
(define-syntax (invariant-contract stx) (define-syntax (invariant-assertion stx)
(syntax-case stx () (syntax-case stx ()
[(_ ctc e) [(_ ctc e)
(quasisyntax/loc stx (quasisyntax/loc stx

View File

@ -4,7 +4,7 @@
define/contract define/contract
with-contract with-contract
current-contract-region current-contract-region
invariant-contract) invariant-assertion)
(require (for-syntax racket/base (require (for-syntax racket/base
racket/struct-info racket/struct-info