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

Robert Smith quad at symbo1ics.com
Sat Feb 23 21:55:18 UTC 2013


How is (:A 1 :D 4) wrong? There is no way to get it to just (:D 4) via
mutation when passing to a function. If we want to have just (:D 4),
we will need to either pass in

(nil nil <plist>)

which will give

(nil nil :D 4)

or we will need to encapsulate or box the value before going in, by
using something like https://bitbucket.org/tarballs_are_good/cl-ref .

All in all, it still returns (:D 4), but it just modifies as much of
the list structure as it can.

-Robert

On Sat, Feb 23, 2013 at 11:53 AM, Stas Boukarev <stassats at gmail.com> wrote:
> Robert Smith <quad at symbo1ics.com> writes:
>
>> 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.
> I don't see how (:A 1 :D 4) is useful, it's less wrong, but it's still
> wrong.
>
> --
> With best regards, Stas.




More information about the alexandria-devel mailing list