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

MULTPLE-VALUE-OR &rest args



    >I think more to the heart of the matter is that Common LISP needs a way to grab,
    >inspect, and pass on an unknown number of multiple values without consing
    > (and yes, avoiding consing can be crucial for real applications
    > give the current state of the art for garbage collection
    > on conventional hardware).  It's possible that, using
    >multiple-value-call, simply having some way of 
    >doing non-consing &rest arguments may be sufficient.   ...

    I whole-heartly agree that A) Unneccessary consing should always be avoided,
     B) it would be great to have &rest args that don't cons.
    I currently have plans to have a STACK-LIST declaration that declares that
    a &Rest is stack-allocated (as well as WITH-STACK-LIST, ala Lisp Machines)
    in my system.  I would suggest that others consider this as well, but
    of course, it is only a declaration that could be ignored.
    (I already avoid consing for (&Rest ignore), which should be easy).

    My point is that MULTIPLE-VALUE-OR can only be done efficiently by low-level
    implementation-specific code, and thats why it should be in Common Lisp.

 >I don't think this conclusion follows from your previous paragraph.
 >If the proposed MULTIPLE-VALUE-OR can easily be implemented in terms of
 >existing primitives, such as MULTIPLE-VALUE-CALL, and would be efficient
 >if there were non-consing &rest arguments, and non-consing &rest arguments
 >are desirable for other reasons, then I think a more logical conclusion is
 >"because non-consing &rest arguments can only be done efficiently by low-level
 >implementation-specific code, they should be in Common Lisp."

Are you just pointing out a flaw in my logic, or are you suggesting that
Common Lisp REQUIRE certain &rest args to not cons?  The last sentence
was not meant to logically follow from the previous -- I was merely
re-iterating my point in requesting a MULTIPLE-VALUE-OR form, which is it
can be efficiently implemented WITHOUT non-consing rest args.  I might
also add that using MULTIPLE-VALUE-CALL is going to require both 
a Lambda and a Block, in which the Return-From will end up being a Throw.
It might not Cons, but I wouldn't call that "Efficient" (Maybe Symbolics does
function calls and throws more efficiently than a couple tests and a branch?
If so, that is exactly why it should be in Common Lisp -- You do it your way,
I'll do it mine).

 >By the way, I don't think a declaration for non-consing &rest arguments
 >should be necessary.  It should be simple enough for any compiler to
 >recognize special cases such as the following, once implementors'
 >attention has been drawn to the desirability of such optimizations.  Another
 >way of saying the same thing is that I think consing is an implementation
 >issue, not a language issue, just as much as whether integer multiplication
 >takes 1 microsecond or 10 microseconds.

 >  (lambda (&rest values)
 >    (when (first values)
 >      (return-from block (values-list values))))

I guess you are saying Common Lisp shouldn't REQUIRE any &rest args not to cons.
I certainly agree - it is properly in the domain of Optimizations.  A declaration
may not be always be necessary, but this is just about in the same category
as determining whether a function has side-effects.  You can sometimes prove
it doesn't, but why go to all the bother if a very knowledgable and intelligent
(compared to a compiler) programmer can simply tell you?

- Kelly Murray