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 callsfresh-line, so the question is in fact how doesfresh-lineknow this, and the answer isIf 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-streamobject (insrc/code/fd-stream.lisp) which keeps track of theoutput-column. But how implementations do this, and whether they do it at all, is up to them.