Closed galdor closed 6 months ago
The problem is that you're asking to print this vector readably. sbcl uses an implementation specific syntax, so it's de-facto non-conforming code.
Now there may be a question of interpretation of the standard, whether printing readably is limited to same implementation loopbacks, or whether it should be possible across implementations. (Also, whether other *print-...*
settings must be taken into account (a strict reading would make us print symbols fully qualified and escaped).
IMO, printing readably notably with standard-io-syntax, should use only standard reader macros syntax. So the bug is in sbcl.
cl-user>
(let ((vector (make-array 0 :element-type '(unsigned-byte 64)
:adjustable t :fill-pointer 0)))
(vector-push-extend 1 vector)
(vector-push-extend 2 vector)
(vector-push-extend 3 vector)
(with-standard-io-syntax
(let ((*print-readably* nil))
(print `(make-array ,(length vector)
:element-type (unsigned-byte 64)
:initial-contents ,vector)))))
(MAKE-ARRAY 3 :ELEMENT-TYPE (UNSIGNED-BYTE 64) :INITIAL-CONTENTS #(1 2 3))
(make-array 3 :element-type (unsigned-byte 64) :initial-contents #(1 2 3))
cl-user> #A((4) (UNSIGNED-BYTE 64) 1 2 3 0)
> Debug: Reader error on #<string-input-stream #x3020F1DDAE8D>, near position 2, within "#A((4) (UNSI":
> reader macro #A used without a rank integer
> While executing: (:internal swank::invoke-default-debugger), in process repl-thread(15).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > :q
; Evaluation aborted on #<ccl::simple-reader-error #x3020F1DDAC0D>.
cl-user>
(Note the standard-IO-syntax print in uppercase, and the result printed with *print-case*
set to :downcase
).
CL Standard 22.1.3.7: "If *print-readably* is true, the vector prints in an implementation-defined manner". WITH-STANDARD-IO-SYNTAX
sets *PRINT-READABLY*
to T
so SBCL isn't non-conformant.
Beyond the fundamental issue of vector printing, I would expect CCL to:
#<error printing object>
objects).Oops, you're right. (I don't like it when the standard allows implementation dependent behavior!)
The error message could be better, I agree.
The backtrace is unlovely, but I assume that the lisp was running in some context where it couldn't enter an interactive break loop.
Issue #253 is about adding an extension to CCL to print arrays readably.
https://github.com/Clozure/ccl/commit/3194ef10ee1fa15ba5e0394974a88ade371e9138 provides a hopefully-better message for print-not-readable
.
I guess that the #<error printing object>
entries in the backtrace may be due to *print-readably*
being bound to true.
With SBCL:
With CCL 1.12.2: