▼ |  | Unstable: May Change Without Warning

1 | Guidelines for Developing unstable Libraries
2 | Automata: Compiling State Machines
3 | Bytes
4 | Contracts
5 | Converting Values to Strings
6 | Contracts for Macro Subexpressions
7 | Debugging
8 | Definitions
9 | Errors
10 | Filesystem
11 | Find
12 | Flonums
13 | Futures
14 | Functions
15 | Hash Tables
16 | Interface-Oriented Programming for Classes
17 | Lazy Require
18 | Lists
19 | Logging
20 | Mark Parameters
21 | Match
22 | Open place expressions
23 | Parameter Groups
24 | Pretty-Printing
25 | Re-Contracting Identifiers
26 | Sandbox
27 | Sequences
28 | Strings
29 | Structs
30 | Struct Printing
31 | Syntax
32 | Temporal Contracts: Explicit Contract Monitors
33 | GUI Libraries

On this page:

recontract-out

Version: 5.3.1
top ← prev up next →

### 25`` Re-Contracting Identifiers

Ryan Culpepper <ryanc@racket-lang.org>

This library is unstable; compatibility will not be maintained. See Unstable: May Change Without Warning for more information.

( require unstable/recontract )

> > syntax

> > ( recontract-out id ...)

Provides each id with its existing contract, but changes the positive blame party of the contract to the enclosing module, instead of the module that originally attached the contract to id. Each id must be imported from a module that exports it via contract-out or recontract-out; otherwise a syntax error is raised.

Use recontract-out when you want to use the same contracts both between different parts of a library and between the library and its clients. The library should use recontract-out in the public interface modules so that clients do not see references to private implementation modules in contract errors.

Examples:

> > ( module private racket
> ( define (f x) ( if ( positive? x) x 'wrong))
> ( provide ( contract-out [f ( -> real? real? )])))

> > ( module public racket
> ( require 'private unstable/recontract)
> ( provide ( recontract-out f)))

> > ( require 'public)

> > (f 1)
> 1
> > (f -2)
> f: broke its contract
> promised: real?
> produced: 'wrong
> in: the range of
> (-> real? real?)
> contract from: public
> blaming: public
> at: eval:2.0
> > (f 'apple)
> f: contract violation
> expected: real?
> given: 'apple
> in: the 1st argument of
> (-> real? real?)
> contract from: public
> blaming: top-level
> at: eval:2.0

top ← prev up next →