emacs-devel
[Top][All Lists]
Advanced

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

Contributing (setf (assoc ...))


From: Daniel Pittman
Subject: Contributing (setf (assoc ...))
Date: Sat, 09 May 2009 23:55:46 +1000
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.60 (gnu/linux)

G'day.

I recently wanted to update as associative list, but apparently Emacs
doesn't presently have an implementation of (setf (assoc ...)), at least
in the snapshot I use.

I believe I have paperwork on file already with the FSF for Emacs, even
assuming that this is large enough to require such paperwork:

(defsetf assoc (key place) (value)
  (let ((s1 (gensym)))
    `(let ((,s1 (assoc ,key ,place)))
       (if ,s1 (setf (second ,s1) ,value)
         (push (list ,key ,value) ,place)))))

That implementation should work fine in all circumstances, I believe,
and passes my local testing.

Um, generally speaking there doesn't seem to be anything like a test
suite for Emacs Lisp code that I could locate.  Did I miss something, or
is it generally the practice to just get it right? ;)

Regards,
        Daniel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]