From 2afe7621b3344758768e25e2e86426f1d0860461 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 7 Jan 2009 16:06:37 +0000 Subject: [PATCH] PR 10010 svn: r13029 --- .../scribblings/reference/contracts.scrbl | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/collects/scribblings/reference/contracts.scrbl b/collects/scribblings/reference/contracts.scrbl index 11a5cea81d..675feb7906 100644 --- a/collects/scribblings/reference/contracts.scrbl +++ b/collects/scribblings/reference/contracts.scrbl @@ -81,6 +81,13 @@ Takes any number of predicates and higher-order contracts and returns a contract that accepts any value that any one of the contracts accepts, individually. +The @scheme[or/c] result tests any value by applying the contracts in +order, from left to right, with the exception that it always moves the +non-@tech{flat contracts} (if any) to the end, checking them +last. Thus, a contract such as @scheme[(or/c (not/c real?) +positive?)] is guaranteed to only invoke the @scheme[positive?] +predicate on real numbers. + If all of the arguments are procedures or @tech{flat contracts}, the result is a @tech{flat contract}. If only one of the arguments is a higher-order contract, the result is a contract that just checks the @@ -95,11 +102,16 @@ calls @scheme[contract-first-order-passes?] with each of the higher-order contracts. If only one returns true, @scheme[or/c] uses that contract. If none of them return true, it signals a contract violation. If more than one returns true, it signals an error -indicating that the @scheme[or/c] contract is malformed. - -The @scheme[or/c] result tests any value by applying the contracts in -order, from left to right, with the exception that it always moves the -non-@tech{flat contracts} (if any) to the end, checking them last.} +indicating that multiple branches of the @scheme[or/c] each might +apply to the value. For example, this contract +@schemeblock[ +(or/c (-> number? number?) + (-> string? string? string?)) +] +cannot accept a function like this one: @scheme[(lambda args ...)] +since it cannot tell which of the two arrow contracts should be used +with the function. +} @defproc[(and/c [contract (or/c contract? (any/c . -> . any/c))] ...) contract?]{