[racket] Default arguments don't need to follow the contract?

From: Neil Toronto (neil.toronto at gmail.com)
Date: Sat Oct 1 14:23:49 EDT 2011

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

Posted on the users mailing list.