(define impc:ti:register-new-nativefunc
(lambda (nativefunc-name type docstring arg-list)
;; check arg types
(if (not (and (or (string? nativefunc-name) (begin (println 'bad 'nativefunc-name: nativefunc-name) #f))
(or (list? type) (begin (println 'bad 'type: type) #f))
(or (string? docstring) (begin (println 'bad 'docstring: docstring)))
(or (list? arg-list) (begin (println 'bad 'arg-list: arg-list)))))
(impc:compiler:print-compiler-error "couldn't register new nativefunc")
(let ((existing (assoc-strcmp nativefunc-name *impc:ti:nativefunc-cache*)))
(if existing
;; update details if it already exists
(set-cdr! existing (vector type docstring arg-list))
;; or create a new entry
(begin
(set! *impc:ti:nativefunc-cache*
(cons (cons nativefunc-name (vector type docstring arg-list))
*impc:ti:nativefunc-cache*))
(car *impc:ti:nativefunc-cache*)))))))