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

Re: fixing our problems with setf

    Date: Tue, 13 Oct 87 20:01:00 PDT
    From: Pavel.pa@Xerox.COM

    A nit in your test case.  It would be nicer if the optional variable end
    had a default value rather than using the (unless end ...) hack:

Not so.  Refer to the definition of the meaning of the arguments to functions
like subseq, CLtL p.246, which says that supplying NIL as end is the same as
omitting end.

    ;If setf of subseq was not already built into Common Lisp,
    ;it could have been defined like this
    (defun (setf subseq) (new-value sequence start &optional (end (length
      (setq end (min end (+ start (length new-value))))
      (do ((i start (1+ i))
	   (j 0 (1+ j)))
	  ((= i end) new-value)
	(setf (elt sequence i) (elt new-value j))))