From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Two questions about generalized variables Date: Sun, 21 Feb 2016 13:16:43 +0800 Message-ID: <87ziuu4p8k.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1456031838 26070 80.91.229.3 (21 Feb 2016 05:17:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Feb 2016 05:17:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 21 06:17:10 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aXMOM-0007C0-1K for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Feb 2016 06:17:10 +0100 Original-Received: from localhost ([::1]:38159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXMOL-0003vp-8C for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Feb 2016 00:17:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXMOB-0003vX-83 for help-gnu-emacs@gnu.org; Sun, 21 Feb 2016 00:17:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXMO6-0008Ew-8u for help-gnu-emacs@gnu.org; Sun, 21 Feb 2016 00:16:59 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:56346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXMO6-0008Ej-2X for help-gnu-emacs@gnu.org; Sun, 21 Feb 2016 00:16:54 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aXMO2-0006vd-TJ for help-gnu-emacs@gnu.org; Sun, 21 Feb 2016 06:16:51 +0100 Original-Received: from 116.1.108.205 ([116.1.108.205]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Feb 2016 06:16:50 +0100 Original-Received: from eric by 116.1.108.205 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Feb 2016 06:16:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 116.1.108.205 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:uLIn6tm/J6IVzaUIAwD4U7ljuXU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:109239 Archived-At: I'm starting to learn a bit more about generalized variables, the gv-* stuff and macroexpand-*, what have you, and I have two practical/learning questions I hope someone can help me with. The first is working with plists. It can be a pain setting many plist entries at once, particularly when there's lots of surrounding conditional code. You either have to keep doing "(setq plist-var (plist-put plist-var ..." Or else use a backquote template, but that's not always practical. It looks like plist-get doesn't return a setf-able place. I was thinking of making a "with-plist-slots" macro, and looking at the `with-slots' macro as inspiration, but `with-slots' also requires setf-able places. Is there a way to define something to make that work? The second question is setting hashtable entries. Right now I have code like this: (setf (gethash uuid my-hashtable) (append (list (list 'thingone 'thingtwo)) (gethash uuid my-hashtable))) I assume this is no more or less efficient than let-ting the gethash, manipulating the value, then using puthash to put it back in. Now I've written this: (macroexp-let2 nil entry (gethash uuid my-hashtable) (setf entry (append (list (list 'thingone 'thingtwo)) entry))) This is a simplistic example, but -- is this actually going to be any faster or more efficient than the first version? Does it only access the hashtable once? Have I just been blinded by the shiny? Any insights very welcome! Thanks, Eric