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: Sat, 09 Jan 2021 17:06:23 -0600 Message-ID: <86zh1hn21c.fsf@x201.butler.org> References: <868s92ntez.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="8118"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 10 00:07:06 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 1kyNK5-0001yp-Aj for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 10 Jan 2021 00:07:05 +0100 Original-Received: from localhost ([::1]:59364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyNK4-0006GG-9h for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 18:07:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyNJa-0006G3-Bx for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 18:06:34 -0500 Original-Received: from mail-eopbgr660101.outbound.protection.outlook.com ([40.107.66.101]:35328 helo=CAN01-QB1-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 1kyNJX-0002Lr-A9 for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 18:06:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nlVk42nG1GFcAxxdfvVspjOQTJmVK+A8p4HHEIhP8jm3aryuHtG2wqf0RhpOWnnmARNGSE/bJ3qhEI3sYvoc3RbCVsXodEDz/fcpRJq7vCvv37lBpE9AjshVhxjipO02YpFGIIFNW+KeQUGHmszVJ6c5VOKdRxSwnV03TxwBeyWMJlcSjYh7dt0VefgHa0RTO//QCsarQOzGizcaIWWpTTOWnxqYUW+gDbHSvaKp5mel0c73UASctlUnutlEKkYnS5abRtFTa3rBgO7igz+36zUwHgqsUjz9XD0mEouz3VZ4nymqSx0Estj7eyZGZT/XnE0mRGSJEcorkdHF9etnhg== 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=kPYpi/XusBlGzuRRgMxr5Zy39eyvWZvznUY3KA6IlkE=; b=iaAzioC6SbJBPxoiMEKbwfjnh/qZ5So+yyPGNeLh0voqDdxgLjQohLWZWc9nP1NjeW86+pUe9cFinhX5nKUDDqR728nN5dqtAuaHzKiDzu0d2lg+f3z3PW7jvY4EkhoP4yS+8WpVpxCScYCCtrMFI81EyQtMqgcOjqnaLFPEL8vpE8jB0ybJtjoCnKem3DvqSEJz2bjEGlkNerKP5IBAQTTXgLdzcIs5eAv2WicsIYx79TVdJpPO0P2j2gPJSrTK8EBS7FDJeWzLALVKwKWieJ3zShVXtinONYiAEUWhG4z2sJOHI42bJu531WPBEZ677edZRQY08MBl4sCOwqND7g== 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=kPYpi/XusBlGzuRRgMxr5Zy39eyvWZvznUY3KA6IlkE=; b=K2cs4aI+v5Ycl22UyM6XVt4m7P1gn+VHS8OAbtlrJ7V6U/q3EvV8uqfVQvu8Y17DIvItUDTRI858TQXjUerfOsXWBq1bpu86I4sW21cgmwh/gsLO8xuqEFdvL3ozXQL4IJVRMiyAOlFJEN5HMxV8NkTRipQ7euQ+KFMJHGju87I= 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 YT1PR01MB4345.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:29::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Sat, 9 Jan 2021 23:06:28 +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; Sat, 9 Jan 2021 23:06:28 +0000 In-Reply-To: (Philipp Stephani's message of "Sat, 9 Jan 2021 15:02:08 +0100") X-Originating-IP: [45.44.33.194] X-ClientProxiedBy: CO2PR18CA0047.namprd18.prod.outlook.com (2603:10b6:104:2::15) 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 CO2PR18CA0047.namprd18.prod.outlook.com (2603:10b6:104:2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Sat, 9 Jan 2021 23:06:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d102bed7-0d75-4d61-7a05-08d8b4f3321e X-MS-TrafficTypeDiagnostic: YT1PR01MB4345: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EZspQO/0C98gpkS1wrNN1pCUPkqqK7eHzzLRIjdwgWrFuirUrbWofTjHORlzJ01OTMjBB/ooyGOrBgbxhra5xo90hz8i4eojQvNFR3wOmRA5hUBFzSMiydtmEFPRJSEiN+xsSntkNmKCaj1f4HJxku8zJDDYrGwadh7UbRHRoTMnIATE02HMhCEwHHZWSP7Jolqr2G3DOycPAc7+Oc8bCHYm1m8us5SShN95JMGXq+Vxyik1cDI+OgYRR6rraonGuA3d1WrS55/mlee7dK4ZgxAiefPmkm/O3G3m4+vIbOS2YX7XfaB/pSYA8sqKvZpShew7JcwujcnR9NLM1YIvMEw5jqNNa2UktEOjNHTlB5DrA1FvlzNcIHSJwa1GAF11zn+Q/i62bTii7s17q+LBLfe52waXLDcH0cAVdXfu/8RGiCaL46RtiAMA6DyBZP6u 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:(39850400004)(396003)(136003)(376002)(366004)(346002)(66946007)(9686003)(66556008)(83380400001)(66476007)(6916009)(5660300002)(6496006)(44832011)(6486002)(6666004)(52116002)(26005)(8676002)(478600001)(956004)(786003)(16526019)(2906002)(316002)(186003)(86362001)(8936002)(81973001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?1CcNOrdgniPGPDVIrkkLre952w4W64IVNo1HYEjFi5LzKe4CXHwl7v8uQq0h?= =?us-ascii?Q?t/D2GMtRfmWp8aT+UtpQ4vOup5+mCFx5mrP71Z/UjuRNZwcjbc5ccVuuqJge?= =?us-ascii?Q?ZOdEraTjEsYDypXO5n1kVCNiPMxmFSsj+kcITgxoh1reLUM/JxqsledFyHWl?= =?us-ascii?Q?6DjOyRpKJqh/a+bpN3hKvnN3QvzdPsyUgevpfd3k9pf2K6vU5Ey+fkKNMxqE?= =?us-ascii?Q?iSCBOEw6GajOYLGrmsphDUy9eJTiz41ENwbhygFrjTnYvyecVf8KIwW5hHeX?= =?us-ascii?Q?c3h8mmiqMtU9pqZpdFtLCwreaValRQvzAbB7GD6coaq/Lch7MiPcmqtO0bf7?= =?us-ascii?Q?zlTwPdJti4cD65887X05+Qxc/Ht9RzHRGeaQ+kMRTwQMEPS8szt/Bj1lTeMa?= =?us-ascii?Q?1obYYUoXK+ICxt5TW4YgUQhkxNaQaz/71GWMa440Zf7z7t3ouEXm98j9g9iD?= =?us-ascii?Q?4tE/mB0PiujLAXOZAPzbQxyD9Odl6p128ldX5JUZQRmahSM313oJ3LdMsDVx?= =?us-ascii?Q?3fkhtvcaFfiorOJYW16FKR+gKRA+EpoEnz4Dbrk3NxCxvzGXQCNa/r/2wjrj?= =?us-ascii?Q?WkgEROZOMbtVdcTGwuvLSvhDDs4x+WsGNKShzAg15h84CmnEPS6Wnn9l0S3/?= =?us-ascii?Q?CIoF 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: 09 Jan 2021 23:06:28.3186 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f80dd0b-338c-4e4c-8a14-90446962f7b8 X-MS-Exchange-CrossTenant-Network-Message-Id: d102bed7-0d75-4d61-7a05-08d8b4f3321e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pnzdoCA/95XR2rwCa2N2Mj8/9lOmX61PYKAw8rQyq6Wv/pGwk6t0qJuD0qQxZTRT6LkkLVKdxi6Ymy+S5NBGAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT1PR01MB4345 Received-SPF: pass client-ip=40.107.66.101; envelope-from=Leo.Butler@umanitoba.ca; helo=CAN01-QB1-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:127155 Archived-At: Philipp Stephani writes: > Am Sa., 9. Jan. 2021 um 14:30 Uhr schrieb Leo Butler : >> >> Stefan, >> >> I wonder why the lexical-binding version of dotimes is not implemented >> like: >> >> #+begin_src emacs-lisp >> (let* ((start 0) (end (nth 1 spec)) (counter (gensym)) >> (body (subst counter (car spec) body))) >> `(let ((,counter ,start)) >> (while (< ,counter ,end) >> ,@body >> (setq ,counter (1+ ,counter))) >> ,@ (cddr spec)))) >> #+end_src > > That would be a semantically different operation. `dotimes' guarantees > that the counter variable is let-bound within each iteration. That > means that the macro expansion needs to contain something like > (let ((VAR ...)) BODY) > 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. Note that I am discussing only the lexical scope case. The macro replaces each occurrence of VAR (=(car spec)) in BODY with the gensym. > >> I am familiar with the comment in subr.el about uninterned symbols, but >> TBH, I don't have a sense of where the performance penalty might be >> of any significant size. > > The uninterned vs. interned distinction is unrelated. `dotimes' > chooses to use an interned symbol as a micro-optimization, but it > doesn't affect its behavior. The current dotimes macro is unhygenic, isn't it, whereas using an uninterned symbol would make it hygenic. So, yes, I think there is a difference in behavior. Leo