From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Why is Elisp's defvar weird? And is eval_sub broken? Date: Mon, 16 Feb 2015 02:40:19 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1424072469 11110 80.91.229.3 (16 Feb 2015 07:41:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Feb 2015 07:41:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kelly Dean Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 16 08:41:00 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YNGIc-0005i6-F6 for ged-emacs-devel@m.gmane.org; Mon, 16 Feb 2015 08:40:58 +0100 Original-Received: from localhost ([::1]:37965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNGIb-0007Q0-6w for ged-emacs-devel@m.gmane.org; Mon, 16 Feb 2015 02:40:57 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNGIN-0007Pu-Rz for emacs-devel@gnu.org; Mon, 16 Feb 2015 02:40:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNGIK-00030z-Lw for emacs-devel@gnu.org; Mon, 16 Feb 2015 02:40:43 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:45523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNGIK-0002zp-BG for emacs-devel@gnu.org; Mon, 16 Feb 2015 02:40:40 -0500 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t1G7eZ8j001364; Mon, 16 Feb 2015 02:40:36 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id DFB592818; Mon, 16 Feb 2015 02:40:19 -0500 (EST) In-Reply-To: (Kelly Dean's message of "Mon, 16 Feb 2015 05:42:38 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5218=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5218> : inlines <2184> : streams <1391073> : uri <1856403> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183147 Archived-At: > If Elisp's defvar with no init value is used, then it avoids conflict, but > the packages that are a problem in the first place (by declaring > non-package-prefixed symbols special) will also be ones that tend to use > defvar _with_ an init value (so the symbols really are declared special, = and > their defvars are in the elc). Elisp's defvar doesn't prevent conflict in > that case, so it seems the local-specialness feature doesn't fulfill its > intended purpose. That's indeed a risk, but it's one that's a lot easier to manage. > In contrast, llet would prevent conflict in that case. Right, you can introduce llet and llet* and then some more l for macros that expand to uses of `let' or `let*' and .... Or you can take a page from Common-Lisp's book and run with it. I chose the second option. It's not perfect, but so far I don't regret it. > (Global) specialness ambushes code that uses Lisp's standard =ABlet=BB, b= ecause > =ABlet=BB lets outside code decide how to bind the symbols. That's true, which is why I added the annoying warnings to `defvar' when the symbol seems not to use a prefix. > And it happens to be faster. It should make 0 difference to byte-compiled code and I don't care much about the speed of the non-byte-compiled code. > And dlet is a faster way of doing what you can currently do in Elisp using > defvar (with no init value) followed by standard =ABlet=BB. Again: no speed difference in byte-compiled code. >> There is such a declaration already. It's called (defvar ). Tada! > Yes, though using defvar for this declaration in the function also causes > local specialness, when all that's needed in this case is just to tell the > byte compiler that the variables aren't mistakes. Using the same identifiers sometimes as a lexical var and sometimes as a dynamic var is evil for the poor human reader. Si I have no intention to try and refine the semantics of such cases. Stefan