[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MAKE-... and friends



    Date: 19 Mar 85 16:47:43 EDT (Tue)
    From: Jonathan Young <young at YALE.ARPA>

    When defining structure-types in T, I like to define a routine similar 
    to MAKE-FOO, usually called MAKE&FILL-FOO, which calls MAKE-FOO, fills 
    the appropriate slots with the appropriate arguments, and initializes
    any other slots. 

Yes, this is a definite deficiency (or bug, or inconsistency) in the
DEFINE-STRUCTURE-TYPE macro (not in the structure package itself, of
course, which dosen't deal with names at all).  The next version of the
structure type definition macro ought to fix this, but unfortunately no
one is writing it.

    While we're on the subject of consistency, is it
            (WALK-type proc type) 
    or      (WALK-type type proc)  

    See WALK, WALK-POPULATION, and WALK-VECTOR.

The conflict is between thinking of WALK-xxx as something which takes a
procedure, and applies it to a bunch of things (or n-tuples of things\n from the cross product of several bunches), or as something which takes
a bunch of things and applies some procedure to all of the things in the
bunch.  In the original design "bunch" could only mean list, and the
order was irrelevant; since there could be many lists it made sense to
put the procedure (of which there was only one) first, in analogy to
WALK.  However, given that you want a WALK for each kind of bunch, you
really want the bunch to go first, just like all the other operations
which work specifically on that kind of bunch, since the rule there
(violated by MEMQ and friends, but generally adhered to) is that "the
aggregate, or most interesting, arguement goes first."  This rule is
especially important if the implementation uses generic operations,
because then the first argument is distinguished.

E.g.:	(SUBLIST list m n)
	(LIST-ELT list n)
	(WALK-LIST list proc)  -- ??

	(ADD-TO-POPULATION population object)
	(WALK-POPULATION population proc)  -- ??

So you are the victim of design rules which contradict each other.  I
think the right answer ought to be that the aggregate should go first,
except maybe in the case of MAP and WALK (and then I don't know).
Somewhere along the line WALK-POPULATION got changed to adhere to this,
and I think the implementation and documentation disagreed for a while
(they may still).

Jonathan