unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
Cc: neil@ossau.uklinux.net, raeburn@raeburn.org, emacs-devel@gnu.org
Subject: Re: Emacs Lisp and Guile
Date: Fri, 2 Aug 2002 11:43:46 -0600 (MDT)	[thread overview]
Message-ID: <200208021743.g72HhkX01596@aztec.santafe.edu> (raw)
In-Reply-To: <ljvg6u4bda.fsf@burns.dt.e-technik.uni-dortmund.de> (message from Marius Vollmer on 01 Aug 2002 21:39:29 +0200)

    >     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.

  parent reply	other threads:[~2002-08-02 17:43 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-20  0:35 Emacs Lisp and Guile Richard Stallman
2002-07-20  8:37 ` Neil Jerram
2002-07-21 20:15   ` Richard Stallman
2002-07-24 22:05     ` Neil Jerram
2002-07-25 18:07       ` Richard Stallman
2002-07-25 19:16         ` Marius Vollmer
2002-07-27 18:53           ` Richard Stallman
2002-07-30 12:20             ` Marius Vollmer
2002-07-31  5:54               ` Richard Stallman
2002-08-01 19:39                 ` Marius Vollmer
2002-08-01 20:52                   ` Kai Großjohann
2002-08-02 10:23                     ` Marius Vollmer
2002-08-02 10:41                       ` Kai Großjohann
2002-08-02 12:09                         ` Marius Vollmer
2002-08-02 12:37                           ` Kai Großjohann
2002-08-05 15:19                             ` Marius Vollmer
2002-08-02 22:14                           ` Richard Stallman
2002-08-02 22:53                             ` Sam Steingold
2002-08-03 15:38                               ` Simon Josefsson
2002-08-03 16:15                                 ` Sam Steingold
2002-08-03 19:35                                   ` Lars Magne Ingebrigtsen
2002-08-03 20:33                                 ` Kai Großjohann
2002-08-03 20:40                                   ` Simon Josefsson
2002-08-03 22:41                                     ` Sam Steingold
2002-08-04  5:14                                     ` Eli Zaretskii
2002-08-04 23:26                                 ` Richard Stallman
2002-08-05 15:58                                   ` Sam Steingold
2002-08-09 18:02                                   ` Alex Schroeder
2002-08-11  3:54                                     ` Richard Stallman
2002-08-04 23:25                               ` Richard Stallman
2002-08-05 16:10                                 ` Sam Steingold
2002-08-10  7:17                                   ` Noah Friedman
2002-08-10 14:01                                     ` Alex Schroeder
2002-08-11 16:52                                     ` Sam Steingold
2002-08-02 17:43                   ` Richard Stallman [this message]
2002-08-05 16:08                     ` Marius Vollmer
2002-08-07 14:24                       ` Richard Stallman
2002-08-08 16:35                         ` Marius Vollmer
2002-08-09 16:39                           ` Richard Stallman
2002-08-12 14:51                             ` Marius Vollmer
2002-08-13  1:47                               ` Richard Stallman
2002-08-13 19:13                                 ` Marius Vollmer
2002-08-14  5:15                                   ` Richard Stallman
2002-08-14 18:26                                     ` Marius Vollmer
2002-08-15 19:53                                       ` Richard Stallman
2002-08-19 21:03                                         ` Marius Vollmer
2002-08-09  6:50                         ` Stefan Monnier
2002-08-10 17:16                           ` Richard Stallman
2002-08-07 14:24                       ` Richard Stallman
2002-08-07 15:38                         ` Simon Josefsson
2002-08-08  7:01                           ` Richard Stallman
2002-08-08 16:06                         ` Marius Vollmer
2002-08-09 16:39                           ` Richard Stallman
2002-08-12 13:40                             ` Marius Vollmer
2002-08-13  1:47                               ` Richard Stallman
2002-08-13 19:17                                 ` Marius Vollmer
2002-08-14  5:15                                   ` Richard Stallman
2002-08-14 18:21                                     ` Marius Vollmer
2002-08-10 14:32                     ` Michael Sperber [Mr.  Preprocessor]
2002-08-11  3:55                       ` Richard Stallman
2002-08-11  8:28                         ` Michael Sperber [Mr.  Preprocessor]
2002-08-12 17:05                           ` Richard Stallman
2002-08-13  6:58                             ` Michael Sperber [Mr.  Preprocessor]
     [not found]                             ` <ljr8h4803x.fsf@burns.dt.e-technik.uni-dortmund.de>
2002-08-13 22:47                               ` Richard Stallman
2002-08-14 18:50                                 ` Marius Vollmer
2002-08-15 19:53                                   ` Richard Stallman
2002-08-19 20:54                                     ` Marius Vollmer
2002-08-21  0:12                                       ` Richard Stallman
2002-07-28  8:17         ` Neil Jerram
2002-07-29 17:30           ` Richard Stallman
2002-07-25  4:22   ` Ken Raeburn
2002-11-05 23:28     ` Neil Jerram
2002-11-07  4:49       ` Richard Stallman
2002-11-07 20:32         ` Neil Jerram
2002-11-09 11:54           ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200208021743.g72HhkX01596@aztec.santafe.edu \
    --to=rms@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=neil@ossau.uklinux.net \
    --cc=raeburn@raeburn.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).