Great, thanks.  I clearly need to add the section on contracts to my
re-read list.  I thought I understood them, but apparently there are still
bits that I'm missing.

On Wed, May 22, 2019 at 1:23 PM Alexis King <[email protected]> wrote:

> Your intuition is right, but let me make it more precise: foo? is used
> when something is a flat contract, and foo/c is used otherwise. Flat
> contracts only check *first order properties* of values, which is a
> technical term that captures what you mean by “general nature.”
>
> The important distinction is that first order properties can be checked
> immediately, whereas checking of higher-order properties may need to be
> delayed. For example, when you write the contract
>
> (-> integer? string?)
>
>
> then you can check immediately that the value is a procedure (via the
> procedure? predicate), but you have to wait until the function is called to
> check that it is actually passed an integer. Therefore, non-flat contracts
> add proxying wrappers to values that do the deferred checking.
>
> Since flat contracts only perform first-order checks, a flat contract can
> be used as a predicate, so you can write (foo? x) to get back a boolean.
> Likewise, all predicates can be used as flat contracts. This is why the
> foo? naming scheme is used for those contracts, since foo? is the
> historical naming convention in Scheme and its descendants for naming
> predicates. The foo/c naming convention is newer, and is specific to
> contracts, so it is used for contracts and contract combinators that are
> not simple predicates, and therefore cannot use the foo? naming convention.
>
> Alexis
>
> On May 22, 2019, at 12:06, David Storrs <[email protected]> wrote:
>
> Is the idea that foo/c is used only when it will specify structure (e.g.
> (hash/c any/c symbol?)) whereas foo? is used to check that a thing has a
> general nature?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKodbUevOE1s1fXyrG%2BLSLpOw6K555apzQyzouFdyPibmbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to