[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GLS replacements for LOOP
I really liked the examples Guy presented - I've long had the feeling
that some of the sequence functions could be really really useful if
only I knew how to use them! And although I've translated PSL's FOR
macro into portable CL, it only seems to get used for compatibility with
old PSL code. So I've sort of drifted from camp 3 to camp 1.
There are a couple problems with using tricky sequence functions etc
instead of generalized loop constructs. Loop macros are frequently
easier to modify - I can just stick in another clause. The before
and after equivalent sequence function calls may be quite dissimilar.
There are more serious questions of efficiency. Loops macros tend
to expand into Fortran-like code. A large proportion of the loops
in PSL's runtime system are written using a version of FOR that totally
opencodes; I believe the same is true of Zetalisp. On the other hand,
this is a little harder to do with the sequence functions. Guy's example of
a multiple-iterator loop turning into (list (mapcar ...) (mapcar ...) ...),
could be fully opencoded, but that would take a pretty aggressive compiler
that had just seen (proclaim '(optimize (speed 3) (safety 0))).
Is anybody's compiler "sufficiently good" to turn sequence function
usages into code as efficient as LOOP produces?
stan