From: Christophe Rhodes
Subject: (setf format)
Date: 
Message-ID: <sqitxv15qi.fsf@lambda.jesus.cam.ac.uk>
As threatened...

I've put up a (short) webpage at
http://www-jcsu.jesus.cam.ac.uk/~csr21/format.html 
and some code at
http://www-jcsu.jesus.cam.ac.uk/~csr21/format-setf.lisp
that attempts to implement (setf format). A reasonable subset of
format is supported (I think) with not too many bugs (I hope).

There are a couple of style issues that worry me about the programme:

1. I have some macros expanding to things like:
`(format-setf-integer ,a ,b ,c ,d ,e 12)
Does this indicate that format-setf-integer should really be a
function returning a list? All those commas worry me.

2. (setf format) often expands into recursive calls to (setf
format). The problem (amazingly) is not the termination; that seems to
work fine. However, at least for the ~t directive, it is necessary to
keep the entire value string around (so that we can find out the
current column). I have, briefly,

(in-package "FORMAT-SETF")
(defvar *value* nil)
(defmacro format-setf (stream control-string &rest args)
  `(let ((*value* (or *value* ,(first (last args)))))
     ;; here *value* takes the value of the outermost *value*, if you
     ;; see what I mean...
     ...))

Is this an acceptable way round this problem? Is there a better way
that I have missed?

Thanks,

Christophe
-- 
(macrolet ((f (a b) `(unless (equal ,a "") (princ (aref ,a 0)) (setf ,a 
(subseq ,a 1)) (,b))) (z (&rest a) `(format nil ยทยท@{~35r~^ ~}" ,@a))) (
let ((w (z 693 29204 28104384)) (x (z 1984050605838 12977))) (labels ((
y () (f w z))(z () (f x y))) (y) (terpri))))#|Jesus College,Cambridge|#