all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marius Vollmer <mvo@zagadka.ping.de>
Cc: neil@ossau.uklinux.net, raeburn@raeburn.org, emacs-devel@gnu.org
Subject: Re: Emacs Lisp and Guile
Date: 19 Aug 2002 22:54:13 +0200	[thread overview]
Message-ID: <87fzxazi16.fsf@zagadka.ping.de> (raw)
In-Reply-To: <200208151953.g7FJruJ07836@wijiji.santafe.edu>

Richard Stallman <rms@gnu.org> writes:

>     There is a nearly standard macro out there called 'fluid-let' that
>     encapsulates the process completely.  For example
> 
> It looks like the right idea, though the name is confusing given that
> it does not use fluids.  Since the name fluid-let seems to be widely
> known, perhaps fluids should be given a different name.

Yes, we could do that.  We could also try to generalize the fluids so
that they can be 'local' to other contexts besides threads, like
buffers or frames.  Or, since we might use variables for buffer-local
things, we could remove fluids and use the new features of variables
to have real thread-local variables.

>     > These functions could also have code for correct interaction with
>     > buffer-local bindings and frame-local bindings.
> 
>     Does this refer to the fact that buffer-localness and frame-localness
>     are not completely independent from dynamic scoping?
> 
> The point is, if the value that was saved by fluid-let came from a
> buffer-local binding, it needs to restore that value into the same
> buffer-local binding.  If the value that was saved was from the
> buffer-global binding, fluid-let needs to restore that value into the
> buffer-global binding.  The expansion of fluid-let needs extra code
> both when saving and when restoring, to do this.

I see, thanks.

> 							  What would need
>     to change in the above example when case-fold-search would be a
>     buffer-local variable?
> 
> I am too overloaded to try to write the code (and I'd have to restudy
> Scheme too).  Is my explanation above clear?

Yes.  (I thought you might enjoy a little bit of programming here and
there... :-)

> This needs to be done for all variables, since any might perhaps be
> made buffer-local.  fluid-let could expand into the proper code for
> this.

We should probably tackle this as the larger, more general problem of
working with arbitrary 'contexts' and variable-like 'entities'
(variables, or fluids, or settable functions, or...) that can take on
context-local values.  Let's call these entities "locations".

A particular context could then be specified by naming a location that
will hold the 'current context'.  For example, the location that
points to the current buffer is used to specify the context for
'buffer-local' locations.  The location that points to the current
thread is used for thread-local variables.

Thus, a location is characterized by its identity, and a reference to
another location that holds its context.  That reference is #f (or
nil) when the location is currently global.

The values of locations could be (conceptually) stored in a data base
that is indexed with keys that are the combination of a location and
another arbitrary value.

'Setting' a location LOC to the value VAL goes like this: when the
context reference is #f, store VAL with the key (LOC . #f).  When the
reference is not #f, 'get' the value CTXT of the referenced location
and store VAL with the key (LOC . CTXT).

'Getting' a location LOC means looking up the key (LOC . #f) when the
context reference is #f, or first 'getting' the value CTXT of the
referenced location and looking up the key (LOC . CTXT).

There would also be a way to set the context reference of a location,
of course.

fluid-let would then remember the (LOC . CTXT) key and would swap
according to that key.

With the above model, we can have buffer-local variables where the
curren-buffer variable is itself thread-local, for example.  We could
not have the situation where a variable is buffer-local in one thread
and frame-local in another (that is, where the context reference of a
location is itself stored in a location).  Maybe we can generalize the
model, or maybe we don't want to.

The real implementation can use the optimizations that Emacs currently
uses for its buffer-local etc variables.

(I like the name 'with' better instead of 'fluid-let'.  It goes with
'with-input-from-file', which sets the current-input-port in a dynamic
extent, for example.  But fluid-let is better known.)

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405

  reply	other threads:[~2002-08-19 20:54 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
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 [this message]
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

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

  git send-email \
    --in-reply-to=87fzxazi16.fsf@zagadka.ping.de \
    --to=mvo@zagadka.ping.de \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.