From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean-Christophe Helary Newsgroups: gmane.emacs.devel Subject: lexical binding? Date: Sun, 24 Oct 2021 10:09:57 +0900 Message-ID: <35E8DC30-8C38-4D74-840A-BBAFDEBA7357@traduction-libre.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36850"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Oct 24 03:11:47 2021 Return-path: Envelope-to: ged-emacs-devel@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 1meS38-0009PJ-VY for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Oct 2021 03:11:46 +0200 Original-Received: from localhost ([::1]:43102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meS37-0008Jh-OW for ged-emacs-devel@m.gmane-mx.org; Sat, 23 Oct 2021 21:11:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meS1c-0007UY-0k for emacs-devel@gnu.org; Sat, 23 Oct 2021 21:10:12 -0400 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:37697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meS1Y-0002MJ-Hd for emacs-devel@gnu.org; Sat, 23 Oct 2021 21:10:11 -0400 Original-Received: (Authenticated sender: lists@traduction-libre.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 70E35100004 for ; Sun, 24 Oct 2021 01:10:01 +0000 (UTC) X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=217.70.178.231; envelope-from=lists@traduction-libre.org; helo=relay11.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:277637 Archived-At: I need to make sure I understand this properly. When I "setq" variables in a defun, they are by default global, so, in = the following code: (defun checkDayTracker () "Creates values for the new index, based on yesterday's values." (save-current-buffer (set-buffer (find-file-noselect dayTrackerPath)) (goto-char (point-min)) (search-forward-regexp "\\([0-9]*\\.[0-9]*\\) \\([0-9]*\\) = \\([0-9]*\\) \\([0-9]*\\)") (setq timeStamp (match-string 1) seasonNumber (match-string 2) totalDays (+ 1 (string-to-number (match-string 3))) dayInSeason (+ 1 (string-to-number (match-string 4))) newTracker (format "%s %s %s %s\n" (float-time) seasonNumber = totalDays dayInSeason)) (goto-char (point-min)) (insert newTracker) (save-buffer) (kill-buffer)) (list seasonNumber totalDays dayInSeason)))=09 I don't *need* to return a list with the values to expose them to other = functions. I can just call the various variables by name directly in = another defun. If I wanted to have them strictly local, I'd use "let" and I would only = be able to access them in the "let" block. If the above is correct, is there anything else there is to know about = lexical binding? (I certainly do not presume that I've understood more than a very tiny = portion of the surface of this issue so I suppose that the answer is = yes, but...) Also, in a 2018 thread that I started in December 2018, when I asked = about using setq to create lists based on other lists, Robert Thorpe = says "I've seen lots of beginners write programs that setq undefined = symbols and now I know why." = (https://lists.gnu.org/archive/html/help-gnu-emacs/2018-12/msg00025.html).= What is the issue with using setq on undefined symbols? Can that break = things eventually? Is that related to lexical binding? --=20 Jean-Christophe Helary @brandelune https://mac4translators.blogspot.com https://sr.ht/~brandelune/omegat-as-a-book/