doc: partially revert eb20dc44
Bring back the exists gotcha, but not the references to the `racket/exists' language.
This commit is contained in:
parent
3f94fab01b
commit
3628df837a
|
@ -56,3 +56,4 @@ To ensure that the queue representation is abstract, we can use @racket[#:∃] i
|
|||
Now, if clients of the data structure try to use @racket[car] and @racket[cdr], they
|
||||
receive an error, rather than mucking about with the internals of the queues.
|
||||
|
||||
See also @ctc-link["exists-gotcha"].
|
||||
|
|
|
@ -108,6 +108,20 @@ Moral: if two values with contracts should interact,
|
|||
put them in separate modules with contracts at
|
||||
the module boundary or use @racket[#:freevar].
|
||||
|
||||
@ctc-section[#:tag "exists-gotcha"]{Exists Contracts and Predicates}
|
||||
|
||||
Much like the @racket[eq?] example above, @racket[#:∃] contracts
|
||||
can change the behavior of a program.
|
||||
|
||||
Specifically,
|
||||
the @racket[null?] predicate (and many other predicates) return @racket[#f]
|
||||
for @racket[#:∃] contracts, and changing one of those contracts to @racket[any/c]
|
||||
means that @racket[null?] might now return @racket[#t] instead, resulting in
|
||||
arbitrarily different behavior depending on how this boolean might flow around
|
||||
in the program.
|
||||
|
||||
Moral: Do not use predicates on @racket[#:∃] contracts.
|
||||
|
||||
@ctc-section{Defining Recursive Contracts}
|
||||
|
||||
When defining a self-referential contract, it is natural to use
|
||||
|
|
Loading…
Reference in New Issue
Block a user