[racket] define/contract with default arguments

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Mon May 23 16:14:51 EDT 2011

On 05/23/2011 02:12 PM, Jon Rafkind 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)

Use ->*:

(define/contract (x [a 5]) (->* () (number?) number?) a)

Ryan


Posted on the users mailing list.