From: Barry Margolin
Subject: Re: Mapping over a tree of CONSes
Date: 
Message-ID: <2kdh2aINNep5@early-bird.think.com>
In article <·················@polaris.flw.att.com> ···@polaris.flw.att.com (Lawrence G. Mayka) writes:
>I found two anomalies, though:
>
>- CL implementations disagree on the order of arguments to the :TEST
>function for SUBLIS and NSUBLIS.  I dealt with this via #+ in those
>two cases.  CLtL2 (p. 391) and the dpANS (Sec. 17.2.1) seem to
>indicate that (ITEM NODE) is the correct ordering, but it would lose
>in a majority vote of the five implementations I tried.

Looks like there is some confusion on what "satisfies the test" refers to.
One interpretation (yours and two implementations') is that the alist is
the sequence, and each node is being tested against the alist; the other is
that each key of the alist is being tested against the tree nodes.

However, the examples in the dpANS make it clear that the :KEY is only
applied to the tree nodes.  Since the result of :KEY is always the second
argument to a two-argument :TEST (except when traversing two sequences, in
which case :KEY is applied to elements of both), I agree with you that it
should be (ITEM NODE).  While the examples are not officially part of the
specification, I believe they can be used to resolve ambiguities like this.

>- CL implementations vary greatly as to which tree-nodes they visit
>once, and which they visit twice.
...
>I was very surprised, because CLtL2 and the dpANS seem to indicate
>that every tree-node should be visited exactly once.  Note that the
>restrictions on side-effects during structure traversal (p. 179 in
>CLtL2, Sec. 3.6 in the dpANS) apply only to modifications of the
>structure itself, not other side-effects such as writing to a stream.

Where does the dpANS say that these functions only visit each node once?
Section 3.6 allows other side effects during structure traversal, but it
never says what order they'll occur in or whether they'll be repeated.
In some cases the description specifically mentions this flexibility (see
SEARCH), but I don't think the lack of such mention implies any particular
behavior; there's no place that says, "Unless otherwise specified, these
functions only call the test function once on each node."
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar