From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Can't M-x compile-defun `edebug' because dynamic variables are falsely taken as lexical. Date: Thu, 5 Jan 2017 10:54:27 +0000 Message-ID: <20170105105426.GB3835@acm.fritz.box> References: <20170103141444.GA4649@acm.fritz.box> <20170103213228.GB2085@acm.fritz.box> <20170104133948.GA7373@acm.fritz.box> <20170104200458.GA2052@acm.fritz.box> <20170104220243.GC2052@acm.fritz.box> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1483613750 9619 195.159.176.226 (5 Jan 2017 10:55:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2017 10:55:50 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 05 11:55:46 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cP5hq-0001B6-Gw for ged-emacs-devel@m.gmane.org; Thu, 05 Jan 2017 11:55:38 +0100 Original-Received: from localhost ([::1]:45613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cP5hu-0001zL-M5 for ged-emacs-devel@m.gmane.org; Thu, 05 Jan 2017 05:55:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cP5h0-0001wO-7y for emacs-devel@gnu.org; Thu, 05 Jan 2017 05:54:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cP5gx-0002Mh-69 for emacs-devel@gnu.org; Thu, 05 Jan 2017 05:54:46 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:55670 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1cP5gw-0002MZ-WF for emacs-devel@gnu.org; Thu, 05 Jan 2017 05:54:43 -0500 Original-Received: (qmail 61633 invoked by uid 3782); 5 Jan 2017 10:54:41 -0000 Original-Received: from acm.muc.de (p548C6DF0.dip0.t-ipconnect.de [84.140.109.240]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 05 Jan 2017 11:54:40 +0100 Original-Received: (qmail 7892 invoked by uid 1000); 5 Jan 2017 10:54:27 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211121 Archived-At: Hello, Stefan. On Wed, Jan 04, 2017 at 05:26:53PM -0500, Stefan Monnier wrote: > >> In which context do you need/want to do that (I ask because how to do > >> it (and even if it can be done) depends on the details)? > > I honestly don't know. I presume that there will be code (other than > > the byte compiler) which will want to make a distinction. > There might, indeed, but it's very rare: in most cases rather than > determining which kind of binding will happen, you want to decide/impose > which binding will happen. OK. > I'm not sure how Common-Lip handles it, but AFAICT there is no > equivalent to special-variable-p there, so they don't seem to offer > a way to find out whether a binding will be lexical or dynamic. > > After (defvar foo), the byte compiler seems able to handle foo as > > a dynamic variable. I'm still trying to figure out how, > The byte-compiler *sees* the defvar, which lets it keep a note > internally (in a data-structure which keeps track of the current > context, which also includes information about which vars that are > let-bound in the surrounding code were bound lexically, so as to know > when we see a reference to var `foo' whether we should look for `foo' in > the dynamic context or in the lexical context (and if so, where in that > context)). Thanks, I'll have a look at that sometime. > Stefan -- Alan Mackenzie (Nuremberg, Germany).