Suppose you have the following
(defun highly-popular-function (x) (mapcar #'something x))
where not only is this function called very often, but almost always with X being NIL.
On the whole it conses madly despite NIL input. Two solutions come to mind:
1. the loop over the input should check whether there is anything to do. if not, just return nil
2. the "extra" cons cell that is pre-allocated for the purpose of being able to do RPLACD down the chain can perhaps be stack-allocated
well, three solutions: make the poor user write (if x (mapcar #'something x)).
Specifically, in this loop in 'mapfoo-transform' and the similar one for 'nconc', and also for the LOOP macro (which I once found where to insert the dx but have since forgotten), I am proposing that MAP-RESULT be declared truly-dynamic-extent.
(let ((temp (gensym))
`(let ((,map-result (list nil))) ; <-- this guy
(do-anonymous ((,temp ,map-result) . ,(do-clauses))
(,endtest (truly-the list (cdr ,map-result)))
(rplacd ,temp (setq ,temp (list ,call)))))))
I don't think the rules of contagion imply that the head cell being dx forces its CAR and CDR to be dx. The opposite is true - an object that contains that cell _would_ be dx, but nothing contains that cell - nobody has access to it. And, moreover, we know that the compiler doesn't dxify anything except the (LIST NIL) anyway, so even if somehow a language lawyer could read into the HyperSpec's explanation about dx that the cells which were RPLACD'd in _were_ in fact "contaminated" by the dx declaration, we know that in _this_ implementation we're still OK.
Does that sound right?