[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs Lisp and Guile
Re: Emacs Lisp and Guile
30 Jul 2002 14:20:30 +0200
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1
Richard Stallman <address@hidden> 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
> 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)
=> #<fluid 5>
> (with-fluids ((var 23))
The "5" in #<fluid 5> is just an index, not the value of the fluid.
Re: Emacs Lisp and Guile, Ken Raeburn, 2002/07/25
- Emacs Lisp and Guile, Richard Stallman, 2002/07/19
- Re: Emacs Lisp and Guile, Neil Jerram, 2002/07/20
- Re: Emacs Lisp and Guile, Richard Stallman, 2002/07/21
- Re: Emacs Lisp and Guile, Neil Jerram, 2002/07/24
- Re: Emacs Lisp and Guile, Richard Stallman, 2002/07/25
- Re: Emacs Lisp and Guile, Marius Vollmer, 2002/07/25
- Re: Emacs Lisp and Guile, Richard Stallman, 2002/07/27
- Re: Emacs Lisp and Guile,
Marius Vollmer <=
- Re: Emacs Lisp and Guile, Richard Stallman, 2002/07/31
- Re: Emacs Lisp and Guile, Neil Jerram, 2002/07/28
- Re: Emacs Lisp and Guile, Richard Stallman, 2002/07/29