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

Dynamic extent with &rest params



I am writing an embedded language which implements all parameter
passing through &rest parameters. I am considering whether to 
declare those rest params to be dynamic extent. 

After having read the MCL 2.0/Common Lisp optimization techniques 
and p.236 of CLtL2, I am still slightly confused about what 
declaring a rest parameter list to be dynamic extent means. 

My question is as follows:
In declaring a rest parameter to be dynamic extent, is it 
sufficient to know that no part of the rest list structure is
used outside the dynamic extent declaration, or must I know 
something about the elements of the list (the arguments passed)
as well?

In other words, is the following declaration of dynamic extent
guaranteed to be correct irrespective of the arguments passed to
some-function?

(defun some-function (&rest rest)
  (declare (dynamic-extent rest))
  ; Any code which doesn't reference rest

  (let ((return-var (first rest)))
    ; Any code which doesn't reference rest, 
    ; but may reference return-var

    return-var)
    ; Any code which doesn't reference rest, 
    ; but may reference return-var
  )

I think it is, but I also think there might be might be things 
to do with immediate data types which I haven't thought of.

Anyone know? 

Oddmund Mogedal
Norwegian Institute of Technology
oddmund@idt.unit.no