Reputation: 2165
I've made an executable that includes calls to arrays. When I execute the program, I get the error
Condition of type: SIMPLE-TYPE-ERROR
In function AREF, the index into the object
#(0.00387149 3.0345068e-4 5.9720734e-4 -1.6648759e-5 0.058811672).
takes a value 5 out of the range (INTEGER 0 4).
I looked up simple-type-error, and I believe it occurs when a value is of an unexpected type. However I was of the impression that you don't have to specify types in Lisp.
Upvotes: 0
Views: 692
Reputation: 139311
You don't have to, but a Lisp system hopefully will complain when you call a function with the wrong type of object.
CL-USER 7 > (sin "a string")
Error: In SIN of ("a string") arguments should be of type NUMBER.
The LispWorks error report for your problem is bit less 'technical':
CL-USER 8 > (aref #(a b c d) 4)
Error: The subscript 4 exceeds the limit 3 for the first dimension
of the array #(A B C D).
Which makes sense, since dimensions are zero-based. The above vector has index 0, 1, 2, and 3. But not 4.
CL-USER 10 > (typep 4 '(integer 0 3))
NIL
So 4 is not an integer in a range of 0 to 3.
Upvotes: 2