From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Marijn Schouten (hkBst)" Newsgroups: gmane.lisp.guile.devel Subject: Re: Elisp lexical-let Date: Fri, 24 Jul 2009 13:09:03 +0200 Message-ID: <4A69964F.5040008@gentoo.org> References: <4A661B73.4090706@domob.eu> <4A66D7BF.5060606@domob.eu> <4A670D78.3040804@gentoo.org> <4A67676F.9010905@domob.eu> <4A6880AE.9070600@gentoo.org> <4A68986A.20006@domob.eu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1248434465 25480 80.91.229.12 (24 Jul 2009 11:21:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Jul 2009 11:21:05 +0000 (UTC) Cc: Andy Wingo , Ken Raeburn , guile-devel , Neil Jerram To: Daniel Kraft Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jul 24 13:20:57 2009 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MUIpY-0000Tn-6f for guile-devel@m.gmane.org; Fri, 24 Jul 2009 13:20:53 +0200 Original-Received: from localhost ([127.0.0.1]:55477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUIpX-00038Y-E0 for guile-devel@m.gmane.org; Fri, 24 Jul 2009 07:20:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MUInQ-0000aH-3j for guile-devel@gnu.org; Fri, 24 Jul 2009 07:18:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MUInK-0000PY-Va for guile-devel@gnu.org; Fri, 24 Jul 2009 07:18:39 -0400 Original-Received: from [199.232.76.173] (port=43919 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUInK-0000P0-Np for guile-devel@gnu.org; Fri, 24 Jul 2009 07:18:34 -0400 Original-Received: from pollux.sshunet.nl ([145.97.192.42]:58261) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MUInK-0001CB-4s for guile-devel@gnu.org; Fri, 24 Jul 2009 07:18:34 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by pollux.sshunet.nl (Postfix) with ESMTP id 03D9E580005; Fri, 24 Jul 2009 13:18:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at pollux.warande.net Original-Received: from pollux.sshunet.nl ([127.0.0.1]) by localhost (pollux.sshunet.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JRNfxZIBm6Ag; Fri, 24 Jul 2009 13:18:24 +0200 (CEST) Original-Received: from [145.97.223.194] (194pc223.sshunet.nl [145.97.223.194]) by pollux.sshunet.nl (Postfix) with ESMTP; Fri, 24 Jul 2009 13:18:24 +0200 (CEST) User-Agent: Thunderbird 2.0.0.22 (X11/20090723) In-Reply-To: <4A68986A.20006@domob.eu> X-Enigmail-Version: 0.95.7 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:8961 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Daniel Kraft wrote: > Hi, > > thanks for your comments; I'm still a bit confused, though :$ > > Marijn Schouten (hkBst) wrote: >>> What's about this: >>> >>> (defun test () a) >>> (let ((a 1)) >>> (print a) ; 1 >>> (print (test)) ; 1 >>> (lexical-set! a 2) >> there is only one variable `a' in my mental model, >> so this changes the value of the only `a' and all >> subsequent expressions accessing `a' are thus affected. >> The same as if you had written `(set! a 2)'. Dynamic >> and lexical only differ in how free variables in >> procedures are bound. >>> (print a) ; 1? >> no, (print a) => 2 >>> (print (test)) ; 1 >> no, there is only one `a' and its value is 2 here >>> (print (lexical a)) ; 2 >>> ) > > Hm... my problem is trying to understand how you want this implemented; > my main point about lexical scoping is that it enables us to use Guile's > built-in lexical mechanisms and we don't have to save the value > explicitly into some fluids. > > But if you require that the second (print (test)) above prints 1 even > though we have done (lexical-set! a) this means that lexical-set! must > update the place somehow where a is accessed dynamically (as is done in > test). And that seems to imply that this lexical-set! updates the > fluids, even though it is meant to perform on a lexically bound variable > a; just in case that "the one" a is at some place referred to dynamically. In my proposal it is meaningless to say "lexically bound variable", as all variables would in principal be accessible both lexically and dynamically. >>> I don't think it's good to have to "completely seperate" variables a and >>> (lexical a). >> >> I don't understand what you mean. My proposal is to have one kind of >> variable >> and two kinds of access. > > Can you please elaborate on this? If there's only one variable and only > the value 2 after the lexical-set! above (both for (print a) in the > lexical scope and (print (test)) which accesses a dynamically), what > would then be the point of writing 'a' or '(lexical a)' and what would > be the difference between those two? (defvar x 3) (defun dynx () x) (dynx) ; => 3 (defun lexx () (lexical x)) (lexx) ; => 3 (defun incdynx () (setq x (+ x 1))) (defun inclexx () (lexical-setq x (+ (lexical x) 1))) (let ((x 5)) (dynx) ; => 5 (lexx) ; => 3 (lexical-setq x 6) (dynx) ; => 6 (lexx) ; => 3 (setq x 7) (dynx) ; => 7 (lexx) ; => 3 (incdynx) (dynx) ; => 8 (lexx) ; => 3 (inclexx) (dynx) ; => 8 (lexx) ; => 4 ) (dynx) ; => 4 (lexx) ; => 4 (incdynx) (dynx) ; => 5 (lexx) ; => 5 (inclexx) (dynx) ; => 6 (lexx) ; => 6 I hope I haven't made any mistakes there and that it explains what I have in mind. Marijn - -- If you cannot read my mind, then listen to what I say. Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML , #gentoo-{lisp,ml} on FreeNode -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpplk8ACgkQp/VmCx0OL2wFVACfV36PIQRwjQu3gGOc8Rly6h8Z UKQAnA5yPPMBNJsoRoc70+5znTP10r6G =SL2/ -----END PGP SIGNATURE-----