complier optimization for DO returning REVERSE, WAS: Re: newbie exploring better ways
- From: K Livingston <kevinlivingston.public@xxxxxxxxx>
- Date: Tue, 29 Jan 2008 23:52:23 -0800 (PST)
On Jan 30, 1:39 am, K Livingston <kevinlivingston.pub...@xxxxxxxxx>
wrote:
a DO with a REVERSE at the end has no side effects,
but the disadvantage of the extra traversal for the REVERSE
just out of curiosity (and possibly in bad form for replying to my own
comment), it seems that a reasonably common form is
(do ((results nil (cons <something> results))
...)
(( ... ) (reverse results)))
it strikes me that a clever compiler could unroll that, and not
require the second traversal and just build up results in reverse, as
it would while performing a MAPCAR or the like. While it could do
this, do any compilers actually do that?
I understand of course, that LOOP could frequently be used to avoid
the second iteration, but since the results are effectively
isomorphic, it be nice if the compiler would "do what I mean" and
build the more efficient version whenever possible, allowing the
programmer to always write what's easiest to code/maintain/understand
for the situation.
.
- Follow-Ups:
- References:
- newbie exploring better ways
- From: vijay
- Re: newbie exploring better ways
- From: Griff
- Re: newbie exploring better ways
- From: Kent M Pitman
- Re: newbie exploring better ways
- From: K Livingston
- newbie exploring better ways
- Prev by Date: Re: newbie exploring better ways
- Next by Date: Re: Paul Graham's Arc is released today... what is the long term impact?
- Previous by thread: Re: newbie exploring better ways
- Next by thread: Re: complier optimization for DO returning REVERSE, WAS: Re: newbie exploring better ways
- Index(es):
Relevant Pages
|
|