<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>In general, the problem is undecidable: </div><div><br></div><div>(define (f x) x)</div><div>(define (g x y) x)</div><div><br></div><div>(define (h x) (if (today-is-tuesday?) (h x 10) (h x)))</div><div><br></div><div>(h f)</div><div><br></div><div>Error? </div><div><br></div><div>In specific circumstances, the compiler knows which function is called and could perform a check. By tradition, we don't but it's worth considering. Still, even then: </div><div><br></div><div>(define (f x) (if (today-s-date-satisfies-fermats-last-theorem?) (car x 10) (car x)))</div><div><br></div><div>Is this an error or a warning? </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><div><div>On Aug 21, 2013, at 4:16 AM, Roman Klochkov wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div><p>Why racket doesn't check arity when compiling?<br><br>(define (test)<br> (car 12 3))<br><br>compiles and even runs. Ir raises an error only when test is called.<br><br>I can have desirable result making<br><br>(define-syntax car*<br> (make-set!-transformer<br> (λ (stx)<br> (syntax-case stx ()<br> [(car* x) (syntax-protect (syntax/loc stx (car x)))]<br> [(car* x ...) (raise-argument-error 'car "one argument" (syntax->datum #'(x ...)))]<br> [car* (syntax-protect (syntax/loc stx car))]))))</p><p>(define (test)<br> (car* 12 3))<br><br>But it is cumbersome (I'll have to wrap every function) and I don't understand why compiler shouldn't see function contracts.<br><br>-- <br>Roman Klochkov</p></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>