From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#33199: lambda forms are not self-quoting Date: Tue, 30 Oct 2018 19:07:16 -0400 Message-ID: <87sh0nhw4b.fsf@gmail.com> References: <87zhuwic9a.fsf@gmail.com> <83in1jlxyu.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1540940771 17310 195.159.176.226 (30 Oct 2018 23:06:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 23:06:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 33199@debbugs.gnu.org, garreau@debbugs.gnu.org, galex-713@galex-713.eu To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 31 00:06:07 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1gHd5J-0004KV-IR for geb-bug-gnu-emacs@m.gmane.org; Wed, 31 Oct 2018 00:06:05 +0100 Original-Received: from localhost ([::1]:55982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHd7P-00045y-L2 for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2018 19:08:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHd7F-00043z-Jf for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2018 19:08:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHd7C-0003Ir-6i for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2018 19:08:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51752) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHd7B-0003IX-Tf for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2018 19:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gHd7B-0004td-Iw for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2018 19:08:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Oct 2018 23:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33199 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 33199-submit@debbugs.gnu.org id=B33199.154094084618774 (code B ref 33199); Tue, 30 Oct 2018 23:08:01 +0000 Original-Received: (at 33199) by debbugs.gnu.org; 30 Oct 2018 23:07:26 +0000 Original-Received: from localhost ([127.0.0.1]:56010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHd6b-0004sk-Q7 for submit@debbugs.gnu.org; Tue, 30 Oct 2018 19:07:26 -0400 Original-Received: from mail-it1-f175.google.com ([209.85.166.175]:52104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHd6a-0004sV-02 for 33199@debbugs.gnu.org; Tue, 30 Oct 2018 19:07:24 -0400 Original-Received: by mail-it1-f175.google.com with SMTP id h13so2967362itl.1; Tue, 30 Oct 2018 16:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=tYzSKq7bUofSTwW/ToET6iFmV7L7aDHfGjBgyXfNeL0=; b=HSw+lLG3rYGAJtRrm90FmB/nhgQIPJjPplJfI8TMFheh+bQObj05T/K7IUv9af1bHH YQEQwYO9aeH1AFMVsxo2ouLRHqygWaL0k/vqql3+7hoYs4Hhqq6bm8ZNYCSWb0C0Karj b6ybKnqo2wCd4sWZRQaPyCnsXuCDm25weam3rzHRsApSF06l2DNB6sRIl/ZIA1sd2/jt IBp9fPISqOUhmUoyTreLc6WycO8Om7dUjSGbTPr70PmvzY63BC9GlJGDj9ze9h0VvfX7 gfAITZH9mBnAdCwTkux7TeD3YXBuiqdY1JjWoEJqVcuPqOaI/7lFccGreIBa0pbDbO32 EoUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=tYzSKq7bUofSTwW/ToET6iFmV7L7aDHfGjBgyXfNeL0=; b=rtMPWKYIfFF7+/FS0WRysCeGtbTDDwtTSVLDR4PBLu3YqV/1ECz9cS2mJS6er2ST0T QX5HWY7K1PPBzxBqPySi946WfHsO342lU4EwhK+n+0x2UV92X/9SSOZc7oSGfDIOdav0 YlODi1TbgtqwzDiEprAk4/3PFXcKifUw4Pdi47vNOtwOx3kr0neUo/XiAPYTMXYtn079 z/4HKy17tYMfKSdVwdRbOIFRHqaDwejAAjM+2AmNRcVuwDFiIm32GxLuDpeYJS6HsRn6 4xC79uIuvSwWKbJC+wk5hUOWwJdl9QC5U2T0lJfzWKErjtz21DO+r+vYihhhmrA9jFIF Pc2Q== X-Gm-Message-State: AGRZ1gJKpixkBwMIq+OzHIXa+EUuUQwOlb1+GpVPBelV8mK+8GmOq69g x2MiXs5E7tvbxEqmhxhp4ZoYVolA X-Google-Smtp-Source: AJdET5dR8V9EwwLHUwUv5a3GVMQ1eOCRNWQT6sY6Q9+ebdqBmKrzkY623whXrU3aK7g5lfwk6bnWpw== X-Received: by 2002:a02:9c37:: with SMTP id q52-v6mr603591jak.0.1540940838368; Tue, 30 Oct 2018 16:07:18 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id y190-v6sm8012793itg.3.2018.10.30.16.07.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 16:07:17 -0700 (PDT) In-Reply-To: <83in1jlxyu.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 30 Oct 2018 09:01:29 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151850 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > This removes useful information, IMO. What's it really useful for though? IMO, all anyone needs to know is that (lambda ...) evaluates to a function. > I'd be much happier if we added to the existing docs that lambda is > not self-quoting in the lexical-binding environment, and described > (and explained) what does happen in the lexical-binding environment. It seems to me like too much useless detail, but if you insist. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v2-0001-Note-that-lambda-forms-are-not-self-quoting-under.patch Content-Description: patch >From bd397a3cec219a453e3118cb59e5955f5a09b870 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 29 Oct 2018 19:01:07 -0400 Subject: [PATCH v2] Note that lambda forms are not self-quoting under lex binding * doc/lispref/functions.texi (Anonymous Functions): * lisp/subr.el (lambda): Note that under lexical binding it yields a closure object (Bug#33199). --- doc/lispref/functions.texi | 9 ++++++--- lisp/subr.el | 13 +++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 9b8057080e..7f8a6fc40b 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -1082,15 +1082,18 @@ Anonymous Functions @var{args}, documentation string @var{doc} (if any), interactive spec @var{interactive} (if any), and body forms given by @var{body}. -In effect, this macro makes @code{lambda} forms self-quoting: -evaluating a form whose @sc{car} is @code{lambda} yields the form -itself: +Under dynamic binding, this macro effectively makes @code{lambda} +forms self-quoting: evaluating a form whose @sc{car} is @code{lambda} +yields the form itself: @example (lambda (x) (* x x)) @result{} (lambda (x) (* x x)) @end example +Note that when evaluting under lexical binding the result is a closure +object (@pxref{Closures}). + The @code{lambda} form has one other effect: it tells the Emacs evaluator and byte-compiler that its argument is a function, by using @code{function} as a subroutine (see below). diff --git a/lisp/subr.el b/lisp/subr.el index 59f6949b21..d09789340f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -93,12 +93,13 @@ def-edebug-spec `(put (quote ,symbol) 'edebug-form-spec (quote ,spec))) (defmacro lambda (&rest cdr) - "Return a lambda expression. -A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is -self-quoting; the result of evaluating the lambda expression is the -expression itself. The lambda expression may then be treated as a -function, i.e., stored as the function value of a symbol, passed to -`funcall' or `mapcar', etc. + "Return an anonymous function. +Under dynamic binding, a call of the form (lambda ARGS DOCSTRING +INTERACTIVE BODY) is self-quoting; the result of evaluating the +lambda expression is the expression itself. Under lexical +binding, the result is a closure. Regardless, the result is a +function, i.e., it may be stored as the function value of a +symbol, passed to `funcall' or `mapcar', etc. ARGS should take the same form as an argument list for a `defun'. DOCSTRING is an optional documentation string. -- 2.11.0 --=-=-=--