11 |
* Asyncs:: Asynchronous procedure invocation. |
* Asyncs:: Asynchronous procedure invocation. |
12 |
* Dynamic Roots:: Root frames of execution. |
* Dynamic Roots:: Root frames of execution. |
13 |
* Threads:: Multiple threads of execution. |
* Threads:: Multiple threads of execution. |
14 |
* Fluids:: Dynamically scoped variables. |
* Fluids:: Thread-local variables. |
15 |
@end menu |
@end menu |
16 |
|
|
17 |
|
|
392 |
executed in separate dynamic roots, fluids can be used for thread local |
executed in separate dynamic roots, fluids can be used for thread local |
393 |
storage (@pxref{Threads}). |
storage (@pxref{Threads}). |
394 |
|
|
395 |
Fluids can be used to simulate dynamically scoped variables. These are |
Fluids can be used to simulate the desirable effects of dynamically |
396 |
used in several (especially in older) dialects of lisp, such as in Emacs |
scoped variables. Dynamically scoped variables are useful when you |
397 |
Lisp, and they work a bit like global variables in that they can be |
want to set a variable to a value during some dynamic extent in the |
398 |
modified by the caller of a procedure, and the called procedure will see |
execution of your program and have them revert to their original value |
399 |
the changes. With lexically scoped variables---which are normally used |
when the control flow is outside of this dynamic extent. See the |
400 |
in Scheme---this cannot happen. See the description of |
description of @code{with-fluids} below for details. |
401 |
@code{with-fluids*} below for details. |
|
402 |
|
New fluids are created with @code{make-fluid} and @code{fluid?} is |
403 |
New fluids are created with @code{make-fluid} and @code{fluid?} is used |
used for testing whether an object is actually a fluid. The values |
404 |
for testing whether an object is actually a fluid. |
stored in a fluid can be accessed with @code{fluid-ref} and |
405 |
|
@code{fluid-set!}. |
406 |
|
|
407 |
@deffn {Scheme Procedure} make-fluid |
@deffn {Scheme Procedure} make-fluid |
408 |
@deffnx {C Function} scm_make_fluid () |
@deffnx {C Function} scm_make_fluid () |
421 |
@code{#f}. |
@code{#f}. |
422 |
@end deffn |
@end deffn |
423 |
|
|
|
The values stored in a fluid can be accessed with @code{fluid-ref} and |
|
|
@code{fluid-set!}. |
|
|
|
|
424 |
@deffn {Scheme Procedure} fluid-ref fluid |
@deffn {Scheme Procedure} fluid-ref fluid |
425 |
@deffnx {C Function} scm_fluid_ref (fluid) |
@deffnx {C Function} scm_fluid_ref (fluid) |
426 |
Return the value associated with @var{fluid} in the current |
Return the value associated with @var{fluid} in the current |
440 |
@deffn {Scheme Procedure} with-fluids* fluids values thunk |
@deffn {Scheme Procedure} with-fluids* fluids values thunk |
441 |
@deffnx {C Function} scm_with_fluids (fluids, values, thunk) |
@deffnx {C Function} scm_with_fluids (fluids, values, thunk) |
442 |
Set @var{fluids} to @var{values} temporary, and call @var{thunk}. |
Set @var{fluids} to @var{values} temporary, and call @var{thunk}. |
443 |
@var{fluids} must be a list of fluids and @var{values} must be the same |
@var{fluids} must be a list of fluids and @var{values} must be the |
444 |
number of their values to be applied. Each substitution is done |
same number of their values to be applied. Each substitution is done |
445 |
one after another. @var{thunk} must be a procedure with no argument. |
in the order given. @var{thunk} must be a procedure with no argument. |
446 |
|
it is called inside a @code{dynamic-wind} and the fluids are |
447 |
|
set/restored when control enter or leaves the established dynamic |
448 |
|
extent. |
449 |
@end deffn |
@end deffn |
450 |
|
|
451 |
|
@deffn {Scheme Macro} with-fluids ((fluid value) ...) body... |
452 |
|
Execute @var{body...} while each @var{fluid} is set to the |
453 |
|
corresponding @var{value}. Both @var{fluid} and @var{value} are |
454 |
|
evaluated and @var{fluid} must yield a fluid. @var{body...} is |
455 |
|
executed inside a @code{dynamic-wind} and the fluids are set/restored |
456 |
|
when control enter or leaves the established dynamic extent. |
457 |
|
@end deffn |
458 |
|
|
459 |
@c Local Variables: |
@c Local Variables: |
460 |
@c TeX-master: "guile.texi" |
@c TeX-master: "guile.texi" |