Skip to content

Cannot displace an array of base-char into one of character

The following code succeeds under ABCL, CCL, Allegro, and Clisp, but fails under SBCL and ECL:

(let ((s (make-array 5 :element-type 'base-char :initial-contents "hello")))
  (make-array 2 :element-type 'character :displaced-to s))

Citing that because the array types are different (even though character is a superclass of base-char), that the displacement can't occur.

Please let me know if this is expected behaviour for ECL. I could see it making sense, as base-char != character (e.g. #\é and #\涅), and perhaps there is some sexier internal representation it's using for simple-base-string.