define-typed working;; parsing keywords in lambdalists correctly next
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
(define-typed (ttt a :number b :alist) (printf a b))
|
||||
|
||||
(define (null? x) "Checks if the argument is =nil=." (= x ()))
|
||||
|
||||
(define (type=? obj typ) "Checks if the argument =obj= is of type =typ=" (= (type obj) typ))
|
||||
|
||||
(define (types=? :rest objs) (if objs (begin (assert (keyword? (first (rest objs)))) (if (type=? (first objs) (first (rest objs))) (apply types=? (rest (rest objs))) ())) t))
|
||||
(define (types=? :rest objs) (define (inner objs) (if objs (let ((actual-type (type (first objs))) (desired-type (first (rest objs)))) (if (= actual-type desired-type) (inner (rest (rest objs))) ())) t)) (inner objs))
|
||||
|
||||
(define (assert-types= :rest objs) (break) (unless (apply types=? objs) (error "assert-types=: types do not match")))
|
||||
(define (assert-types= :rest objs) (define (inner objs) (when objs (let ((actual-type (type (first objs))) (desired-type (first (rest objs)))) (if (= actual-type desired-type) (inner (rest (rest objs))) (error "type missmatch" actual-type desired-type))))) (inner objs))
|
||||
|
||||
(define (number? x) "Checks if the argument is a number." (type=? x :number))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user