[racket-dev] Please help me to understand the two lines.

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon May 30 10:13:33 EDT 2011

The results of functions are all given by contracts. So, this is saying that
the function named "boolean?" returns something that, when passed to
"boolean?", returns #true.

This is a confusing example to start with, tho, if you had number?, you'd
see:

  (number? v) -> boolean?
  v : any/c

which is saying that the function named "number?" returns something that,
when passed to "boolean?" returns #true.

As for the any/c vs any: they are two separate things. "any/c" is general
purpose contract that allows anything. "any" is special syntax that is only
allowed inside function contracts. You can think of "any" as a more
restricted form of "any/c" and that's 95% of the story.

Also, do check out this section for more on contracts:

  http://docs.racket-lang.org/guide/contracts.html

Robby

On Mon, May 30, 2011 at 9:07 AM, Yingjian Ma <yingjian.ma1955 at gmail.com>wrote:

>   The lines are from
> http://pre.racket-lang.org/docs/html/reference/booleans.html
> section 3.1
>
> The lines are:
> (boolean?<http://pre.racket-lang.org/docs/html/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._boolean%7E3f%29%29>
>  v) → boolean?<http://pre.racket-lang.org/docs/html/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._boolean%7E3f%29%29>
>     v : any/c<http://pre.racket-lang.org/docs/html/reference/Data-structure_Contracts.html#%28def._%28%28lib._racket/contract/private/misc..rkt%29._any/c%29%29>
>
> Question 1
> The result (boolean?<http://pre.racket-lang.org/docs/html/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._boolean%7E3f%29%29>
>  v) is a boolean.  Why is it not
>   (boolean?<http://pre.racket-lang.org/docs/html/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._boolean%7E3f%29%29>
>  v) → boolean  instead of  (boolean?<http://pre.racket-lang.org/docs/html/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._boolean%7E3f%29%29>
>  v) → boolean?<http://pre.racket-lang.org/docs/html/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._boolean%7E3f%29%29>
> ?
>
>  Question 2
> If v can be anything,  why not just use any instead of using any/c<http://pre.racket-lang.org/docs/html/reference/Data-structure_Contracts.html#%28def._%28%28lib._racket/contract/private/misc..rkt%29._any/c%29%29>
> ?
>
>  Question 3
> What does / and c mean?
>
> BTW, did I missed the definition of / and c?  I have not read the entire
> document.
>
> Thanks a lot.
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110530/fb9e6db2/attachment.html>

Posted on the dev mailing list.