[plt-scheme] Contract question

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Jun 13 14:31:46 EDT 2008

That function accepts a mandatory keyword parameter using the keyword
whose name just happens to be #:optional which, I'm guessing, is not
what you intended.

Anyways, here is its contract:

  (-> any/c #:optional any/c false/c)

If you wanted a function that takes either one or two arguments (as
the contract suggests), I think you meant to write it like this:

  (define (foo a [b #f]) #f)

(They keyword syntax changed a little bit from 372's (lib "kw.ss") to
4.0. Maybe that's the source of the confusion?)


On Fri, Jun 13, 2008 at 1:28 PM, David Einstein <deinst at gmail.com> wrote:
> How do I write a contract for the following
> (define (foo a #:optional b) #f)
> I would have thought that
> (provide/contract
>   [foo (->* (any/c) (any/c) false?)]
> )
> would work, but obviously I'm missing something.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.