[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More LOOP fan mail.
- Subject: Re: More LOOP fan mail.
- From: George J. Carrette <GJC at MIT-MC>
- Date: Thu ,11 Dec 80 19:07:00 EDT
A macsyma system programmer used loop in an includef
file:
(LOOP FOR X IN PRELUDE-FILES
COLLECT X
COLLECT (GET X 'VERSION))
However, we made him remove it to save us the slowdown of the
loading of loop.
He grudingly replaced it with this:
(DO ((X PRELUDE-FILES (CDR X))
(RESULT NIL))
((NULL X) (NREVERSE RESULT))
(PUSH (CAR X) RESULT)
(PUSH (GET (CAR X) 'VERSION) RESULT))
Ok, uglier than the loop, maybe. But there is a nice mapping way
to do it:
(MAPCAN #'(LAMBDA (X) `(,X ,(GET X 'VERSION))) PRELUDE-FILES)
Here are the results from compiling these three examples:
(in GJC;LOOPT >)
Example | code size (pdp10).
-------------------------------
LOOP 29.
DO 23.
MAP 11. including SUBR generated from the LAMBDA.
MAP 27. with MAPEX T to give open compilation.
The LOOP macro produces almost three times as much
machine code as the map in this example.
Observations?
Using LOOP avoided using back-quote.
GLS: Doesn't an optimizing compiler have a tougher time
with a PROG construct and GO-TO's than with a regularized
mapping construct?
Maybe we need a shorter name for lambda, so people won't
be afraid to type it?
How do the proposed NIL mapping extensions compare with
LOOP?
-gjc