parallel stepping in loop, but what about termination tests?
| Newsgroups | gmane.lisp.clisp.devel |
|---|---|
| Message-ID | <b5d083308d6a4ab1a9ecdbdaf157b6e3@HE105658.emea1.cds.t-internal.com> |
Hi, The following two loops produce identical results and side-effects. Surprise? (loop for x across "abc" and for z on (list 1) do (princ x) finally (return (cons x z))) (loop for x across "abc" for z on (list 1) do (princ x) finally (return (cons x z))) a -> (#\b) One *might* have expected "AND", implying parallel stepping, to assign either all values, or nothing when iteration terminates. However, in the above case, x clearly has the value #\b from a second round, but there's only one iteration -- one would think. This contributes to the topic of non-obvious values of variables within FINALLY clauses. So the question IMHO is: when, if ever, shall termination tests be combined, such that all tests (from FOR clauses) are performed prior to assigning new values? Testing varying inputs with clisp's LOOP macro, I've seen tests sometimes combined, others not. The picture is not yet clear to me. Combined test & stepping might look like this: (when (OR (<= (length vector) index) (atom z)) (LOOP-FINISH)) (PSETQ x (AREF vector index) z (cdr z)) ... (INCF index) [From an implementation POV, combined tests might require more internal variables (cf. e.g. internals of FOR HASH), thus be slower.] Regards, Jörg ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ clisp-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-devel