From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp and Guile Date: 30 Jul 2002 14:20:30 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: 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> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1028031723 19112 127.0.0.1 (30 Jul 2002 12:22:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 30 Jul 2002 12:22:03 +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 17ZW0o-0004y9-00 for ; Tue, 30 Jul 2002 14:22:02 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17ZWIW-0004Ek-00 for ; Tue, 30 Jul 2002 14:40:20 +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 17ZW1C-00039H-00; Tue, 30 Jul 2002 08:22:26 -0400 Original-Received: from krusty.dt.e-technik.uni-dortmund.de ([129.217.163.1] helo=mail.dt.e-technik.uni-dortmund.de) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17ZW0M-000318-00; Tue, 30 Jul 2002 08:21:34 -0400 Original-Received: from burns.dt.e-technik.uni-dortmund.de (burns.dt.e-technik.uni-dortmund.de [129.217.163.19]) by mail.dt.e-technik.uni-dortmund.de (Postfix) with ESMTP id 4A959A3831; Tue, 30 Jul 2002 14:21:33 +0200 (CEST) Original-Received: by burns.dt.e-technik.uni-dortmund.de (Postfix, from userid 520) id B742EF42F; Tue, 30 Jul 2002 14:20:31 +0200 (CEST) Original-To: rms@gnu.org In-Reply-To: <200207271853.g6RIre710837@aztec.santafe.edu> Original-Lines: 51 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 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:6176 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:6176 Richard Stallman writes: > When that is the case, we need to treat Elisp variable references > differently from Scheme variable references. In Scheme, we only look > up the storage location of a variable once and then each reference is > only a simple memory access. > > I guess so. But one question is, what would a reference to a "Lisp" > variable look like in Scheme? Would you have to call a special > function to get or set the value? Yes, probably, as far as I can see. I don't think this is a problem, tho. A call to that special function can be very fast when needed. For example, when we should get serious about compilation to machine code, we will want to inline certain operations, like arithmetic on fixnums, and the call to the special Elisp-variable-accessor-function can be one of these operations. For a bytecode interpreter (or similar), we will likewise want to have special opcodes for these kind of things. > Scheme variables are normally lexical. What do people normally do in > Scheme when you want a dynamically scoped value? 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. We also have '@bind' which does just this but more efficiently. In Guile, we also have 'fluids'. A fluid is a normal object like a cons pair that holds one object per thread. That is, fluids are our mechanism for thread local variables. There is also support for efficiently creating dynamic contexts that will swap the value of a fluid with a backing store when entered/left. > (define var (make-fluid)) > (define (peek-var) (peek (fluid-ref var))) > (fluid-set! var 12) > var => # > (peek-var) ;;; 12 > (with-fluids ((var 23)) (peek-var)) ;;; 23 > (peek-var) ;;; 12 The "5" in # is just an index, not the value of the fluid.