From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67734: 30.0.50; Don't mention `set` in the ELisp intro Date: Sat, 09 Dec 2023 18:17:50 -0500 Message-ID: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40401"; mail-complaints-to="usenet@ciao.gmane.io" To: 67734@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 10 00:19:09 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rC6bF-000AI6-5K for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Dec 2023 00:19:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rC6ax-0006vr-G0; Sat, 09 Dec 2023 18:18:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rC6av-0006v9-E6 for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 18:18:49 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rC6av-0003sh-6L for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 18:18:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rC6b8-00026r-JK for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 18:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Dec 2023 23:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67734 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17021639098061 (code B ref -1); Sat, 09 Dec 2023 23:19:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Dec 2023 23:18:29 +0000 Original-Received: from localhost ([127.0.0.1]:49172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rC6ab-00025x-5s for submit@debbugs.gnu.org; Sat, 09 Dec 2023 18:18:29 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:54136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rC6aZ-00025f-3a for submit@debbugs.gnu.org; Sat, 09 Dec 2023 18:18:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rC6aC-0006qK-PU for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 18:18:05 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rC6a7-0003oj-EX for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 18:18:02 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0827510019F for ; Sat, 9 Dec 2023 18:17:58 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1702163876; bh=STV374Gx1ygxsrBv9388gSz/eiONUcw+1uesryOBElw=; h=From:To:Subject:Date:From; b=LMRE9M3nR2ygxegc2hXO+vg7JQBOw5U4FjGhe1fq5dZ1OZIY+xTFDV2k62z0RCfWX CJ/+NDuIARnfQBpO+2YP7Cn2fBuFC0wUIIa7BkHafmS/CT03o1HJBVnVj3A4IZDQl9 n0cub2l2RuAGeoK+yYMLVt6s6aNvCI+d+XXUbhKPS4zQECYYWTWWb2zXZK/DnZaczl OZUxgSrb7eqxTuIoX35AsOzcWfZAsxfPz2ZNO2pECTa6Ny4ljzFlkmj4L7jxDzKxeP x27JPfdLIEG/p2J/7xWV2EiwE2BK6JRcEPDieN4s2Ib9qSqx59aCmbzZMHH1Ii5Ic4 5WGrXg37ISgeg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D7B6C100189 for ; Sat, 9 Dec 2023 18:17:56 -0500 (EST) Original-Received: from pastel (unknown [45.72.207.126]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B993512031E for ; Sat, 9 Dec 2023 18:17:56 -0500 (EST) Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275887 Archived-At: --=-=-= Content-Type: text/plain Package: Emacs Version: 30.0.50 The ELisp intro needs to be updated to the world of static scoping. I haven't really looked at doing that, but the patch below can be considered as a step in that direction. In any case, I think it's a good change on its own. It removes all mentions of the `set` function. `set` cannot be used on statically scoped variables and I can't see what it brings to the reader of the ELisp intro (except maybe for explaining the "q" in `setq`) to first tell them about `set` only to turn around and tell them they'll never use it. Suggestions for improvements welcome, Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=elisp-intro.patch diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index eb8ff413b79..4246742a17e 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi @@ -2280,34 +2280,33 @@ set & setq @cindex @samp{bind} defined There are several ways by which a variable can be given a value. One of -the ways is to use either the function @code{set} or the special form +the ways is to use the special form @code{setq}. Another way is to use @code{let} (@pxref{let}). (The jargon for this process is to @dfn{bind} a variable to a value.) -The following sections not only describe how @code{set} and @code{setq} -work but also illustrate how arguments are passed. +The following sections not only describe how @code{setq} +works but also illustrate how arguments are passed. @menu -* Using set:: Setting values. -* Using setq:: Setting a quoted value. +* Using setq:: Setting variables. * Counting:: Using @code{setq} to count. @end menu -@node Using set -@subsection Using @code{set} +@node Using setq +@subsection Using @code{setq} @findex set -To set the value of the symbol @code{flowers} to the list @code{'(rose +To set the value of the symbol @code{flowers} to the list @code{(rose violet daisy buttercup)}, evaluate the following expression by positioning the cursor after the expression and typing @kbd{C-x C-e}. @smallexample -(set 'flowers '(rose violet daisy buttercup)) +(setq flowers '(rose violet daisy buttercup)) @end smallexample @noindent The list @code{(rose violet daisy buttercup)} will appear in the echo -area. This is what is @emph{returned} by the @code{set} function. As a +area. This is what is @emph{returned} by the @code{setq} special form. As a side effect, the symbol @code{flowers} is bound to the list; that is, the symbol @code{flowers}, which can be viewed as a variable, is given the list as its value. (This process, by the way, illustrates how a @@ -2316,7 +2315,7 @@ Using set Lisp function must return a value if it does not get an error, but it will only have a side effect if it is designed to have one.) -After evaluating the @code{set} expression, you can evaluate the symbol +After evaluating the @code{setq} expression, you can evaluate the symbol @code{flowers} and it will return the value you just set. Here is the symbol. Place your cursor after it and type @kbd{C-x C-e}. @@ -2336,29 +2335,7 @@ Using set 'flowers @end smallexample -Note also, that when you use @code{set}, you need to quote both -arguments to @code{set}, unless you want them evaluated. Since we do -not want either argument evaluated, neither the variable -@code{flowers} nor the list @code{(rose violet daisy buttercup)}, both -are quoted. (When you use @code{set} without quoting its first -argument, the first argument is evaluated before anything else is -done. If you did this and @code{flowers} did not have a value -already, you would get an error message that the @samp{Symbol's value -as variable is void}; on the other hand, if @code{flowers} did return -a value after it was evaluated, the @code{set} would attempt to set -the value that was returned. There are situations where this is the -right thing for the function to do; but such situations are rare.) - -@node Using setq -@subsection Using @code{setq} -@findex setq - -As a practical matter, you almost always quote the first argument to -@code{set}. The combination of @code{set} and a quoted first argument -is so common that it has its own name: the special form @code{setq}. -This special form is just like @code{set} except that the first argument -is quoted automatically, so you don't need to type the quote mark -yourself. Also, as an added convenience, @code{setq} permits you to set +Also, as an added convenience, @code{setq} permits you to set several different variables to different values, all in one expression. To set the value of the variable @code{carnivores} to the list @@ -2369,18 +2346,6 @@ Using setq (setq carnivores '(lion tiger leopard)) @end smallexample -@noindent -This is exactly the same as using @code{set} except the first argument -is automatically quoted by @code{setq}. (The @samp{q} in @code{setq} -means @code{quote}.) - -@need 1250 -With @code{set}, the expression would look like this: - -@smallexample -(set 'carnivores '(lion tiger leopard)) -@end smallexample - Also, @code{setq} can be used to assign different values to different variables. The first argument is bound to the value of the second argument, the third argument is bound to the value of the @@ -2401,8 +2366,8 @@ Using setq formatted lists.) Although I have been using the term ``assign'', there is another way of -thinking about the workings of @code{set} and @code{setq}; and that is to -say that @code{set} and @code{setq} make the symbol @emph{point} to the +thinking about the workings of @code{setq}; and that is to +say that @code{setq} makes the symbol @emph{point} to the list. This latter way of thinking is very common and in forthcoming chapters we shall come upon at least one symbol that has ``pointer'' as part of its name. The name is chosen because the symbol has a value, @@ -3598,6 +3563,8 @@ Prevent confusion @unnumberedsubsec @code{let} Prevents Confusion @end ifnottex +@c FIXME!! lexbind!! + @cindex @samp{local variable} defined @cindex @samp{variable, local}, defined The @code{let} special form prevents confusion. @code{let} creates a @@ -4471,9 +4438,7 @@ Review The @code{setq} special form sets the value of its first argument to the value of the second argument. The first argument is automatically quoted by @code{setq}. It does the same for succeeding pairs of -arguments. Another function, @code{set}, takes only two arguments and -evaluates both of them before setting the value returned by its first -argument to the value returned by its second argument. +arguments. @item buffer-name Without an argument, return the name of the buffer, as a string. --=-=-=--