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

Things to consider for CLtL'97

    Date: Mon, 3 Mar 86 10:43 EST
    From: Guy Steele <gls@THINK-AQUINAS.ARPA>

	Date: Fri, 28 Feb 86 17:06 EST
	From: David C. Plummer <DCP@SCRC-QUABBIN.ARPA>

	    Date: Fri, 28 Feb 86 15:04 EST
	    From: Guy Steele <gls@THINK-AQUINAS.ARPA>

		Date: Tue, 25 Feb 86 11:15 EST
		From: David C. Plummer <DCP@SCRC-QUABBIN.ARPA>

		reduce should have a :KEY keyword argument.  For example, suppose you
		have a sequence of sequences, and you want to know the sum of the
		lengths of the inner sequences.  Currently, I think you have to do
			(reduce #'(lambda (so-far subsequence)
				    (+ so-far (length sub-sequence)))
		but I would prefer to do
			(reduce #'+ sequence :key #'length)

	    (REDUCE #'+ (MAP (TYPE-OF sequence) #'length sequence))

	Yours conses.  Mine doesn't.

    Argh.  If you're worried about conses, use LOOP.  Seems like everyone
    else does.  (This week I am of the opinion that all those :START and
    :END keywords were a mistake.)
If I were worried about speed, I would use LOOP.  Since I wasn't, I
wanted to be pretty and still have some small spattering of efficiency.
(This month I'm trying not to use LOOP when other CL constructs are

	    Did you mean:

		modify-seq item sequence modifier &key start end from-end test test-not
		modify-seq-if predicate sequence modifier &key start end from-end
		modify-seq-if-not predicate item sequence modifier &key start end from-end

	I see, I think.  Yes, I want the -IF and -IF-NOT forms as well.

	    And should they all also take a :KEY argument?
	I don't think so.  Consider what :KEY does.  It extracts a part of the
	datastructure.  To put it back, the implementation would have to do
	something like
		(setf (funcall key sequence-element)
		      (funcall modifier
			       (funcall key sequence-element)))
	and SETF of FUNCALL isn't generally invertable.

    Sorry; I meant the :KEY part to be used only in conjunction with the
    test, not the modify part of the operation.  See how tricky it is to
    specify these things?

Glorp!  I see, you meant
	(when (funcall predicate (funcall key seqeunce-element))
	  (setf <sequence-element> (funcall modifier sequence-element)))
Yeah, I guess that would be reasonable.

    Seems to me JONL once proposed an omnibus sequence function with a name
    such as MEMASSDELREMCONCQ-IF that simply took enough options to be able
    to do anything you desired with a sequence.