From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christopher Schmidt Newsgroups: gmane.emacs.devel Subject: Re: New assoc-let package Date: Sat, 6 Dec 2014 06:36:31 -0500 (EST) Message-ID: <87wq65rov9@ristopher.com> References: <87mw72q5z2.fsf@lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417869420 2216 80.91.229.3 (6 Dec 2014 12:37:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Dec 2014 12:37:00 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 06 13:36:49 2014 Return-path: Envelope-to: ged-emacs-devel@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 1XxEbP-0002QE-N2 for ged-emacs-devel@m.gmane.org; Sat, 06 Dec 2014 13:36:47 +0100 Original-Received: from localhost ([::1]:54231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxEbP-0000BI-B1 for ged-emacs-devel@m.gmane.org; Sat, 06 Dec 2014 07:36:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxDfl-0006qp-Vm for emacs-devel@gnu.org; Sat, 06 Dec 2014 06:37:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XxDff-0005y0-RQ for emacs-devel@gnu.org; Sat, 06 Dec 2014 06:37:13 -0500 Original-Received: from ristopher.com ([81.4.108.209]:47441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxDff-0005xL-Li for emacs-devel@gnu.org; Sat, 06 Dec 2014 06:37:07 -0500 Original-Received: by ristopher.com (Postfix, from userid 0) id C98A92048A; Sat, 6 Dec 2014 06:36:31 -0500 (EST) In-Reply-To: (Artur Malabarba's message of "Fri, 5 Dec 2014 20:28:29 +0000") Mail-Followup-To: emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 81.4.108.209 X-Mailman-Approved-At: Sat, 06 Dec 2014 07:36:30 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:179170 Archived-At: Artur Malabarba writes: > ;;;###autoload > (defmacro assoc-let (alist &rest body) > "Let-bind dotted symbols to their cdrs in ALIST and execute BODY. > Dotted symbol is any symbol starting with a `.'. Only those > present in BODY are let-bound and this search is done at compile > time. > > For instance, the following code > > (assoc-let alist > (if (and .title .body) > .body > .site)) > > expands to > > (let ((.title (cdr (assoc 'title alist))) > (.body (cdr (assoc 'body alist))) > (.site (cdr (assoc 'site alist)))) > (if (and .title .body) > .body > .site))" > (declare (indent 1) (debug t)) > `(let ,(mapcar (lambda (x) `(,(car x) (cdr (assoc ',(cdr x) ,alist)))) (alist-get ',(cdr x) ,alist) > (delete-dups (assoc-let--deep-dot-search body))) (macroexpand-all body) ? > ,@body)) I do not think adding assoc-let (assq-let?) to the core is a good idea. The inability to meaningfully nest different assoc-let forms makes the macro inflexible. It is probably a good idea to make the dotvars generalized variables.