On this page:
define/ contract

 (require mzlib/contract)

This library is designed as a backwards compatible library for old uses of contracts. It should not be used for new libraries; use scheme/contract instead.

The main differences: the function contract syntax is more regular and function contracts now support keywords, and union is now or/c.

The mzlib/contract library re-exports many bindings from scheme/contract:

  

</c

  

guilty-party

  

<=/c

  

integer-in

  

=/c

  

list/c

  

>/c

  

listof

  

>=/c

  

make-none/c

  

and/c

  

make-proj-contract

  

any

  

natural-number/c

  

any/c

  

none/c

  

between/c

  

not/c

  

box-immutable/c

  

one-of/c

  

box/c

  

or/c

  

build-compound-type-name

  

parameter/c

  

coerce-contract

  

printable/c

  

cons/c

  

promise/c

  

contract

  

provide/contract

  

contract-first-order-passes?

  

raise-contract-error

  

contract-violation->string

  

real-in

  

contract?

  

recursive-contract

  

define-contract-struct

  

string/len

  

false/c

  

struct/c

  

flat-contract

  

symbols

  

flat-contract-predicate

  

syntax/c

  

flat-contract?

  

vector-immutable/c

  

flat-murec-contract

  

vector-immutableof

  

flat-named-contract

  

vector/c

  

flat-rec-contract

  

vectorof

It also provides the old version of define/contract:

(define/contract id contract-expr init-value-expr)
Attaches the contract contract-expr to init-value-expr and binds that to id.

The define/contract form treats individual definitions as units of blame. The definition itself is responsible for positive (co-variant) positions of the contract and each reference to id (including those in the initial value expression) must meet the negative positions of the contract.

Error messages with define/contract are not as clear as those provided by provide/contract, because define/contract cannot detect the name of the definition where the reference to the defined variable occurs. Instead, it uses the source location of the reference to the variable as the name of that definition.