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

Re: Stack-consed &REST args?



chucko@whitman.arc.nasa.gov (Chuck Fry ) writes:
 
>Next question: I was unable to find anywhere in the MCL 2.0
>documentation, or the FAQ, any reference to the DYNAMIC-EXTENT
>declaration, and particularly the use of this declaration on &REST
>arguments of functions.  Several other CL implementations support this
>idiom by stack-consing &REST args for such functions.  Does MCL?  If
>not by default, is there a patch or hack available to add this
>support?

Apparently it does stack cons it; You can test it out 9as probably
just slipped your mind) consider the example you gave:

? (defun test1 (&rest nums)
    (reduce #'+ nums))
TEST1
? (time (without-interrupts (test1 1 2 3 4 5 6 7 8 9 10)))
(WITHOUT-INTERRUPTS (TEST1 1 2 3 4 5 6 7 8 9 10)) took 1 milliseconds (0.001 seconds) to run.
Of that, 1 milliseconds (0.001 seconds) were spent in The Cooperative Multitasking Experience.
 80 bytes of memory allocated.
55
? (defun test2 (&rest nums)
    (declare (dynamic-extent nums))
    (reduce #'+ nums))
TEST2
? (time (without-interrupts (test2 1 2 3 4 5 6 7 8 9 10)))
(WITHOUT-INTERRUPTS (TEST2 1 2 3 4 5 6 7 8 9 10)) took 0 milliseconds (0.000 seconds) to run.
55

Without the declaration it conses 80 bytes, with it nothing.