From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)) Date: Sun, 25 Sep 2016 14:53:42 -0400 Message-ID: References: <871t07271d.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1474829709 14594 195.159.176.226 (25 Sep 2016 18:55:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Sep 2016 18:55:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 25 20:55:02 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boEZi-0002Dq-Fq for ged-emacs-devel@m.gmane.org; Sun, 25 Sep 2016 20:54:54 +0200 Original-Received: from localhost ([::1]:40035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boEZg-0002Ez-Ns for ged-emacs-devel@m.gmane.org; Sun, 25 Sep 2016 14:54:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boEYv-0001rh-2D for emacs-devel@gnu.org; Sun, 25 Sep 2016 14:54:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boEYq-0003S9-4H for emacs-devel@gnu.org; Sun, 25 Sep 2016 14:54:05 -0400 Original-Received: from [195.159.176.226] (port=43282 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boEYp-0003Qu-TU for emacs-devel@gnu.org; Sun, 25 Sep 2016 14:54:00 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1boEYd-0002og-Nb for emacs-devel@gnu.org; Sun, 25 Sep 2016 20:53:47 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 29 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:VPSXqsrUEBnDWWTGr/9AsFa4kmw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:207791 Archived-At: >> [...] then how I can decide how to quote this value [...]? > By looking at the value (or do I miss something)? > #+begin_src emacs-lisp > (let ((var 1)) > (let* ((fu #'(lambda (a) (+ a var))) > ba) > (message "%s" `,fu) > (setq ba (byte-compile `(lambda (b) (funcall ,(if (equal (car-safe fu) 'lambda) `#',fu `',fu) b)))) > (funcall ba 3))) > #+end_src FWIW, in this case, the byte-compiler's warning is incorrect: it tries to warn the programmer about the all-too common habit of using '(lambda ...) instead of #'(lambda ....) in the source code, but in the present example, the quoted (lambda ...) is actually indeed a function value we want to quote as-is rather than a function expression. So I think it's better to use with-no-warnings (which I generally don't like to use) than to do as above, which feels like a hack. Of course, taking a step back, if the whole code gets byte-compiled (as it should), then the problem doesn't even appear since #'(lambda (a) (+ a var)) will not evaluate to (lambda (a) (+ a var)) but to a bytecoded function (which needs to be quoted with `quote` rather than with `function`). Stefan