Pereira@SRI-AI@sri-unix.UUCP (10/12/83)
Warren's setof/bagof, implemented on DEC-10/20 Prolog and C-Prolog, has some very interesting properties, not shared by the competition: 1. Variables not bound explicitly by some special operator (setof, ^,...) are universally quantified at the outermost level. This is a simple and uniform convention. To see what it buys you 2. setof((X,S),setof(Y,p(X,Y),S),SS) binds SS to the list representation of {(x,s): s = {y: p(x,y)}} the set of pairs (x,s) such that s is the set of y's such that p(x,y). This is the only reasonable interpretation of nested set expressions, and cannot be done with findall. I use things like this all the time (what are set expressions for, if not to do what sets do...). Recently, I've been helping someone to move one of my programs to a Prolog lacking setof/bafof, and what a pain it has been ! 3. calls to findall are trivial to simulate with bagof, but implementing bagof in terms of findall is rather tricky (that's what David's implementation is all about). What Richard's complaint was about was the abuse of the name "bagof" to mean something different from what it had been used to mean in the literature, and for which there was already a perfectly good name, "findall". Of course, the Humpty Dumpty school of semantics thinks nothing of such abuses... -- Fernando Pereira