From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Thorpe Newsgroups: gmane.emacs.help Subject: Re: using setq to create lists based on other lists... Date: Sun, 02 Dec 2018 19:11:28 +0000 Message-ID: <87va4bu4kf.fsf@robertthorpeconsulting.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1543777799 28432 195.159.176.226 (2 Dec 2018 19:09:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Dec 2018 19:09:59 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Jean-Christophe Helary Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 02 20:09:55 2018 Return-path: Envelope-to: geh-help-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 1gTX7q-0007Hy-I8 for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Dec 2018 20:09:54 +0100 Original-Received: from localhost ([::1]:45572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTX9x-0003uL-0R for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Dec 2018 14:12:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTX9T-0003uG-QX for help-gnu-emacs@gnu.org; Sun, 02 Dec 2018 14:11:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTX9Q-0005HD-Ly for help-gnu-emacs@gnu.org; Sun, 02 Dec 2018 14:11:35 -0500 Original-Received: from outbound-smtp27.blacknight.com ([81.17.249.195]:54459) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTX9Q-0005GP-Fe for help-gnu-emacs@gnu.org; Sun, 02 Dec 2018 14:11:32 -0500 Original-Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp27.blacknight.com (Postfix) with ESMTPS id 007DDB8870 for ; Sun, 2 Dec 2018 19:11:30 +0000 (GMT) Original-Received: (qmail 16565 invoked from network); 2 Dec 2018 19:11:29 -0000 Original-Received: from unknown (HELO RTLaptop) (rt@robertthorpeconsulting.com@[109.77.118.232]) by 81.17.254.9 with ESMTPSA (AES128-SHA encrypted, authenticated); 2 Dec 2018 19:11:29 -0000 In-Reply-To: (message from Jean-Christophe Helary on Mon, 3 Dec 2018 02:21:05 +0900) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 81.17.249.195 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118838 Archived-At: I agree with you on some things and I disagree with you on others. Notice also it says this in the Emacs Lisp intro in the node "Using setq": > Although I have been using the term =E2=80=98assign=E2=80=99, there is an= other way of > thinking about the workings of =E2=80=98set=E2=80=99 and =E2=80=98setq=E2= =80=99; and that is to say > that =E2=80=98set=E2=80=99 and =E2=80=98setq=E2=80=99 make the symbol _po= int_ 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 =E2=80=98pointer=E2=80=99 as= part of its > name. The name is chosen because the symbol has a value, specifically > a list, attached to it; or, expressed another way, the symbol is set > to =E2=80=9Cpoint=E2=80=9D to the list. It also says in the section on setcar: > As you might guess from their names, the =E2=80=98setcar=E2=80=99 and =E2= =80=98setcdr=E2=80=99 > functions set the CAR or the CDR of a list to a new value. They > actually change the original list, unlike =E2=80=98car=E2=80=99 and =E2= =80=98cdr=E2=80=99 which leave > the original list as it was. ... > Put another way, the variable =E2=80=98animals=E2=80=99 points to the lis= t =E2=80=98(antelope > giraffe lion tiger)=E2=80=99. In the section "How Lists are Implemented" it describes how things work internally. So, I think you could have avoided your first problem if you'd read the intro more carefully. However, you're quite right in what you wrote most recently... >> You're using `setq` on vars you haven't declared/defined yet! > > The Introduction doesn't even mention that... It doesn't. It mentions setq, let and defvar. But it never says that it's the preferred style to define variables with let & defvar first. I think it should say that. I've seen lots of beginners write programs that setq undefined symbols and now I know why. >> Better write this as (setf (nth 3 myDateLastMonth) myDay) > > No reference to setf in the Introduction, and it's buried under tons of r= eference in the Reference... I agree here too. I think setf is important enough that the introduction should mention it at least in passing. BR, Robert Thorpe