CL-USER> (progn
(format t "abc~%")
(format t "~&abc"))
abc
abc
NIL
CL-USER>
My guess is: An ostream descriptor always stores the latest char sent to it.
Say, after ostream receiving an #\a
, FORMAT
can determine that the ostream is not at the beginning because the latest char sent to it is #\a
.
But I'm not sure that's really the case.
~&
just calls fresh-line
, so the question is in fact how does fresh-line
know this, and the answer is
If you look at various implementations for which source is available you will probably find various ways they do this. For instance SBCL has an fd-stream
object (in src/code/fd-stream.lisp
) which keeps track of the output-column
. But how implementations do this, and whether they do it at all, is up to them.