[racket] Arity check
Why racket doesn't check arity when compiling?
(define (test)
(car 12 3))
compiles and even runs. Ir raises an error only when test is called.
I can have desirable result making
(define-syntax car*
(make-set!-transformer
(λ (stx)
(syntax-case stx ()
[(car* x) (syntax-protect (syntax/loc stx (car x)))]
[(car* x ...) (raise-argument-error 'car "one argument" (syntax->datum #'(x ...)))]
[car* (syntax-protect (syntax/loc stx car))]))))
(define (test)
(car* 12 3))
But it is cumbersome (I'll have to wrap every function) and I don't understand why compiler shouldn't see function contracts.
--
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130821/783750e3/attachment.html>