Re: novice: mapcan use?



Peter Seibel wrote:
Well it's possible that using a destructive (or, as I prefer,
"recycling") function will slow things down--by recycling old conses
you may move them out of the youngest generation in a generational
garbage collector where they could have been collected much more
efficiently than they will now. Or so I understand but IANAGCI.

I would think so too. BTW is there a good comparison of the different Lisp to what GC technique they use (just curious)? IIRC I remember hearing that CLisp has generational GC and SBCL is working on one.


At any rate, one interesting (to me anyway) stat I came across while
working on my book was the use of recycling functions in CLOCC: I
examined all the uses of recycling functions in CLOCC and found that
the PUSH, PUSH, NREVERSE idiom accounted for nearly half of all uses

I'd call PUSH more imperative than recycling. It changes the variable binding, but not anything on the heap.


That is the Big-O complexity of PUSH, PUSH, NREVERSE would be the same
if you used REVERSE instead of NREVERSE.

Sure, but you create a new spine for the list (which may not be bad at all if cons is fast and garbage cheap).


--
My ideal for the future is to develop a filesystem remote interface
(a la Plan 9) and then have it implemented across the Internet as
the standard rather than HTML.  That would be ultimate cool.
	Ken Thompson
.