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

Re: LOOP usage, versus "best-optimizeable-codings"



The value of iteration optimization, beyond the obvious things, must be 
low; for otherwise we'd never let MacLISP get away with turning DOs and LOOPs
into PROGs. (not to say that a modest amount of optimization isn't
already there -- witness the obscure GOFOO marker in COMPLR for saving
one cons cell per call to MAPCAR).  GLS's note is very telling about this:
    Date: 12 December 1980 0122-EST (Friday)
    From: Guy.Steele at CMU-10A
    (1) An optimizing compiler might have an easier time of dealing
    with a mapping construct, or with a LOOP construct, or even a DO (!)
    than a PROG.  However, COMPLR reduces all three to a PROG before
    doing its thing, so any differences in code size are attributable
    to odd differences in the constructions of the PROG.
At one time, the NIL special form MAPF was intended to express the
union of all the "maping" functions we know of, but we had no particular
plans to make its compilation much more efficient than MAPC or DO.
The note from Deustch to LISP-FORUM some time ago shows that the
higher-level abstraction of iteration concepts is "feature" whose 
time has come.  Also, as Barton points out:
    Date: 11 DEC 1980 1938-EST
    From: EB at MIT-AI (Edward Barton)
    Why should anyone believe that generated codesize is a measure of elegance
    and expressive power?
Beyond all other considerations, as is usually the case when one goes hunting
the elusive "compiler optimization snark", it is very easy to be misled down 
a fruitless path, as this note from GSB shows:
    Date: 11 DEC 1980 1856-EST
    From: GSB at MIT-ML (Glenn S. Burke)
    You failed to count the space taken by the breakoff function:
	    pname:  6 words;  symbol:  3 words; plist:  2 words 
	    and one cons cell to intern it. 
    That makes the space comparison 23. words, not 11. .  .  .
    In any case, a more appropriate comparison with the open-coded map is:
      (LOOP FOR X IN PRELUDE-FILES
	    NCONC (LIST X (GET X 'VERSION)))
    which happens to take 26. words.