Can you be more specific about what playing nice is in this context?

Robby

On Mon, May 23, 2011 at 3:12 PM, Jon Rafkind <[email protected]> wrote:
> Is there a way to get `define/contract' to play nice with default
> arguments? I could see how this would be an issue in general (like
> trying to provide/contract some function defined with default arguments)
> but I was hoping `define/contract' could set things up so it would work.
>
>> (define/contract (x [a 5]) (-> number? number?) a)
>> (x 2)
> 2
>> (x)
> self-contract violation: received 0 arguments, expected 1 non-keyword
> argument
>  contract on x from (function x), blaming (function x)
>  contract: (-> number? number?)
>        at: readline-input::69-70
>
>  === context ===
> /home/jon/bin/plt/collects/racket/contract/private/blame.rkt:58:0:
> raise-blame-error
> basic-checker53
> /home/jon/bin/plt/collects/racket/private/misc.rkt:85:7
>
>> (define/contract (y [a 5]) (-> number?) a)
>> (y)
> 5
>> (y 9)
> self-contract violation: received 1 argument, expected 0 non-keyword
> arguments
>  contract on y from (function y), blaming (function y)
>  contract: (-> number?)
>        at: readline-input::130-131
>
>  === context ===
> /home/jon/bin/plt/collects/racket/contract/private/blame.rkt:58:0:
> raise-blame-error
> basic-checker61
> /home/jon/bin/plt/collects/racket/private/misc.rkt:85:7
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to