From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el Date: Wed, 20 May 2015 08:58:52 -0400 Message-ID: References: <87egmdncf7.fsf@gmail.com> <87oalh6blm.fsf@gmail.com> <874mn956rr.fsf@gmail.com> <87oalftz4v.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1432126749 21450 80.91.229.3 (20 May 2015 12:59:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 May 2015 12:59:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: Oleh Krehel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 20 14:59:00 2015 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 1Yv3aO-0001hq-0f for ged-emacs-devel@m.gmane.org; Wed, 20 May 2015 14:59:00 +0200 Original-Received: from localhost ([::1]:51784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv3aN-0006Tr-DK for ged-emacs-devel@m.gmane.org; Wed, 20 May 2015 08:58:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv3aJ-0006Tl-Vr for emacs-devel@gnu.org; Wed, 20 May 2015 08:58:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yv3aH-0006NH-03 for emacs-devel@gnu.org; Wed, 20 May 2015 08:58:55 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:55800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv3aG-0006ND-TQ for emacs-devel@gnu.org; Wed, 20 May 2015 08:58:52 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUFAGvvdVTO+LMW/2dsb2JhbAA3gVOhb4EIgXUBAQQBViMFCwsOJhIUGA0kiBOiEYwDGEkMA4M+Aw6DYgSjY4RY X-IPAS-Result: AgUFAGvvdVTO+LMW/2dsb2JhbAA3gVOhb4EIgXUBAQQBViMFCwsOJhIUGA0kiBOiEYwDGEkMA4M+Aw6DYgSjY4RY X-IronPort-AV: E=Sophos;i="5.11,557,1422939600"; d="scan'208";a="121174442" Original-Received: from 206-248-179-22.dsl.teksavvy.com (HELO pastel.home) ([206.248.179.22]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 May 2015 08:58:52 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 2FAE024E0; Wed, 20 May 2015 08:58:52 -0400 (EDT) In-Reply-To: <87oalftz4v.fsf@gmail.com> (Oleh Krehel's message of "Wed, 20 May 2015 10:46:24 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:186653 Archived-At: > (defmacro let-when-compile (bindings &rest body) > "Like `let', but allows for compile time optimization. > \n(fn BINDINGS BODY)" > (declare (indent 1) (debug let)) > (cl-progv (mapcar #'car bindings) > (mapcar (lambda (x) (eval (cadr x))) bindings) > (macroexpand-all > `(progn > ,@body) > macroexpand-all-environment))) You can use `macroexp-progn' to avid adding `progn' when it's not needed, but other than that, it looks good. > So I guess it's fine. The byte compiler will issue a warning about an > unbound variable if `eval-when-compile' is omitted by mistake. I was > thinking maybe something clever could be done, like automatically > leaving a let binding to prevent an error. Leaving a let-binding behind would kind of defeat the purpose and would lead to lots of byte-compiler warnings about unused variables. > Should I install the patch? Go ahead, yes, but please move let-when-compile to a generic file rather than lisp-mode.el. I guess subr.el would make sense. Stefan