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 <david.sto...@gmail.com 
> <mailto:david.sto...@gmail.com>> 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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3D2F671B-9322-43FC-B51D-2BA6542E2D67%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to