I have not used format in about a decade. (I admit, I just print/princ/prin1/terpri my stuff together.) My conclusion is format is working.
Yes, I confirm that fe2o3’s example throws an error (yet works fine not in SBCL), but will be fine if you omit the minus and change it to:
(format t “The number is ~10d” 3.14)
If x is defined, then
(setf x (format nil “The answer is ~a” 42))
really does set x to that value (and I think this is ever going to be its most important function: dumping stuff into a string). And also, if I change nil to t and do:
(setf x (format t “The answer is ~a” 42))
- then x is actually set to nil. That is what SBCL does, too.
These all throw errors - as they SHOULD:
(format t “~{~a/~a ~}” #(1 2 3 4 5 6))
(format t "alpha ~r " 20)
(format t “~}” '(A))
A trailing tilde is ignored - which is fine, and it is good it does not crash the environment:
(format t “~x~” 16) --> 10
(format t “test ~d” -2.0) --> test -2.0
- this is what SBCL does, too
(format t “test ~g” -2) --> test -2
- HERE, however, SBCL gives -2. and not -2, to indicate the floating point nature. (But given you do all in float anyway, e.g. stuff like (/ 2 3) gives 0.6…, I think it doesn’t matter.)
Another thing - which is FINE - apparently boundp tolerates unquoted function names:
(boundp boundp) --> nil (which is correct, but e.g. SBCL throws an error).
All in all, I think format looks solid and is fine.