unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: plist-put: destructive?
Date: Mon, 23 Jan 2017 10:01:47 +0100	[thread overview]
Message-ID: <20170123090147.GA19549@tuxteam.de> (raw)
In-Reply-To: <jwvd1ffuhrw.fsf-monnier+gmane.emacs.help@gnu.org>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Jan 22, 2017 at 12:30:49PM -0500, Stefan Monnier wrote:
> > The code I'm working has many repeated clauses looking like:
> >
> > (when thing1
> >   (setq the-plist (plist-put the-plist :thing thing1)))
> 
> FWIW, I've found that such code can often advantageously be turned
> into a non-side-effecting form like:
> 
>    (let ((the-plist
>           (nconc
>            (when thing1 (list :key1 thing1))
>            (when thing2 (list :key2 thing2))
>            ...)))

Thanks for this one! I positively know I've been struggling for
something like that, only to come up with a far clumsier variant.

- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAliFxnsACgkQBcgs9XrR2kY82wCfboH2ToyZGcsOaoFCB1zuqxQ/
5hoAn3gM7xvUAvQfZSr7CH9+wCeDxRDn
=hZBt
-----END PGP SIGNATURE-----



  parent reply	other threads:[~2017-01-23  9:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 19:13 plist-put: destructive? Eric Abrahamsen
2017-01-21  3:25 ` Stefan Monnier
2017-01-21 10:25   ` tomas
2017-01-21 16:41   ` Eric Abrahamsen
2017-01-21 17:13     ` Drew Adams
2017-01-22  0:50       ` Eric Abrahamsen
2017-01-22 10:08         ` Philipp Stephani
2017-01-22 13:10           ` Eric Abrahamsen
2017-01-22 17:30         ` Stefan Monnier
2017-01-23  0:31           ` Eric Abrahamsen
2017-01-23  9:01           ` tomas [this message]
2017-01-21 23:03     ` Stefan Monnier
2017-01-22  1:15       ` Eric Abrahamsen
2017-01-21  8:13 ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170123090147.GA19549@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).