[Top][All Lists]

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

Re: Replacement for `aput' from obsolete assoc.el?

From: Stefan Monnier
Subject: Re: Replacement for `aput' from obsolete assoc.el?
Date: Tue, 05 Jun 2012 13:43:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

>> But I wonder if there is a simple replacement for `aput' in vanilla
>> Emacs?  I don't think so, but maybe I have overseen something.

Usually, for alists, you can do:

 (push (cons key val) alist)

If you want to do it via side-effects, then it largely depends on what
kind of "alist" this is.  If you know the key is already in there, you
can do

  (setcdr (assoc key alist) val)
>> instead of `eq')?  Dunno why this function does not exist yet, but it
>> would ease handling alists e.g. if its keys are strings.

Using side-effects on alists is often a bad idea.

> Starting with GNU Emacs 24.2 you are allowed to use the cl functions in
> end-user code.

Now that's a confusing statement:
- CL functions have always been allowed in end-user code (and third
  party packages for that matter).  Being the "canonical" Free Software,
  Emacs is usually not in the business of disallowing its users to do
  whatever they want.
- Code bundled with Emacs-24.2 is still not "allowed" to use the CL
  function you showed (i.e. `delete*').  It can require the new `cl-lib'
  and use `cl-delete' instead, tho.


reply via email to

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