From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp and Guile Date: Fri, 2 Aug 2002 11:43:46 -0600 (MDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200208021743.g72HhkX01596@aztec.santafe.edu> References: <200207200035.g6K0ZAb27891@aztec.santafe.edu> <200207212015.g6LKF4c00874@aztec.santafe.edu> <200207251807.g6PI75d07615@aztec.santafe.edu> <874renlito.fsf@zagadka.ping.de> <200207271853.g6RIre710837@aztec.santafe.edu> <200207310554.g6V5ssc16508@aztec.santafe.edu> Reply-To: rms@gnu.org NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1028310221 1206 127.0.0.1 (2 Aug 2002 17:43:41 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 2 Aug 2002 17:43:41 +0000 (UTC) Cc: neil@ossau.uklinux.net, raeburn@raeburn.org, emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17agSi-0000JL-00 for ; Fri, 02 Aug 2002 19:43:40 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17aglz-000540-00 for ; Fri, 02 Aug 2002 20:03:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17agT7-0001sI-00; Fri, 02 Aug 2002 13:44:05 -0400 Original-Received: from pele.santafe.edu ([192.12.12.119]) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17agSq-0001pL-00; Fri, 02 Aug 2002 13:43:48 -0400 Original-Received: from aztec.santafe.edu (aztec [192.12.12.49]) by pele.santafe.edu (8.11.6+Sun/8.11.6) with ESMTP id g72Hhw518707; Fri, 2 Aug 2002 11:43:58 -0600 (MDT) Original-Received: (from rms@localhost) by aztec.santafe.edu (8.10.2+Sun/8.9.3) id g72HhkX01596; Fri, 2 Aug 2002 11:43:46 -0600 (MDT) X-Authentication-Warning: aztec.santafe.edu: rms set sender to rms@aztec using -f Original-To: marius.vollmer@uni-dortmund.de In-Reply-To: (message from Marius Vollmer on 01 Aug 2002 21:39:29 +0200) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:6252 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:6252 > In plain Scheme, you use 'dynamic-wind' to establish a dynamic > context. Entering and leaving that context will run specified > procedures that can swap values in and out of variables that should > have dynamically scoped values. > > It is very undesirable for Lisp dynamic variables to be different > from Scheme dynamic variables. It makes the system specs incoherent. There really aren't dynamic Scheme variables (in the sense that there are dynamic 'special' variables in Common Lisp). I know that. Variables with dynamic bindings are dynamic variables even if they are not a special kind of variable. Emacs Lisp also has only one kind of variable. It is not like Common Lisp. This is why I propose extending the dynamic-wind mechanism to handle various kinds of context-local bindings. > Is it possible to extend dynamic-wind so that it can handle > buffer-local, frame-local, etc. contexts? No, dynamic-wind is only for control flow. At present, the dynamic-wind mechanism only works with control flow. I am proposing to generalize the mechanism so that it implements various selectable "local" contexts (current buffer, selected frame, etc.). What exactly the API should look like, I am not venturing to say. You normally hide these things behind some functions. That won't work here. Emacs Lisp has hundreds of dynamic variables, whose names are documented, that user programs examine, set, and bind. It would be clumsy and impractical to hide each of these variables behind a separate function in Scheme. It would be practical but clumsy to have a few Scheme functions for accessing and binding Lisp variables. That would make Scheme very inconvenient to use, compared with Emacs Lisp. The clean approach is that each of these Lisp variables is simply a Scheme variable. What about exporting all Elisp variables to Scheme as settable functions? For example (set! (require-final-newline) 'ask) This would lead to a divergence between Scheme variables and Lisp variables, but I don't think this is bad. I think it is ugly--variables should remain variables. However, we could have something like it for buffer-local contexts, say 'buffer-wind'. That is, we could have a way to specify hooks that are run whenever the value of (current-buffer) changes. The hooks would then install the right values in the variables that are supposed to behave buffer-locally. Perhaps this is what we should do. However, these local contexts should not be associated specifically with buffers. There should be a list of current local contexts, which the user program can use for different purposes. Emacs would use one for the current buffer's bindings, and one for the current frame's bindings. It is necessary for the mechanism that handles let-style dynamic scope to know something about these contexts as well. If they don't know about each other, they will get confused in certain cases, with bindings being swapped out into the wrong place. Those bugs used to exist in Emacs but we fixed them. Essentially, it is necessary to label each variable by saying which local context its current binding belongs to. I'm afraid this might turn out to be expensive and it is not a good solution in a multi-threaded system. It does not have to be expensive. Although Emacs is not multi-threaded, it has an optimization for this: a variable's buffer-local bindings are not swapped until you try to access the variable. Runnning another thread for a short time, if it does not access many of these variables, won't have to swap many of them. Fluids provide thread-local storage and dynamic-wind is used to swap values in and out of these locations to establish dynamic contexts. Are you saying that dynamic-wind can't be used directly to swap values in and out of a variable, that you have to set the variable to a fluid and use dynamic-wind to swap values in and out of the fluid? Or are you saying that dynamic-wind can be used either to swap values in and out of a variable, or to swap values in and out of a fluid? Do fluids have an optimized mechanism like the one I described above for Emacs buffer-local variables? Or does each access to a fluid look up the binding for the current thread? Given that optimized mechanism, I think threa-local variable values (as distinct from use of fluids) would be a natural and useful feature. There might be no need any more for fluids.