[alexandria-devel] Implementation of DELETE-FROM-PLIST

Robert Smith quad at symbo1ics.com
Sat Feb 23 19:46:59 UTC 2013


Good style remarks, I suppose, which I can change.

On Sat, Feb 23, 2013 at 8:08 AM, Stas Boukarev <stassats at gmail.com> wrote:
> And I don't quite understand the purpose of
> (unless (eq first plist)
>         (setf (cddr plist)
>               first))

The point of that was for more DWIMness.

Without it, we have:

CL-USER> (let ((x (list :a 1 :b 2 :c 3 :d 4)))
           (print (delete-from-plist x :a :b :c))
           x)

(:D 4)
(:A 1 :B 2 :C 3 :D 4)

And with it, we have:

CL-USER> (let ((x (list :a 1 :b 2 :c 3 :d 4)))
           (print (delete-from-plist x :a :b :c))
           x)

(:D 4)
(:A 1 :D 4)

If your typical mode of operation is to (setf x (delete-from...)),
then of course either are fine. If your goal is to use
DELETE-FROM-PLIST for its side effects, then I think the latter is
more useful. In fact, for really simple and efficient imperative
maintenance of a plist, just prepend (nil nil), and use the function
purely for mutation.

Cheers,

Robert




More information about the alexandria-devel mailing list