From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Can't M-x compile-defun `edebug' because dynamic variables are falsely taken as lexical. Date: Wed, 04 Jan 2017 17:26:53 -0500 Message-ID: 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 X-Trace: blaine.gmane.org 1483569017 21919 195.159.176.226 (4 Jan 2017 22:30:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Jan 2017 22:30:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 04 23:30:12 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 1cOu4O-0004eo-Pt for ged-emacs-devel@m.gmane.org; Wed, 04 Jan 2017 23:30:08 +0100 Original-Received: from localhost ([::1]:42499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOu4T-0005Ss-0k for ged-emacs-devel@m.gmane.org; Wed, 04 Jan 2017 17:30:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOu1d-0003jI-TY for emacs-devel@gnu.org; Wed, 04 Jan 2017 17:27:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOu1Z-0007BV-1C for emacs-devel@gnu.org; Wed, 04 Jan 2017 17:27:17 -0500 Original-Received: from [195.159.176.226] (port=57741 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cOu1Y-0007Az-Qs for emacs-devel@gnu.org; Wed, 04 Jan 2017 17:27:12 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cOu1I-0008MA-H3 for emacs-devel@gnu.org; Wed, 04 Jan 2017 23:26:56 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 26 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:o2CbXyP7nWVn2ylVUt61jmVvh3I= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:211115 Archived-At: >> 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. 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)). Stefan