From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Leo Butler Newsgroups: gmane.emacs.help Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? Date: Mon, 11 Jan 2021 06:53:13 -0600 Message-ID: <86r1mrmy86.fsf@x201.butler.org> References: <868s92ntez.fsf@x201.butler.org> <86zh1hn21c.fsf@x201.butler.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26876"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 11 14:11:36 2021 Return-path: Envelope-to: geh-help-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 1kywyu-0006tE-9d for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 11 Jan 2021 14:11:36 +0100 Original-Received: from localhost ([::1]:39616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kywyt-0001ZD-Ar for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 11 Jan 2021 08:11:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kywvr-0000NU-O5 for help-gnu-emacs@gnu.org; Mon, 11 Jan 2021 08:08:27 -0500 Original-Received: from mail-eopbgr670112.outbound.protection.outlook.com ([40.107.67.112]:38912 helo=CAN01-TO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kywvm-0003Ny-Fk for help-gnu-emacs@gnu.org; Mon, 11 Jan 2021 08:08:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EP2OwXDJ9RjFWeM866S92rhpIo5ec2Q0DBUvt/XD+fMJMLiDrbvohAO8kN/TXGwRtRWVBsTrLyG6Tms9t9ztPD2ygp7R1MBBLd/jfOdScj2q4Gk4PlBOqmiqKLgjFUpr+RC+9FI1W7xnIeyY73DDwhkcpXzq96uH3lHeu1McMuVh1Z0foZzF6WgdCWrFpD74VOWKhN2Rhw13TSCFqSIUCZ0ZOpZHVbMIBvGAAb+giw3mDLfmuBm0PZfi+teHQN+RnthTEDp8NJhlTOCY5r7dwLE0fT9oZCSVsRFyyWzRyRE62LYiuygEX+TWp/si3Z09mpV7UrYAVVdfIopkPGJCLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PQh4qeb16F96BttqfszbjlxgPf2ouYeaqBlRH/TqVeg=; b=OE0vvcTd/UE0btQoHgubZohtvPJV5arIhe+OPYP7StaFEQvUdvYLLoYsgmUUOLQailxfnTr2m9UDH0e+Vihlvoy0Cy4eamVxcBNIvgGL2ykY1E/kxS32yyPsiDjQd4T0fwX70GE/pUOqxIOs1nLDTjx5xUnK4jT/t3NY7ifF18lcOpLt3kuToY0yHvJfd6NHFuAapKVU3moV/vAO8BJpxmPsObdN6OH6SprAvxzEubE6rPhAH1elw48iMW5omGT6b41Qp0i/zaEkCgajAc5OR8qzqE6LQ4m+KOmNJFxvpKmQnAUoPZ9biTSDMpBRES4xgiXHIxKNoJHAar56Yfxy4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=umanitoba.ca; dmarc=pass action=none header.from=umanitoba.ca; dkim=pass header.d=umanitoba.ca; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umanitoba.onmicrosoft.com; s=selector2-umanitoba-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PQh4qeb16F96BttqfszbjlxgPf2ouYeaqBlRH/TqVeg=; b=Bz4z7P2ZNVsGLk66D+j5L2IzOJR7DsZUsZRR2jQXOuWjVhI1hgcfniKKDH85lTPOKjg7z+GJy4q6zOiPoKounJmsEV4HIWhzu0P7qeZhzF69jJYRz5dcQIkSxt4TZGFbet7TSdairodBgTSR2VzyCVncY69XXfHqVDNp1OGEUQQ= Authentication-Results: gnu.org; dkim=none (message not signed) header.d=none;gnu.org; dmarc=none action=none header.from=umanitoba.ca; Original-Received: from YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:21::31) by YTXPR0101MB1773.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.12; Mon, 11 Jan 2021 12:53:17 +0000 Original-Received: from YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM ([fe80::e557:4be:b224:e3ca]) by YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM ([fe80::e557:4be:b224:e3ca%4]) with mapi id 15.20.3742.012; Mon, 11 Jan 2021 12:53:17 +0000 In-Reply-To: (Stefan Monnier's message of "Sat, 9 Jan 2021 18:14:49 -0500") X-Originating-IP: [45.44.33.194] X-ClientProxiedBy: MW4PR04CA0008.namprd04.prod.outlook.com (2603:10b6:303:69::13) To YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:21::31) X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from x201 (45.44.33.194) by MW4PR04CA0008.namprd04.prod.outlook.com (2603:10b6:303:69::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 12:53:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bf2600c-2ba6-406e-aabd-08d8b62fde16 X-MS-TrafficTypeDiagnostic: YTXPR0101MB1773: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x66Ja1CUuMqab2WR9sETRha9mqtmUYE78c+Ge2jMw5lO9k5X9FoIPrJu5CjAKwK2mOuc4OHRlLI81kEPmTmbRV4UrH0ii1FTw7htWAVSbJDg8SGORgamXWGoh0ml0aa/VNiwUIblmV/Zmv7ZZTdyxoGp5ux0IIY+pjYnl9lWX+s5wDIRkY1jJDVDHTVs/C8PRW4UF6fzDjgizpdVIufGrukUZm94q53HjS9A026kAPwM0iCesCoSVqlRKE1cbNfUkupY+n1u/cS0vZHomBMAx4odwOzd4u+xrBVuhpYg8kTh8k+wcbBz1zDJ6+7K24IdouuGbbn+3hiHee7IKc+gIeXUI2tZbaFaWfXSwOX+78k1zRki5xtoejaLuizMXGnuf51/fZ8F1t6JY3EkaSm++W0OkQlIUlG/uCpfJDunoICae5oDTSvsFiIxGeZo5AKxLN7OuxZ3TSOgq+/n9IMfzrrxvkBIM4c26PRDhSJAezOFZrFB4bLSRE653D51Wi09RkuZ29cRe9KRCQQg7OdsMg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(376002)(366004)(346002)(396003)(136003)(39850400004)(52116002)(6496006)(8676002)(5660300002)(956004)(8936002)(83380400001)(478600001)(44832011)(16526019)(2906002)(786003)(6666004)(66946007)(316002)(66476007)(66556008)(6916009)(26005)(186003)(4326008)(6486002)(9686003)(86362001)(81973001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?UXt2Ere+gTgniitfC1pmZ/mXLuZB5pWtEd0az/XQBQZ2QXbi6o78AGjTCdA7?= =?us-ascii?Q?0UQSL785uQlvXcVxTSRLKL4Wiv1a/rYYHdL7sViJ1JxClZLIbztt0iGUpMN3?= =?us-ascii?Q?Oy9DyJ0BBBaLD4oyLrS2itECaSpnPDBOhiLTg8MutV5wemh0/IX3yxZYcUkQ?= =?us-ascii?Q?sEIs3zpOyTy71UAofUgNMJQTHsOi6eNVOvgaEGW1QtydmbxrhTvK7fSEOXvX?= =?us-ascii?Q?Pt60qbOpvgpKnDRYhlk0vufBRO8v26n/VAyDixzY7rT7E4yU9NPNwjDg3R8Y?= =?us-ascii?Q?nacd+pR6z18xjozC6TLcf/v5EglCxM8XD9itAhRHU+hkUHREKpUMmqsPG9ju?= =?us-ascii?Q?+lAHFdY5kWqlDA1U697ynvOk7eFCe9sLtI3KlL+HB1sd138KVtWu+SqmTsFE?= =?us-ascii?Q?ZnlqapdkYpgbotNfoLAftyHGVkErkjGM5ItN4xSU4NTkPNc6y8qeFizevLSB?= =?us-ascii?Q?3ScIzTcMftOybhSOg/vliNLIAdxEWKnqqW/p+q0O8K+mpL+h8wI0PuqA43qV?= =?us-ascii?Q?ztIqY+ErEve8T36WkUz3PRKSprk9cuf1CuR+SENd18OwWES3DHoFCB6rdfoE?= =?us-ascii?Q?aJbxtBQjNNm6AofL3ORQeIGwwC5p4AYQmFILJx8CwxQogmhEg6GHXuOD8j09?= =?us-ascii?Q?6ssB X-OriginatorOrg: umanitoba.ca X-MS-Exchange-CrossTenant-AuthSource: YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2021 12:53:17.8191 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f80dd0b-338c-4e4c-8a14-90446962f7b8 X-MS-Exchange-CrossTenant-Network-Message-Id: 2bf2600c-2ba6-406e-aabd-08d8b62fde16 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WDqTcmOPwCKS2gU6XyntZCePDomGJBK+sOrvQGbnlrcY3ULO2rI0+DyDnrNaIAqOvLZOWK3BpCFodeerm8vMjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTXPR0101MB1773 Received-SPF: pass client-ip=40.107.67.112; envelope-from=Leo.Butler@umanitoba.ca; helo=CAN01-TO1-obe.outbound.protection.outlook.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127188 Archived-At: Stefan Monnier writes: > ******************************************************** > Caution: This message was sent from outside the University of Manitoba. > ******************************************************** > >>> This distinction becomes relevant if BODY modifies VAR or captures it >>> in a closure. >> Maybe I am being thick, but I cannot think of how there would be a >> different behaviour. > > Try: > > (let (funs) > (dotimes (i 5) > (push (lambda () i) funs)) > (mapcar #'funcall funs)) > > IIUC the version you advocate would return > > (5 5 5 5 5) > > whereas the current version returns > > (4 3 2 1 0) Thanks, I was being thick. ---- I realize that elisp does not claim to be a dialect of common lisp, but it would be helpful to note that this behaviour deviates from the behaviour of several CL implementations (gcl, clisp, sbcl, ecl). The CL standard (http://clhs.lisp.se/Body/m_dotime.htm) says: .... It is implementation-dependent whether dotimes establishes a new binding of var on each iteration or whether it establishes a binding for var once at the beginning and then assigns it on any subsequent iterations. > > Other differences occur if you do > > (let (vals) > (dotimes (i 10) > (push (setq i (1+ i)) vals)) > vals) Yes. Leo