▼ |  | Unstable: May Change Without Warning

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

On this page:

recontract-out

5.3.6
top ← prev up next →

### 26`` 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 →