From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: lexical-binding is turned on in more use cases Date: Tue, 10 Mar 2020 23:06:38 -0400 Message-ID: References: <83k13ubv3g.fsf@gnu.org> <83imjebsrh.fsf@gnu.org> <20200308193048.GB4832@ACM> <20200310191328.GB5046@ACM> <87lfo7q5e3.fsf@web.de> <20200310215334.GG5046@ACM> <87eetz4w1k.fsf@web.de> Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="108843"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, eliz@gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 11 04:07:16 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jBriG-000SCS-NS for ged-emacs-devel@m.gmane-mx.org; Wed, 11 Mar 2020 04:07:16 +0100 Original-Received: from localhost ([::1]:43188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBriF-0004Qb-Qr for ged-emacs-devel@m.gmane-mx.org; Tue, 10 Mar 2020 23:07:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47970) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBrhf-0003Mj-KJ for emacs-devel@gnu.org; Tue, 10 Mar 2020 23:06:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jBrhf-00004s-7X; Tue, 10 Mar 2020 23:06:39 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1jBrhe-0006FR-1m; Tue, 10 Mar 2020 23:06:38 -0400 In-Reply-To: <87eetz4w1k.fsf@web.de> (message from Michael Heerdegen on Wed, 11 Mar 2020 00:41:59 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245471 Archived-At: [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > (defun my-make-counter () > (let ((counter 0)) > (lambda () (setq counter (1+ counter))))) > (setq mc (my-make-counter)) > (funcall mc) => 1 > (funcall mc) => 2 ; etc. > If you eval (my-make-counter) with lexical-binding off, the result is > not functional. It is clear that my-make-counter needs to be run with lexical binding. The closure it returns also needs to be run with lexical binding. However, it seems like a bug that the lexical-dynamic mode in effect around the _call_ to my-make-counter has any effect on how it runs. It seems to me that if the definition of my-make-counter comes from a file that specifies lexical, it should run with lexical bindings regardless of where it is called from. -- Dr Richard Stallman Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org)