From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: How do I pass a variable defined in a wrapping let, to a lambda? Date: Mon, 14 Mar 2022 15:51:40 +0100 Message-ID: <87zglsh9j7.fsf@zoho.eu> References: <87k0d03vaw.fsf@ericabrahamsen.net> <8735joc5of.fsf@web.de> <87r177rjzn.fsf@zoho.eu> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26396"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:JoNHDZRgKm9kSPcgHJCvKG1VBQ0= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 15 04:16:45 2022 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 1nTxfx-0006c2-1f for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 15 Mar 2022 04:16:45 +0100 Original-Received: from localhost ([::1]:45658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTxfv-0001Rj-Mv for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Mar 2022 23:16:43 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTm39-0005dK-22 for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 10:51:56 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:58296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTm36-00073U-5J for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 10:51:54 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nTm32-000ADK-LL for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 15:51:48 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 14 Mar 2022 23:14:45 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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:136556 Archived-At: Jean Louis wrote: > New `dlet' is this and it broke my programs because somebody > removed `let*' inside. I don't think that person who changed > it every used `dlet' in their own programs. Reason is > semantics, "dlet" uses "let*" so they changed it, but did > not provide "dlet*" (though is easy to adapt it). So there is a `dlet', there is also a `lexical-let' lexical-let is a Lisp macro in ‘cl.el’. (lexical-let BINDINGS BODY) Like ‘let’, but lexically scoped. The main visible difference is that lambdas inside BODY will create lexical closures as in Common Lisp. However ... I don't know how useful this is, especially not in the face of `dlet' and even more so the consensus (?) that static/lexical scope should be the default? Also based on that the docstring is confusing since that's what you get with `let' under static/lexical scope (at least the closure example; I don't now if `lexical-let' is ALWAYS static/lexical or if it allows already dynamic/special variables just as `let' does even under static/lexical scope? I think they are the same there as well, right?). But/so better would be an `slet' (with an `llet' alias, or the other way around) which is always static/lexical, a `dlet' which is always dynamic/special, and a `let' that can be both - static/lexical unless dynamic/special variable(s) is/are already present with the same name(s) ... `lexical-let' would be deprecated/obsolete which would be stated in the docstring and by the byte-compiler, to not break code one could alias it to `let' - not that I think think people use it a lot, right? Then static/lexical scope would be the default, ugly and error-prone cookies with respect to this would be unnecessary and all dynamic/special use would be explicit and much easier to describe in docstrings on a function-by-function basis. Use of dynamic/special scope would be reduced a lot since a lot of today's use is probably due to either ignorance or old habits of not using the cookie to set/get static/lexical scope. Problem solved! Any questions? PS. When the legendary African leader Patrice Lumumba held his speeches he always concluded with that question. And there were never any questions, because if anyone asked he was later beaten up by Lumumba supporters :) -- underground experts united https://dataswamp.org/~incal