fixes docs, closes #3682
This commit is contained in:
parent
c07e9cde09
commit
2ca6f7a5d6
|
@ -1964,21 +1964,30 @@ As with the external contracts, when a method or field name is specified
|
||||||
|
|
||||||
@examples[#:eval class-eval
|
@examples[#:eval class-eval
|
||||||
(eval:no-prompt
|
(eval:no-prompt
|
||||||
(define/contract woody2+c%
|
|
||||||
(class/c (super [draw (->m symbol? string?)]))
|
(define/contract woody%+s
|
||||||
(class woody%
|
(class/c (super [draw (->m symbol? string?)]))
|
||||||
(define/override draw
|
(class object%
|
||||||
(case-lambda
|
(define/public (draw who)
|
||||||
[(a) (super draw a)]
|
(format "reach for the sky, ~a" who))
|
||||||
[(a b) (string-append (super draw a)
|
(super-new)))
|
||||||
" and "
|
|
||||||
(super draw b))]))
|
(define woody2+c%
|
||||||
(super-new))))
|
(class woody%+s
|
||||||
|
(define/override draw
|
||||||
|
(case-lambda
|
||||||
|
[(a) (super draw a)]
|
||||||
|
[(a b) (string-append (super draw a)
|
||||||
|
" and "
|
||||||
|
(super draw b))]))
|
||||||
|
(super-new))))
|
||||||
|
|
||||||
(send (new woody2+c%) draw 'evil-dr-porkchop 'zurg)
|
(send (new woody2+c%) draw 'evil-dr-porkchop 'zurg)
|
||||||
(send (new woody2+c%) draw "evil dr porkchop" "zurg")]
|
(eval:error (send (new woody2+c%) draw "evil dr porkchop" "zurg"))]
|
||||||
|
|
||||||
The last call signals an error blaming @racket[woody2%] because
|
The last call signals an error blaming @racket[woody2%+c] because
|
||||||
there is no contract checking the initial @racket[draw] call.
|
there is no contract checking the initial @racket[draw] call and
|
||||||
|
the super-call violates its contract.
|
||||||
}
|
}
|
||||||
@item{A method contract tagged with @racket[inner] describes the
|
@item{A method contract tagged with @racket[inner] describes the
|
||||||
behavior the class expects of an augmenting method in a subclass.
|
behavior the class expects of an augmenting method in a subclass.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user