From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#18059: 24.3.92; defvar and special variables Date: Sat, 10 Feb 2018 19:38:41 -0500 Message-ID: <87inb4bbse.fsf@users.sourceforge.net> References: <87ha2c7lxy.fsf@web.de> <87mv0gbq33.fsf@users.sourceforge.net> <87y3k0bdm9.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1518309451 12570 195.159.176.226 (11 Feb 2018 00:37:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Feb 2018 00:37:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 18059@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 11 01:37:27 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ekfdk-0001YO-Sr for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Feb 2018 01:37:09 +0100 Original-Received: from localhost ([::1]:54564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekffk-0002Jw-KT for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Feb 2018 19:39:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekffd-0002Ij-O6 for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 19:39:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekffa-0003tY-GS for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 19:39:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57758) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekffa-0003t3-Bh for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 19:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ekffZ-0002FV-Vp for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 19:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Feb 2018 00:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18059 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18059-submit@debbugs.gnu.org id=B18059.15183095328631 (code B ref 18059); Sun, 11 Feb 2018 00:39:01 +0000 Original-Received: (at 18059) by debbugs.gnu.org; 11 Feb 2018 00:38:52 +0000 Original-Received: from localhost ([127.0.0.1]:37422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekffQ-0002F8-Bw for submit@debbugs.gnu.org; Sat, 10 Feb 2018 19:38:52 -0500 Original-Received: from mail-io0-f171.google.com ([209.85.223.171]:37413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekffN-0002Eu-M2 for 18059@debbugs.gnu.org; Sat, 10 Feb 2018 19:38:49 -0500 Original-Received: by mail-io0-f171.google.com with SMTP id f89so13731987ioj.4 for <18059@debbugs.gnu.org>; Sat, 10 Feb 2018 16:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=/zfmQBxRrB70+fQiXt7pmPnihwd60/DIauWrEhx8kTk=; b=cpE/UphR1MN19iUwHOrvctSx9d4n1/nfgdUzYhQ3+KcjxnKiqNgTB0KUUXdK1qU2hr 9npWa04K1euO5F24C6x5BVAbyrquPjP03K94CwVqJPVKJYnF6L9f6w8Nai6E50K/wb0l 870efZ496f7zNEEsJgHGpK/XZ/1rOKla+3e4UZ45GbMIa9J5Q9PVUOte9qp5TJPOxDqH CNlozxGQ3OTQO4KmrZs9DRKu1gQa237J93hjTO+p0Ds3QRXn9GcE0sAJGCRDaQ7/6rxz ox3hbfVtd4FgZdPk8OoRx+7w2HFtXRDHwXleBl6aZqL0Crh+e1DG85JyOOViTI7aoliP pPXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=/zfmQBxRrB70+fQiXt7pmPnihwd60/DIauWrEhx8kTk=; b=RhK/VPkRE8iu4EWBERHwsrvUDZGw2HMu0+0ERr1O+ilPdbKmaYeQdd3plj1+V0TGjQ pko0Ck1iOyNvjR1qMoSviejTySZ/SQh2vecsBTdDbj771m+EO3bZHcaowPp9V25IB1Ct Kl5+xAo4D5mN34YM5mOTUCSKg9mkKLU7M28mF/XvUKFaLfFF6d6LVBEXW86Vecpjz7SF an2x6RF2K7AWazf5BMv3udb9sqrEyszBU2lOHMEVWMUlreUeZ7pcT3gHhJJoMcFjkvgb 9n7/T9Gd4enYptK1V6eXfHAeu3ScexVpL1o2NcDGyN5f3zeM32XjEwRkAsOj+66fgL+k aP2w== X-Gm-Message-State: APf1xPCYS5EbFC66cnwT7b48XLXvPV6JLd2Nj0pfNxWEtRWw7E5KmS1E IuvZQDAUH+HdYL/cWXeSvNbCeA== X-Google-Smtp-Source: AH8x227Ln/SJsc/lph0YkPPYKRcdudWmXALxIZ3OwwRHiiXeT5C40QmGZpA1UVszHLw5tXIEfEAhSA== X-Received: by 10.107.23.7 with SMTP id 7mr8557328iox.62.1518309523805; Sat, 10 Feb 2018 16:38:43 -0800 (PST) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id g186sm3436105itg.2.2018.02.10.16.38.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Feb 2018 16:38:42 -0800 (PST) In-Reply-To: <87y3k0bdm9.fsf@web.de> (Michael Heerdegen's message of "Sun, 11 Feb 2018 00:59:10 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143120 Archived-At: Michael Heerdegen writes: > After reading this and thinking about it, I'm confused now what the > extent of `defvar' without a specified value is. > > In the case of a file, does it mean that the variable is considered > special for the rest of the file, or for the whole file? The rest of the file, I believe. AFAIK, both interpretation and compilation are 1-pass. > ;; -*- lexical-binding: t -*- > > (defvar testfun nil) > > (let ((x 1) f g) > (defvar x) > (setq testfun (lambda () x))) > > (funcall testfun) > [...] you get 1 > I don't really see the connection to a `let' block: > the defvar is in a let block, but the variable is > not treated as special in the block. Yes, but the let-binding happened before the defvar. > ;; -*- lexical-binding: t -*- > > (defvar testfun nil) > > (progn > (defvar x) > (let ((x 1) f g) > (setq testfun (lambda () x)))) > > (funcall testfun) > [...] gives you an error. > [the defvar is] outside, but the variable is treated as special > (though the extent is surely not limited to any `let' block). Right, because the defvar is not inside any let-block, so it applies to the rest of the file. Compare ;; -*- lexical-binding: t -*- (progn (defvar x)) (let ((x 1)) (setq testfun (lambda () x))) (message "%S" (funcall testfun)) vs ;; -*- lexical-binding: t -*- (let (_) (defvar x)) (let ((x 1)) (setq testfun (lambda () x))) (message "%S" (funcall testfun)) I noticed doing (let () (defvar x)) seems to be the same as (progn (defvar x)), which may be a bug.