I’ve a very big array composed of only nil s and t s .
My questions is; does it make sense for the compiler to make type declaration within a function that handles this specific type of array. If so what should the declaration look like?
For example:
(defun foo(my-array)
(declare (type (array ?????) my-array))
....
First notice that in Common Lisp an array of type
(array boolean)(where BOOLEAN is the applicable type) is not an array that just happens to contain onlyts andnils, but an array that can only contain those, which is a property that has to be specified during creation of the array. Violating this will result in a run-time error or undefined behaviour depending on yoursafetylevel.I don’t think there is much point in specifying the type at function level, since I don’t believe there are any applicable optimizations. You might consider using bit-vectors, which are at least tightly packed and allow the use of fast bit processing instructions. That is, if your data is representable in one dimension, since I am not sure how much those apply for multidimensional
(array bit)arrays.