Was there ever any doubt? :)
Still requiring extensions from earlier posts:
(def dsb-params-parse (params) (withs (reqs nil key? nil opt? nil keys nil opts nil rest (mem '&r params) rest-var (cadr rest) aok? (find '&aok cddr.rest) resting? nil no-mas nil) (each p params (if no-mas (assert nil "No params &aok, OK?" ',params) (is p '&o) (do (assert ~opt? "Duplicate &o:" ',params) (assert ~key? "&k cannot precede &o:" ',params) (= opt? t)) (is p '&k) (do (assert ~key? "Duplicate &k:" ',params) (= key? t)) (is p '&r) (= resting? t) (is p '&aok) (= no-mas t) key? (push-end p keys) (and opt? (no resting?)) (push-end p opts) (no resting?) (do (assert (~acons p) "Reqd parameters need not be defaulted:" p) (push-end p reqs)))) (prt 're-obj!!!!! reqs opts rest-var keys aok?) (obj reqs reqs opts opts rst rest-var keys keys aok? aok?)))
(mac dsb (params data . body) (w/uniq (tree kvs valid-keys aok?) `(withs (,tree ,data ,@(let plist (dsb-params-parse params) (prn `(reqs ,plist!reqs)) (prn `(rst ,plist!rst)) (prn `(keys ,plist!keys)) (prn `(&aok ,plist!aok?)) (with (n -1) (+ (mappend [list _ `(nth ,(++ n) ,tree)] plist!reqs) (mappend [list (carif _) `(if (< ,(++ n) (len ,tree)) (nth ,n ,tree) ,(cadrif _))] plist!opts) `(,plist!rst (nthcdr ,(++ n) ,tree)) `(,valid-keys ',plist!keys) `(,aok? ',plist!aok?) `(,kvs (do (prt 'foing ,valid-keys) (when (and ,plist!rst ,valid-keys) (assert (even (len ,plist!rst)) "Keyword list not even" ,plist!rst) (let ,kvs (pair ,plist!rst) (prt 'vetting ,valid-keys 'againt ,kvs) (unless ,aok? (assert (all [find (car _) ,valid-keys] ,kvs) "Invalid key in" (map car ,kvs))) (prt 'kvs!!!!! ,kvs) ,kvs)))) (mappend [list (carif _) `(do (prt 'kvs!!! ',(carif _) ,kvs) (aif (assoc ',(carif _) ,kvs) cadr.it ,(cadrif _)))] plist!keys))))) ,@body)))
(err:tostring:write ...) works fine for me for reporting errors and aborting
-----