[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LOOP and Reply to Boyer
Having used Interlisp's I.S.OPRS at length now, I want to re-confirm my
original support for the so-calld LOOP macro. By the way, I thought one
of the versions did have a user-extensible syntax; has that been taken
out?
Regarding Bob's simplified example -- the fact that it could be written
with other CL constructs shouldn't be allow to occlude the very powerful
mechanism in user-extensibility, nor in the somewhat broader scope of
LOOP (as opposed to reduction operators).
E.g., I once wrote an I.S.OPRS form called "inpname", which could be
very efficient on strings (works on all things -- just super-efficient
on strings):
(for C inpname <mumble> do <look-for-something>
finally <break-if-get-here>)
A big "win" was to encapsulate in only one place the schema for how to
iterate over pnames -- I don't have to do it in a lot of little places
simply because there is some exception to the control structure of the
client code (in this case, the exception is what to do if you actually
reach the end!). In the normal case, a function call on each character
would drastically impair performance.
Also the symmetric ability to mix iteration schema simplifies things;
consider the following Interlisp form:
(during 300 timerUnits 'SECONDS
find MATRIX in L ;"find" is like "for", but the
as I from 0 by 2 ; return value is implicitly MATRIX
while (SunSetsInTheWest)
suchthat (AREF MATRIX K I))
This loop has 4 different termination criteria, most of which would have
to be programmed separately in a functional-style program, and which
possibly would have to be programmed slightly differently depending on
context; but the I.S.OPRS mechanism, whether user-extensible or not,
gives a feel not unlike a rule-based system -- you specify details and
order-of-execution only when it matters. The macro (or DWIM in
Interlisp) figures out how to put the schema together.
-- JonL --