One more time. Oh, well.

svn: r11745
This commit is contained in:
Stevie Strickland 2008-09-14 06:27:22 +00:00
parent 0cdb21157e
commit 6c2f2bc60d
2 changed files with 61 additions and 61 deletions

View File

@ -112,22 +112,22 @@ 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.
@interaction[#:eval (parameterize ([sandbox-output 'string]
[sandbox-error-output 'string]
[sandbox-eval-limits #f])
(make-evaluator 'mzscheme))
(require mzlib/contract)
(define/contract f
(-> number? number?)
(lambda (x) (+ x 1)))
(define/contract g
(-> number? number?)
(lambda (x) (f #t)))
(define/contract i
(-> number? number?)
(lambda (x)
(if (number? x) (i #t) 0)))
(f 4)
(f #t)
(g 4)
(i 3)]}
@examples[#:eval (parameterize ([sandbox-output 'string]
[sandbox-error-output 'string]
[sandbox-eval-limits #f])
(make-evaluator 'mzscheme))
(require mzlib/contract)
(define/contract f
(-> number? number?)
(lambda (x) (+ x 1)))
(define/contract g
(-> number? number?)
(lambda (x) (f #t)))
(define/contract i
(-> number? number?)
(lambda (x)
(if (number? x) (i #t) 0)))
(f 4)
(f #t)
(g 4)
(i 3)]}

View File

@ -662,30 +662,30 @@ exported without a contract.
The @scheme[blame-id] is used for the positive positions of
contracts paired with exported @scheme[id]s. Contracts broken
within the @scheme[with-contract] @scheme[body] will use the
@scheme[blame-id] for their negative position.}
@scheme[blame-id] for their negative position.
@interaction[(require scheme/contract)
(with-contract odd-even
([odd? (-> number? boolean?)]
[even? (-> number? boolean?)])
(define (odd? n)
(if (zero? n) #f (even? (sub1 n))))
(define (even? n)
(if (zero? n) #t (odd? (sub1 n)))))
(even? 4)
(odd? "foo")
(with-contract bad-internal-call
([f (-> number? number?)]
[g (-> number? number?)])
(define (f x)
(+ x 1))
(define (g x)
(if (zero? x) #t (f #t))))
(f 4)
(f 'a)
(g "foo")
(g 0)
(g 3)]
@examples[(require scheme/contract)
(with-contract odd-even
([odd? (-> number? boolean?)]
[even? (-> number? boolean?)])
(define (odd? n)
(if (zero? n) #f (even? (sub1 n))))
(define (even? n)
(if (zero? n) #t (odd? (sub1 n)))))
(even? 4)
(odd? "foo")
(with-contract bad-internal-call
([f (-> number? number?)]
[g (-> number? number?)])
(define (f x)
(+ x 1))
(define (g x)
(if (zero? x) #t (f #t))))
(f 4)
(f 'a)
(g "foo")
(g 0)
(g 3)]}
@defform*[[(define/contract id contract-expr init-value-expr)
(define/contract (head args) contract-expr body ...+)]]{
@ -701,25 +701,25 @@ of the contract. It is equivalent to wrapping a single @scheme[define]
with a @scheme[with-contract] form that pairs the @scheme[contract-expr]
with the bound identifier.
@interaction[(require scheme/contract)
(define/contract a number? #t)
a
(define/contract (f x)
(-> number? number?)
(+ x 1))
(f 4)
(f #t)
(define/contract (g #:foo [x 3] . y)
(->* () (#:foo number?) #:rest (listof number?) number?)
(+ x (apply + y)))
(g)
(g #:foo #t)
(g 1 2 3 'a)
(define/contract i
(-> number? number?)
(lambda (x)
(if (number? x) (i #t) 0)))
(i 3)]}
@examples[(require scheme/contract)
(define/contract a number? #t)
a
(define/contract (f x)
(-> number? number?)
(+ x 1))
(f 4)
(f #t)
(define/contract (g #:foo [x 3] . y)
(->* () (#:foo number?) #:rest (listof number?) number?)
(+ x (apply + y)))
(g)
(g #:foo #t)
(g 1 2 3 'a)
(define/contract i
(-> number? number?)
(lambda (x)
(if (number? x) (i #t) 0)))
(i 3)]}
@defform*[[(contract contract-expr to-protect-expr
positive-blame-expr negative-blame-expr)