From e7fdc0887de814a1566e9e59d5ab23899612112f Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 4 Aug 2009 18:16:53 +0000 Subject: [PATCH] added support for number-based argument specification svn: r15669 --- collects/htdp/error.ss | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/collects/htdp/error.ss b/collects/htdp/error.ss index e5a0d46a83..3d9e1ed1fd 100644 --- a/collects/htdp/error.ss +++ b/collects/htdp/error.ss @@ -62,11 +62,30 @@ (car other-given) given)))) -;; check-arg : sym bool str str TST -> void +;; check-arg : sym bool str (or/c str non-negative-integer) TST -> void (define (check-arg pname condition expected arg-posn given) (unless condition (tp-error pname "expected <~a> as ~a argument, given: ~e" - expected arg-posn given))) + expected + (spell-out arg-posn) + given))) + +(define (spell-out arg-posn) + (cond + [(string? arg-posn) arg-posn] + [(number? arg-posn) + (case arg-posn + [(1) "first"] + [(2) "second"] + [(3) "third"] + [(4) "fourth"] + [(5) "fifth"] + [(6) "sixth"] + [(7) "seventh"] + [(8) "eighth"] + [(9) "ninth"] + [(10) "tenth"] + [_ (format "~ath") arg-posn])])) ;; check-arity : sym num (list-of TST) -> void (define (check-arity name arg# args)