[racket] Default arguments don't need to follow the contract?
That is my impression too, but it would be good to be sure there are
test cases that explicitly check for this.
Robby
On Sat, Oct 1, 2011 at 1:41 PM, Stevie Strickland <sstrickl at ccs.neu.edu> wrote:
> I have no plans to ever change that behavior. I consider the default arguments as being inside the contract boundary for these definitions, which means they are unchecked. The programmer of the function, not the client of the function, is responsible for these values, so he can either ignore the contract or stick to it as desired.
>
> Stevie
>
> On Oct 1, 2011, at 2:23 PM, Neil Toronto wrote:
>
>> This seems odd, but is useful:
>>
>> (define/contract (foo #:opt1 [opt1 #f] #:opt2 [opt2 #f])
>> (->* () (#:opt1 real? #:opt2 real?) real?)
>> (or opt1 opt2 30))
>>
>>
>> The keyword arguments' default values aren't 'real?', but nothing complains when 'foo' is applied.
>>
>> It allows me to have 'foo' with an '#:opt1' keyword with contract 'real?', default 30, and an '#:opt2' keyword for backward-compatibility:
>>
>> (foo) ; => 30
>> (foo #:opt1 45) ; => 45
>> (foo #:opt2 23) ; => 23
>> (foo #:opt1 45 #:opt2 23) ; => 45
>>
>>
>> Is it intentional? Will this behavior ever change?
>>
>> Neil T
>> _________________________________________________
>> For list-related administrative tasks:
>> http://lists.racket-lang.org/listinfo/users
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>