From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.help Subject: Re: Closures in Emacs and their usage scenarios. Date: Tue, 28 Sep 2021 13:53:20 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27803"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Monnier To: Stefan Monnier via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 28 13:54:00 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 1mVBgN-0006zs-V5 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Sep 2021 13:54:00 +0200 Original-Received: from localhost ([::1]:60388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVBgM-0004DD-90 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Sep 2021 07:53:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVBft-0004Cj-LY for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 07:53:29 -0400 Original-Received: from mail-oln040092070052.outbound.protection.outlook.com ([40.92.70.52]:27045 helo=EUR03-AM5-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 1mVBfq-0007rY-A4 for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 07:53:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fLg0OCPBWpLOOKhAV+nyzIMeJ2yDScDpWX5WBvO92sKLsNGfRMnj4uuxxYbbWqnAGefYl2iH5DsBJRWx1CWKMawemoBbuzhjxxGia3m9YydAtuxp5p+ODF4k01ichKFMB1WjGXHU5N8A0BnR1KeeOrhT1YZY+3PK1C+iQzYYVswfyxY3xrnMAGOOMDT2SqeHJ/7PcH2Q/+Vw9Zlc1KWaBSCMNuLVaKalS8l3TAU2ML1j8IVJON9Wvn7hnl30+WTUHdW4OSVxWawqfLM9nI+ua4efK4iYap6PasKcNfQUmt0eHRGy9nBersng7zi7T3+iChPGbu+V40Rhn+cD3D5JNw== 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; bh=POO2+SQuQXfXjxuT4REiAJAPGYr0w/8w+qpd8wbvR+4=; b=LIsiUam3sZJXNeAcWx1h8Kr12fdYHV51bMYKw0u6RBPjlkCcmT7zLNvOzKGqUTMID9VhwbjNhiXH/Oh6A+72YxjSWbErdyXAeZN3aF63vfNQEx9UtZSBTWnBS+5E9HXrQV+BXeKtAzy7KCnsmtol9EFwXZePMLEYgULV63fObUKCjCUBGE6gO7vhO6UpPJZS8MtD6Nyo8tAKSrmdn7DddAdhgmv3x33Z925Dw/AM3iWxFtAVfD6pbiV14wtw/rCidFL0LpXgqwqTBYGQP8TquvH3+oh4S+5go6kbL13E+AGVcI/18SSebsSLD8PVE7GhTbfvD7EQQGLhEIj9IV44Dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=POO2+SQuQXfXjxuT4REiAJAPGYr0w/8w+qpd8wbvR+4=; b=ib2rA1+3eqwqZD2IHpUItCRZX/7pkecr9l5lNQIYmGWrY6BK//p1nbcO1EzwXNxdaM2itLm5V2ps3wwMmgy8c62BF/aXmvMsqjP13NqM+jR/Xd4NRY0SZsasLQgtknZX8XdXROHcJmASXkQ5qhhprV+sbibVviSdjroe3KPmsk1gqvVbQKi0H2Fd3SrUQfX6pYHjKbGbrpq3FfZRLrOe/zNO67lLhkGB+dR065TkIx7jNXXKGnfa2uOZvDNlDruTIBjGfWhosOZ2uw8olNQGZ5kI5DU6ArBlR7hdYNn3PZ3RxdnW3P7WiWUDdzhXdQfoKEbEXZsbR1bnitfBP98xDg== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB2468.eurprd09.prod.outlook.com (2603:10a6:208:d8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 28 Sep 2021 11:53:22 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc%9]) with mapi id 15.20.4544.022; Tue, 28 Sep 2021 11:53:22 +0000 In-Reply-To: (Stefan Monnier via Users list for the's message of "Mon, 27 Sep 2021 22:55:51 -0400") X-TMN: [Q2J7bmUGBz4U3DHSM/BxKSy/wZsIY7Aj] X-ClientProxiedBy: HE1PR0902CA0040.eurprd09.prod.outlook.com (2603:10a6:7:15::29) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <871r58zzkf.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by HE1PR0902CA0040.eurprd09.prod.outlook.com (2603:10a6:7:15::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.13 via Frontend Transport; Tue, 28 Sep 2021 11:53:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c439843d-9e87-4e36-fb6f-08d982769230 X-MS-TrafficTypeDiagnostic: AM0PR09MB2468: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yYFTykW9B+rSJ7GfOAYnssC/GldSZjxsHo5If+M0FRuAKV1HJHtvZIPYBAbUKzaKgqlYm8Skqp5eiBQAgeCz/gj5SUKMfO25dGgv7WwRTAAaOv8IE0qr9SKIFT/GHyBJ0RT0C4NK3Oe39/blY6+kXn3AwGPqWtEu+Sa8mp4rWzAd6KfCfRJ7AwjpS+FuC9Bs5P4n0w8D/uVvzwBQJ84/oAZx5dvF+A+GQ4uVNEDzpHZVVMn8SdLutp2Lwh1Kw0HmgkoOfNUKu6mQbbPHjwTMnGvLQtkE6ZKp9D1dAi0uNuPgxQbX2EysyEXhCaE8pObA3z+HmtllQ2U+25kq2YVuqsBOe64O3jcE1wh4JqNUpwNJe9FKq75Ry4orwKy1EOn9PRK8x4b+L5Syfi9gc7EhVmDV5kawWOBhCBSeMoNwJx1URDAnUMM3+ikXDh4EneAYA1YrF68P/7LwNYafw/Pm2GRT3D8Uz998fho1JBdmBH4= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OdN7i+RYA7obkIl4Asbd8e9IFokxZ7LOHghBvvZXX3l8VoEWtBUdRCBWhLt/YZuKFNqna6aQzSuqCCGGsahBA7rZbqKSpUM+yVg8yc/R31eohQta/kyH4WBVd+kbDaLmSv7WpSQB9x9wdJrF6MI/VQ== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: c439843d-9e87-4e36-fb6f-08d982769230 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2021 11:53:22.5676 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB2468 Received-SPF: pass client-ip=40.92.70.52; envelope-from=arthur.miller@live.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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:133346 Archived-At: Stefan Monnier via Users list for the GNU Emacs text editor writes: >> I noticed the document on closure here [1] implemented in Emacs/Elisp currently. >> But it's only a very concise and short introduction, and I want to >> know more about the closures in Emacs and their usage scenarios. >> Any helpful tips are welcome. > > Maybe a good starting point is > > https://en.wikipedia.org/wiki/Closure_(computer_programming) Chapter 2 from "On Lisp" by P. Graham has also very nice and accessible intro to functions and closures: https://sep.yimg.com/ty/cdn/paulgraham/onlisp.pdf?t=1595850613& So has also "Let Over Lambda" by D. Hoyte: https://letoverlambda.com/index.cl/guest/chap2.html Chapter 2 is an entire chapter on closures and using them; if one is not scared by subtitles like: "Let Over Lambda Over Let Over Lambda" :).