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

*To*: Mark.Perlin@J.GP.CS.CMU.EDU*Subject*: Re: consing with +*From*: bill@cambridge.apple.com (Bill St. Clair)*Date*: Thu, 2 Sep 1993 10:31:00 -0500*Cc*: info-mcl

At 10:13 AM 9/2/93 -0400, Mark.Perlin@J.GP.CS.CMU.EDU wrote: >Since + has &rest arguments, it may entail consing. I'm certainly getting >enough garbage collection in inner numerical loops to suggest this. >Questions: > >(1) Does +, indeed, entail consing? (If not, then DOTIMES must be the >culprit, which is even less likely.) > >(2) If (1) is true, is there any way to force + to be a nonconsing binary >operator? + does not cons due to its rest argument. If the result is other than a fixnum or short float, however, storage for the result will be consed. Example (I used LET below to prevent the addition from being done at compile time): ? (time (let ((x 1) (y 2)) (+ x y))) (LET ((X 1) (Y 2)) (+ X Y)) took 0 milliseconds (0.000 seconds) to run. 3 ? (time (let ((x 1.2s0) (y 3.4s0)) (+ x y))) (LET ((X 1.2S0) (Y 3.4S0)) (+ X Y)) took 0 milliseconds (0.000 seconds) to run. 4.6000004S0 ? (time (let ((x 1.2) (y 3.4)) (+ x y))) (LET ((X 1.2) (Y 3.4)) (+ X Y)) took 0 milliseconds (0.000 seconds) to run. 8 bytes of memory allocated. 4.6 ? (time (let ((x (expt 2 32)) (y (expt 2 33))) (+ x y))) (LET ((X (EXPT 2 32)) (Y (EXPT 2 33))) (+ X Y)) took 0 milliseconds (0.000 seconds) to run. 16 bytes of memory allocated. 12884901888 ? (time (let ((x 1/2) (y 2/3)) (+ x y))) (LET ((X 1/2) (Y 2/3)) (+ X Y)) took 0 milliseconds (0.000 seconds) to run. 16 bytes of memory allocated. 7/6 ?

**Follow-Ups**:**Re: consing with +***From:*Michael Burks <mb1i+@andrew.cmu.edu>

- Prev by Date:
**consing with +** - Next by Date:
**Foreign Function call question** - Previous by thread:
**consing with +** - Next by thread:
**Re: consing with +** - Index(es):