Array or char bug?

Q&A's, tips, howto's
Locked
cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Array or char bug?

Post by cameyo »

I have some problem to update an array:

Code: Select all

; define an array
(setq ar (array 256 '(-1)))
; define a string
(setq str "bar")
; define an index
(setq idx (char (str 0)))
;-> 98
(number? idx)
;-> true
; update array
(setf (ar idx) 555)
;-> 555
(number? (char (str 0)))
;-> true
; update array fail
(setf (ar (char (str 0))) 555)
;-> ERR: string expected : 555
Why the last expression raise an error?

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: Array or char bug?

Post by cameyo »

Reading the manual for "char" function...
This solve the problem (on UTF-8 enabled system):

Code: Select all

(setf (ar (char (str 0) 0 true)) 555)
;-> 555

Locked