In my format ~VT tabs behave differently depending on whether the newline ~% at the beginning or end of the lines, and I would like to know why. The difference is that when a new line is at the end of lines, the first instance seems to have extra tab-only space. The following examples illustrate. The only difference in the examples is in the format control line: it "~%~A~VT= ~A" in the first example and "~A~VT= ~A~%" in the second.
EXAMPLE 1: new line at the beginning of output lines
(let ((sb (make-array 0 :element-type 'character :adjustable t :fill-pointer 0))) (mapcar (lambda (line) (format sb "~%~A~VT= ~A" line 10 42)) '(a abcd asdf foobar g november)) sb) " A = 42 ABCD = 42 ASDF = 42 FOOBAR = 42 G = 42 NOVEMBER = 42"
The behavior here is as expected.
EXAMPLE 2: new line at the ends of output lines
In this example, it should be noted that the first line,
A = 42
has one more space in it than the corresponding line from example 1:
A = 42
It's a little hard to see because of the leading double quote, and so I cut it off: to help you see them better. This is repeatable on much larger examples and is MVE devoid of a much larger program.
(let ((sb (make-array 0 :element-type 'character :adjustable t :fill-pointer 0))) (mapcar (lambda (line) (format sb "~A~VT= ~A~%" line 10 42)) '(a abcd asdf foobar g november)) sb) "A = 42 ABCD = 42 ASDF = 42 FOOBAR = 42 G = 42 NOVEMBER = 42 "
The question with the big picture "why?" I use SBCL 1.3.1 on a Mac and have not tried it in other implementations. It may be a mistake, but it seems more plausible that it was intended for behavior, but I donβt understand what it could be for achievement, and I could not find an explanation in the format documentation.
source share