[plt-scheme] Contract question

From: David Einstein (deinst at gmail.com)
Date: Fri Jun 13 14:42:59 EDT 2008

Thanks.  The source of the problem was that I missed the note in the
documentation for scheme/kw saying that

"The lambda<file:///C:/Program%20Files/PLT-FULL-3.99.0.26/doc/reference/lambda.html#%28form._%28%28lib._scheme/base..ss%29._lambda%29%29>and
procedure-application forms of
scheme/base support keyword arguments, and it is *not* compatible with the
mzlib/kw library."

and blithely went on thinking they were the same.  I'll pay more attention
to the sidenotes in the future.  Thanks again.

On Fri, Jun 13, 2008 at 2:31 PM, Robby Findler <robby at cs.uchicago.edu>
wrote:

> 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?)
>
> Robby
>
> 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
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080613/ef70724b/attachment.html>

Posted on the users mailing list.