[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (setf (foo #) value), foo being undefined yet



I wrote:
> I'm not sure whether the above code intended to make use of this
> extended setf behaviour and thus was written for CLtLII.

Bruno Haible replied:
> It is wrong only w.r.t. CLTL1, but is will be a good idea to change
> the macroexpansion of (DEFROUTINE ...) from

I still think that it's even wrong for CLtLII the way it was done, but
anyway I changed it to generate:
(PROGN
 (DEFSETF E** E**-SET)
 (DEFSETF I** I**-SET)
 ;; neither E** nor E**-SET are defined now, but they'll be when this
 ;; function gets called. A (declare (notinline E** E**-SET)) could be
 ;; in add1-nam** to make things really safe.
 (DEFUN ADD1-NAM** (N)
   (LET ()
     (COND ((< (I**) N) (SETF (E**) (+ (E**) 1))) (T NIL))
     (VALUES)))
 (DEFMACRO ADD1-NAM (E I N)
   `(PROGN
     ,@(DEFTHUNK 'E** E)
     ,@(DEFTHUNK 'I** I)
     (MULTIPLE-VALUE-BIND NIL (ADD1-NAM** ,N))
     NIL)))
and removed the defsetf from the defthunk generation:
> (defthunk 'e** 'bar)
((SETF (SYMBOL-FUNCTION E**) #'(LAMBDA () BAR))
 (SETF (SYMBOL-FUNCTION 'E**-SET) #'(LAMBDA (VAL) (SETF BAR VAL))))
making the setf functions known to Lisp before their use.

 	Joerg.
hoehle@inf-wiss.ivp.uni-konstanz.de