If (second args)
is NIL
then either args
has no second
or its second
is NIL
. However, the third argument to mem-aref
must be a number since it is an index. Therein lies the problem.
If in your program (second args)
is allowed to be NIL
(or to not exist), then you'll have to test for that possibility and avoid passing NIL
to mem-aref
(maybe by leaving out that optional argument). If (second args)
is not allowed to be NIL
, then the bug is somewhere else in your program.
E.g. (untested),
(defun vector-float (&rest args)
(cond
((null (first args))
(return-from vector-float (%vector-float)))
((listp (first args))
(c-arr-to-vector-float (first args)))
((symbolp (second args))
(%vector-float-size (first args)))
((pointerp (first args))
(if (null (second args))
(mem-aref (%vector-float-to-c-array (first args)) :float)
(mem-aref (%vector-float-to-c-array (first args)) :float (second args))))
(t nil)))