This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

element-type in array..

4 posts · 3123 views

HI
If I try to make a resizable string with make-array, but error raises with vector-push..:
(defparameter str (make-array 10 :fill-pointer 0 :adjustable t :element-type 'character))
>STR
(vector-push 'a' str)   ;;error raise:

value STR is not of the expected type (AND
                                       ARRAY
                                       (SATISFIES
                                        ARRAY-HAS-FILL-POINTER-P)).
   [Condition of type TYPE-ERROR]
....?it works without specify :element-type.....but why it's atype error?? 'a' is a char...
thanks in advance!!!

Re: element-type in array..

Because 'a' isn't a character. This works:
(vector-push #\a str)
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Re: element-type in array..

(vector-push 'a' str) is the same as (vector-push 'a 'str) is the same as (vector-push (quote a) (quote str)) -- you're trying to push the symbol A onto the symbol STR.

You probably want VECTOR-PUSH-EXTEND, too.

Re: element-type in array..

opss'!!!
perfect thanks!