From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Declaring a local dynamic variable? Date: Fri, 27 Sep 2013 22:18:24 +0200 Organization: Informatimago Message-ID: <87zjqyyq5r.fsf@informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1380313214 14398 80.91.229.3 (27 Sep 2013 20:20:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Sep 2013 20:20:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 27 22:20:19 2013 Return-path: Envelope-to: geh-help-gnu-emacs@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 1VPeWQ-0002Sf-T9 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Sep 2013 22:20:19 +0200 Original-Received: from localhost ([::1]:38380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPeWQ-0007Rs-8q for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Sep 2013 16:20:18 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 87 Original-X-Trace: individual.net 4RYgpAB2GRFaSI6hlpydXgblc/6AEJ7gH17dcVnOdK9gBLBWzC Cancel-Lock: sha1:N2U3MWM1NWE0ZjRkY2QwYTE3MDAyNjUxY2NmNGFlNTE4MmE0OTNhNA== sha1:Rys/IUbNdNlJDDOcNBK9RCEd1Do= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:201403 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93672 Archived-At: Andreas Röhler writes: > Let's memorize Stefan's remark as a starting-point to work-on: > > " But if d1 and d2 are in two separate packages that know > nothing about each other but who happen to call each other through some > potentially twisted sequence of calls, they will still interfere, > because there's only (globally) one dynamic variable by that name." > > Would like to see such a twisted sequence and what makes it's different from a common bug. With (setq lexical-binding nil). Here is a case where it's a common bug: ;; -------- (defun p1-f () (let ((print-circle t)) (p2-g (function p1-h) '#1=(1 2 . #1#)))) (defun p1-h (data f) (print data) (funcall f)) ;; -------- (defun p2-g (p d) (let ((print-circle nil)) (funcall p '(1 2 3) (function p2-i)))) (defun p2-i (data) (print data)) ;; -------- Here is a case where it's not a common bug: ;; -------- (defun p1-f () (let ((be-careful t)) (p2-g (function p1-h) '#1=(1 2 . #1#)))) (defun p1-h (data f) (if be-careful (let ((print-circle t)) (print data)) (print data)) (funcall f)) ;; -------- (defun p2-g (p d) (let ((be-careful nil)) (funcall p '(1 2 3) (function p2-i)))) (defun p2-i (data) (if be-careful (let ((print-circle t)) (print data)) (print data))) ;; -------- The difference is that in the first case, there's a global definition for print-circle, while in the second case, the packages expect be-careful to be local special variables. You could use my macros and (declare (special be-careful)) in each package, and the bug would persist. However, it would NOT occur in Common Lisp, where you'd have (in-package "P1") and (in-package "P2") forms in front of each bodies of code, because you'd have actually TWO special symbols: p1::be-careful and p2::be-careful. The conclusion is that in emacs lisp you have to prefix ALL the symbols! Which clearly demonstrates a failure of the language. -- __Pascal Bourguignon__ http://www.informatimago.com/