I want to improve the quality and quantity of compiler warnings that I get - is there a way in Common Lisp to include type predicates over declared types, as well as over instances - the concrete answers are all right, I am interested to see how this is done if someone does this will do.
Compilation in CCL as follows:
(defun non-list (o) (not (listp o))) (deftype non-list () '(satisfies non-list)) (defun example (a) (list a)) (declaim (ftype (function (non-list) list) example)) (defun hmm () (declare (optimize (debug 3) (safety 3))) (let ((a '(abc)) (b '(def))) (declare (type list a)) (example '(ghi)) (example a) (example b)))
I will get a warning about the compiler when I first call example - one that provides an instance of which can be checked with satisfies . This is good, and with the debug settings I get a runtime error which is good. I am wondering if I can write something like the following:
(defun non-list-typep (type) (not (subtypep type 'list)))
and somehow integrate it so that at least the second call - (example a) gives a warning at compile time, because its declared list type crashes the non-list-typep
Hooray!
source share