From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Kraft Newsgroups: gmane.lisp.guile.devel Subject: Re: Elisp lexical-let Date: Wed, 22 Jul 2009 21:24:31 +0200 Message-ID: <4A67676F.9010905@domob.eu> References: <4A661B73.4090706@domob.eu> <4A66D7BF.5060606@domob.eu> <4A670D78.3040804@gentoo.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1248290667 30082 80.91.229.12 (22 Jul 2009 19:24:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Jul 2009 19:24:27 +0000 (UTC) Cc: Andy Wingo , Ken Raeburn , guile-devel , Neil Jerram To: "Marijn Schouten (hkBst)" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jul 22 21:24:20 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 1MThQJ-00013c-NU for guile-devel@m.gmane.org; Wed, 22 Jul 2009 21:24:20 +0200 Original-Received: from localhost ([127.0.0.1]:34718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MThQI-0002d1-Ss for guile-devel@m.gmane.org; Wed, 22 Jul 2009 15:24:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MThQB-0002cc-ET for guile-devel@gnu.org; Wed, 22 Jul 2009 15:24:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MThQ6-0002aN-Ql for guile-devel@gnu.org; Wed, 22 Jul 2009 15:24:10 -0400 Original-Received: from [199.232.76.173] (port=56319 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MThQ6-0002aD-AS for guile-devel@gnu.org; Wed, 22 Jul 2009 15:24:06 -0400 Original-Received: from taro.utanet.at ([213.90.36.45]:37938) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MThQ5-0001zU-RB for guile-devel@gnu.org; Wed, 22 Jul 2009 15:24:06 -0400 Original-Received: from patricia.xoc.tele2net.at ([213.90.36.9]) by taro.utanet.at with esmtp (Exim 4.69) (envelope-from ) id 1MThQ1-00056h-H5; Wed, 22 Jul 2009 21:24:01 +0200 Original-Received: from d86-33-51-101.cust.tele2.at ([86.33.51.101] helo=[192.168.1.18]) by patricia.xoc.tele2net.at with esmtpa (Exim 4.69) (envelope-from ) id 1MThQ1-0003Rq-AO; Wed, 22 Jul 2009 21:24:01 +0200 User-Agent: Thunderbird 2.0.0.0 (X11/20070425) In-Reply-To: <4A670D78.3040804@gentoo.org> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:8916 Archived-At: Hi Marijn, Marijn Schouten (hkBst) wrote: > Guile also has lexical and dynamic variables; the fluids[1]. Queinnec in his > book LiSP also describes a system that has (default) lexical and dynamic > variable, on page 44. In both cases to find the value of a non-default variable > a function is used. Translated to elisp where the situation is dynamic by > default you probably want something like `(lexical x)' to dereference the > lexical variable `x' and also lexical-set(q). > > It seems to me that only the dereferencing of variables is dynamic or lexical, > not the binding. Thus you don't even need lexical-let and `(lexical x)' would be > `x' found in the lexical environment (if it isn't found you can generate an > error) and `x' would be searched for in the dynamic environment. Does that make > sense? not only the dereferencing, but also the setting must be of a dynamic or lexical value; and at least in my Lisp code, setting is mostly done with let's, so at the same time as the "binding". So what you propose would then be to have a (lexical sym) for referencing and (lexical-set! sym value) for setting in lexical scope -- and then as a consequence also a lexical-let, that does let but sets to the provided values just as lexical-set! does...? Well, that's how I see it, anyways. And while your arguments seem quite reasonable (decide for each access of a symbol between lexical and dynamic), I think this creates a superfluous amount of confusion and "just" switching for certain variables to lexical binding within the scope of a lexical-let seems to me the better solution. What's about this: (defun test () a) (let ((a 1)) (print a) ; 1 (print (test)) ; 1 (lexical-set! a 2) (print a) ; 1? (print (test)) ; 1 (print (lexical a)) ; 2 ) I don't think it's good to have to "completely seperate" variables a and (lexical a). And besides, here there's no way to decide that no fluids at all are needed for a, as the let construct itself (except the references following) still creates a with-fluids* call. Yours, Daniel PS: From a performance point of view, I guess that the void checks on each variable access are far more expensive than the fluid/dynamic-scoping business. But I'll report on this (performance) maybe in a seperate posting when I've done some experiments and real data as well as suggestions. -- Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz To go: Hea-Kni-Mon-Pri