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 the source location of the reference to the variable as the name of
that definition. that definition.
@interaction[#:eval (parameterize ([sandbox-output 'string] @examples[#:eval (parameterize ([sandbox-output 'string]
[sandbox-error-output 'string] [sandbox-error-output 'string]
[sandbox-eval-limits #f]) [sandbox-eval-limits #f])
(make-evaluator 'mzscheme)) (make-evaluator 'mzscheme))
(require mzlib/contract) (require mzlib/contract)
(define/contract f (define/contract f
(-> number? number?) (-> number? number?)
(lambda (x) (+ x 1))) (lambda (x) (+ x 1)))
(define/contract g (define/contract g
(-> number? number?) (-> number? number?)
(lambda (x) (f #t))) (lambda (x) (f #t)))
(define/contract i (define/contract i
(-> number? number?) (-> number? number?)
(lambda (x) (lambda (x)
(if (number? x) (i #t) 0))) (if (number? x) (i #t) 0)))
(f 4) (f 4)
(f #t) (f #t)
(g 4) (g 4)
(i 3)]} (i 3)]}

View File

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