1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 09:10:22 +02:00

Exchange of manual enhancements between stable and unstable branches.

This commit is contained in:
Neil Jerram 2002-03-27 21:48:16 +00:00
parent 890f4dd7e3
commit 6dd447a368
12 changed files with 479 additions and 2901 deletions

View file

@ -1,8 +1,34 @@
2002-03-27 Neil Jerram <neil@ossau.uklinux.net>
* Makefile.am (guile_TEXINFOS): Remove appendices.texi, add
debugging.texi.
2002-03-24 Neil Jerram <neil@ossau.uklinux.net> 2002-03-24 Neil Jerram <neil@ossau.uklinux.net>
* scheme-data.texi (Pairs, Lists, Vectors, Records, Structures,
Arrays, Association Lists and Hash Tables): Move into a new
chapter ...
(Data Types): Renamed `Simple Data Types'; improvements ported
from unstable branch.
(Symbols and Variables): Renamed `Symbols'; improvements ported
from unstable branch. `Variables' subsection moved to
scheme-modules.texi.
* scheme-compound.texi: New file.
* scheme-data.texi (Rx Regexps): Move section so that it becomes a
chapter in misc-modules.texi, in the Modules section of the manual.
* guile.texi (Top): Remove anything to do with appendices, as
there's no appendix material anymore.
* appendices.texi (Debugger User Interface): Moved to non-appendix
chapter in Part II; file renamed `debugging.texi'.
* guile.texi (Top), intro.texi (What is Guile?, The Basic Guile * guile.texi (Top), intro.texi (What is Guile?, The Basic Guile
Package): Use @ifnottex instead of @ifinfo, so that HTML Package): Use @ifnottex instead of @ifinfo, so that HTML
generation works correctly. generation works correctly.
(Top): Move scheme-indices.texi after other indices at end.
2002-03-20 Marius Vollmer <mvo@zagadka.ping.de> 2002-03-20 Marius Vollmer <mvo@zagadka.ping.de>

View file

@ -31,7 +31,7 @@ guile_TEXINFOS = preface.texi intro.texi scheme-intro.texi \
scheme-translation.texi scheme-debug.texi deprecated.texi \ scheme-translation.texi scheme-debug.texi deprecated.texi \
scheme-reading.texi scheme-indices.texi slib.texi posix.texi \ scheme-reading.texi scheme-indices.texi slib.texi posix.texi \
expect.texi scsh.texi tcltk.texi scripts.texi gh.texi scm.texi \ expect.texi scsh.texi tcltk.texi scripts.texi gh.texi scm.texi \
appendices.texi indices.texi script-getopt.texi data-rep.texi \ debugging.texi indices.texi script-getopt.texi data-rep.texi \
autoconf.texi autoconf-macros.texi tools.texi \ autoconf.texi autoconf-macros.texi tools.texi \
extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi

View file

@ -1,177 +0,0 @@
@page
@node Debugger User Interface
@appendix Debugger User Interface
@c --- The title and introduction of this appendix need to
@c distinguish this clearly from the chapter on the internal
@c debugging interface.
When debugging a program, programmers often find it helpful to examine
the program's internal status while it runs: the values of internal
variables, the choices made in @code{if} and @code{cond} statements, and
so forth. Guile Scheme provides a debugging interface that programmers
can use to single-step through Scheme functions and examine symbol
bindings. This is different from the @ref{Debugging}, which permits
programmers to debug the Guile interpreter itself. Most programmers
will be more interested in debugging their own Scheme programs than the
interpreter which evaluates them.
[FIXME: should we include examples of traditional debuggers
and explain why they can't be used to debug interpreted Scheme or Lisp?]
@menu
* Single-Step:: Execute a program or function one step at a time.
* Trace:: Print a report each time a given function is called.
* Backtrace:: See a list of the statements that caused an error.
* Stacks and Frames:: Examine the state of an interrupted program.
@end menu
@node Single-Step
@appendixsec Single-Step
@node Trace
@appendixsec Trace
When a function is @dfn{traced}, it means that every call to that
function is reported to the user during a program run. This can help a
programmer determine whether a function is being called at the wrong
time or with the wrong set of arguments.
@defun trace function
Enable debug tracing on @code{function}. While a program is being run, Guile
will print a brief report at each call to a traced function,
advising the user which function was called and the arguments that were
passed to it.
@end defun
@defun untrace function
Disable debug tracing for @code{function}.
@end defun
Example:
@lisp
(define (rev ls)
(if (null? ls)
'()
(append (rev (cdr ls))
(cons (car ls) '())))) @result{} rev
(trace rev) @result{} (rev)
(rev '(a b c d e))
@result{} [rev (a b c d e)]
| [rev (b c d e)]
| | [rev (c d e)]
| | | [rev (d e)]
| | | | [rev (e)]
| | | | | [rev ()]
| | | | | ()
| | | | (e)
| | | (e d)
| | (e d c)
| (e d c b)
(e d c b a)
(e d c b a)
@end lisp
Note the way Guile indents the output, illustrating the depth of
execution at each function call. This can be used to demonstrate, for
example, that Guile implements self-tail-recursion properly:
@lisp
(define (rev ls sl)
(if (null? ls)
sl
(rev (cdr ls)
(cons (car ls) sl)))) @result{} rev
(trace rev) @result{} (rev)
(rev '(a b c d e) '())
@result{} [rev (a b c d e) ()]
[rev (b c d e) (a)]
[rev (c d e) (b a)]
[rev (d e) (c b a)]
[rev (e) (d c b a)]
[rev () (e d c b a)]
(e d c b a)
(e d c b a)
@end lisp
Since the tail call is effectively optimized to a @code{goto} statement,
there is no need for Guile to create a new stack frame for each
iteration. Using @code{trace} here helps us see why this is so.
@node Backtrace
@appendixsec Backtrace
@node Stacks and Frames
@appendixsec Stacks and Frames
When a running program is interrupted, usually upon reaching an error or
breakpoint, its state is represented by a @dfn{stack} of suspended
function calls, each of which is called a @dfn{frame}. The programmer
can learn more about the program's state at the point of interruption by
inspecting and modifying these frames.
@deffn {Scheme Procedure} stack? obj
Return @code{#t} if @var{obj} is a calling stack.
@end deffn
@deffn {Scheme Procedure} make-stack
@end deffn
@deffn syntax start-stack id exp
Evaluate @var{exp} on a new calling stack with identity @var{id}. If
@var{exp} is interrupted during evaluation, backtraces will not display
frames farther back than @var{exp}'s top-level form. This macro is a
way of artificially limiting backtraces and stack procedures, largely as
a convenience to the user.
@end deffn
@deffn {Scheme Procedure} stack-id stack
Return the identifier given to @var{stack} by @code{start-stack}.
@end deffn
@deffn {Scheme Procedure} stack-ref
@end deffn
@deffn {Scheme Procedure} stack-length
@end deffn
@deffn {Scheme Procedure} frame?
@end deffn
@deffn {Scheme Procedure} last-stack-frame
@end deffn
@deffn {Scheme Procedure} frame-number
@end deffn
@deffn {Scheme Procedure} frame-source
@end deffn
@deffn {Scheme Procedure} frame-procedure
@end deffn
@deffn {Scheme Procedure} frame-arguments
@end deffn
@deffn {Scheme Procedure} frame-previous
@end deffn
@deffn {Scheme Procedure} frame-next
@end deffn
@deffn {Scheme Procedure} frame-real?
@end deffn
@deffn {Scheme Procedure} frame-procedure?
@end deffn
@deffn {Scheme Procedure} frame-evaluating-args?
@end deffn
@deffn {Scheme Procedure} frame-overflow
@end deffn

View file

@ -94,7 +94,7 @@ by the Free Software Foundation.
@sp 10 @sp 10
@comment The title is printed in a large font. @comment The title is printed in a large font.
@title Guile Reference Manual @title Guile Reference Manual
@subtitle $Id: guile.texi,v 1.2.2.12 2002-03-24 19:07:08 ossau Exp $ @subtitle $Id: guile.texi,v 1.2.2.13 2002-03-27 21:48:16 ossau Exp $
@subtitle For use with Guile @value{VERSION} @subtitle For use with Guile @value{VERSION}
@c AUTHORS @c AUTHORS
@ -211,7 +211,8 @@ Part II: Guile Scheme
* Scheme Intro:: Introduction to Guile Scheme. * Scheme Intro:: Introduction to Guile Scheme.
* Basic Ideas:: Basic ideas in Scheme. * Basic Ideas:: Basic ideas in Scheme.
* Data Types:: Data types for generic use. * Simple Data Types:: Numbers, strings, booleans and so on.
* Compound Data Types:: Data types for holding other data.
* Procedures and Macros:: Procedures and macros. * Procedures and Macros:: Procedures and macros.
* Utility Functions:: General utility functions. * Utility Functions:: General utility functions.
* Binding Constructs:: Definitions and variable bindings. * Binding Constructs:: Definitions and variable bindings.
@ -226,6 +227,7 @@ Part II: Guile Scheme
* Translation:: Support for translating other languages. * Translation:: Support for translating other languages.
* Debugging:: Internal debugging interface. * Debugging:: Internal debugging interface.
* Deprecated:: Features that are planned to disappear. * Deprecated:: Features that are planned to disappear.
* Debugger User Interface::
* Autoconf Support:: Guile-specific configure.in macros. * Autoconf Support:: Guile-specific configure.in macros.
* Miscellaneous Tools:: Snarfing, linting, etc. * Miscellaneous Tools:: Snarfing, linting, etc.
* Further Reading:: Where to find out more about Scheme programming. * Further Reading:: Where to find out more about Scheme programming.
@ -239,6 +241,7 @@ Part III: Guile Modules
* Value History:: Maintaining a value history in the REPL. * Value History:: Maintaining a value history in the REPL.
* Pretty Printing:: Nicely formatting Scheme objects for output. * Pretty Printing:: Nicely formatting Scheme objects for output.
* Formatted Output:: The @code{format} procedure. * Formatted Output:: The @code{format} procedure.
* Rx Regexps:: The Rx regular expression library.
* Expect:: Controlling interactive programs with Guile. * Expect:: Controlling interactive programs with Guile.
* The Scheme shell (scsh):: Using scsh interfaces in Guile. * The Scheme shell (scsh):: Using scsh interfaces in Guile.
@c * Tcl/Tk Interface:: @c * Tcl/Tk Interface::
@ -255,10 +258,6 @@ Part V: Extending Applications Using Guile
* Scheme Primitives:: Writing Scheme primitives in C. * Scheme Primitives:: Writing Scheme primitives in C.
* GH:: The deprecated GH interface. * GH:: The deprecated GH interface.
Appendices
* Debugger User Interface::
Indices Indices
* Concept Index:: * Concept Index::
@ -288,6 +287,7 @@ Indices
@include scheme-intro.texi @include scheme-intro.texi
@include scheme-ideas.texi @include scheme-ideas.texi
@include scheme-data.texi @include scheme-data.texi
@include scheme-compound.texi
@include scheme-procedures.texi @include scheme-procedures.texi
@include scheme-utility.texi @include scheme-utility.texi
@include scheme-binding.texi @include scheme-binding.texi
@ -302,10 +302,10 @@ Indices
@include scheme-translation.texi @include scheme-translation.texi
@include scheme-debug.texi @include scheme-debug.texi
@include deprecated.texi @include deprecated.texi
@include debugging.texi
@include autoconf.texi @include autoconf.texi
@include tools.texi @include tools.texi
@include scheme-reading.texi @include scheme-reading.texi
@include scheme-indices.texi
@iftex @iftex
@page @page
@ -341,21 +341,13 @@ Indices
@include scm.texi @include scm.texi
@include gh.texi @include gh.texi
@c Appendices
@iftex
@page
@unnumbered{Appendices}
@end iftex
@include appendices.texi
@c Indices
@iftex @iftex
@page @page
@unnumbered{Indices} @unnumbered{Indices}
@end iftex @end iftex
@include indices.texi @include indices.texi
@include scheme-indices.texi
@contents @contents

View file

@ -287,6 +287,140 @@ large version of @code{format} by default, so that the start-up time
of the interpreter is not unnecessarily increased. of the interpreter is not unnecessarily increased.
@page
@node Rx Regexps
@chapter The Rx Regular Expression Library
[FIXME: this is taken from Gary and Mark's quick summaries and should be
reviewed and expanded. Rx is pretty stable, so could already be done!]
@cindex rx
@cindex finite automaton
The @file{guile-lang-allover} package provides an interface to Tom
Lord's Rx library (currently only to POSIX regular expressions). Use of
the library requires a two step process: compile a regular expression
into an efficient structure, then use the structure in any number of
string comparisons.
For example, given the regular expression @samp{abc.} (which matches any
string containing @samp{abc} followed by any single character):
@smalllisp
guile> @kbd{(define r (regcomp "abc."))}
guile> @kbd{r}
#<rgx abc.>
guile> @kbd{(regexec r "abc")}
#f
guile> @kbd{(regexec r "abcd")}
#((0 . 4))
guile>
@end smalllisp
The definitions of @code{regcomp} and @code{regexec} are as follows:
@deffn {Scheme Procedure} regcomp pattern [flags]
Compile the regular expression pattern using POSIX rules. Flags is
optional and should be specified using symbolic names:
@defvar REG_EXTENDED
use extended POSIX syntax
@end defvar
@defvar REG_ICASE
use case-insensitive matching
@end defvar
@defvar REG_NEWLINE
allow anchors to match after newline characters in the
string and prevents @code{.} or @code{[^...]} from matching newlines.
@end defvar
The @code{logior} procedure can be used to combine multiple flags.
The default is to use
POSIX basic syntax, which makes @code{+} and @code{?} literals and @code{\+}
and @code{\?}
operators. Backslashes in @var{pattern} must be escaped if specified in a
literal string e.g., @code{"\\(a\\)\\?"}.
@end deffn
@deffn {Scheme Procedure} regexec regex string [match-pick] [flags]
Match @var{string} against the compiled POSIX regular expression
@var{regex}.
@var{match-pick} and @var{flags} are optional. Possible flags (which can be
combined using the logior procedure) are:
@defvar REG_NOTBOL
The beginning of line operator won't match the beginning of
@var{string} (presumably because it's not the beginning of a line)
@end defvar
@defvar REG_NOTEOL
Similar to REG_NOTBOL, but prevents the end of line operator
from matching the end of @var{string}.
@end defvar
If no match is possible, regexec returns #f. Otherwise @var{match-pick}
determines the return value:
@code{#t} or unspecified: a newly-allocated vector is returned,
containing pairs with the indices of the matched part of @var{string} and any
substrings.
@code{""}: a list is returned: the first element contains a nested list
with the matched part of @var{string} surrounded by the the unmatched parts.
Remaining elements are matched substrings (if any). All returned
substrings share memory with @var{string}.
@code{#f}: regexec returns #t if a match is made, otherwise #f.
vector: the supplied vector is returned, with the first element replaced
by a pair containing the indices of the matched portion of @var{string} and
further elements replaced by pairs containing the indices of matched
substrings (if any).
list: a list will be returned, with each member of the list
specified by a code in the corresponding position of the supplied list:
a number: the numbered matching substring (0 for the entire match).
@code{#\<}: the beginning of @var{string} to the beginning of the part matched
by regex.
@code{#\>}: the end of the matched part of @var{string} to the end of
@var{string}.
@code{#\c}: the "final tag", which seems to be associated with the "cut
operator", which doesn't seem to be available through the posix
interface.
e.g., @code{(list #\< 0 1 #\>)}. The returned substrings share memory with
@var{string}.
@end deffn
Here are some other procedures that might be used when using regular
expressions:
@deffn {Scheme Procedure} compiled-regexp? obj
Test whether obj is a compiled regular expression.
@end deffn
@deffn {Scheme Procedure} regexp->dfa regex [flags]
@end deffn
@deffn {Scheme Procedure} dfa-fork dfa
@end deffn
@deffn {Scheme Procedure} reset-dfa! dfa
@end deffn
@deffn {Scheme Procedure} dfa-final-tag dfa
@end deffn
@deffn {Scheme Procedure} dfa-continuable? dfa
@end deffn
@deffn {Scheme Procedure} advance-dfa! dfa string
@end deffn
@c Local Variables: @c Local Variables:
@c TeX-master: "guile.texi" @c TeX-master: "guile.texi"
@c End: @c End:

View file

@ -27,8 +27,6 @@ values can be looked up within them.
@section Pairs @section Pairs
@tpindex Pairs @tpindex Pairs
@c FIXME::martin: Review me!
Pairs are used to combine two Scheme objects into one compound object. Pairs are used to combine two Scheme objects into one compound object.
Hence the name: A pair stores a pair of objects. Hence the name: A pair stores a pair of objects.
@ -133,8 +131,6 @@ by @code{set-cdr!} is unspecified.
@section Lists @section Lists
@tpindex Lists @tpindex Lists
@c FIXME::martin: Review me!
A very important data type in Scheme---as well as in all other Lisp A very important data type in Scheme---as well as in all other Lisp
dialects---is the data type @dfn{list}.@footnote{Strictly speaking, dialects---is the data type @dfn{list}.@footnote{Strictly speaking,
Scheme does not have a real datatype @dfn{list}. Lists are made up of Scheme does not have a real datatype @dfn{list}. Lists are made up of
@ -173,8 +169,6 @@ or a pair which has a list in its cdr.
@node List Syntax @node List Syntax
@subsection List Read Syntax @subsection List Read Syntax
@c FIXME::martin: Review me!
The syntax for lists is an opening parentheses, then all the elements of The syntax for lists is an opening parentheses, then all the elements of
the list (separated by whitespace) and finally a closing the list (separated by whitespace) and finally a closing
parentheses.@footnote{Note that there is no separation character between parentheses.@footnote{Note that there is no separation character between
@ -208,8 +202,6 @@ applications (@pxref{Simple Invocation}).
@node List Predicates @node List Predicates
@subsection List Predicates @subsection List Predicates
@c FIXME::martin: Review me!
Often it is useful to test whether a given Scheme object is a list or Often it is useful to test whether a given Scheme object is a list or
not. List-processing procedures could use this information to test not. List-processing procedures could use this information to test
whether their input is valid, or they could do different things whether their input is valid, or they could do different things
@ -279,8 +271,6 @@ use the procedure @code{copy-tree} (@pxref{Copying}).
@node List Selection @node List Selection
@subsection List Selection @subsection List Selection
@c FIXME::martin: Review me!
These procedures are used to get some information about a list, or to These procedures are used to get some information about a list, or to
retrieve one or more elements of a list. retrieve one or more elements of a list.
@ -323,8 +313,6 @@ return it.
@node Append/Reverse @node Append/Reverse
@subsection Append and Reverse @subsection Append and Reverse
@c FIXME::martin: Review me!
@code{append} and @code{append!} are used to concatenate two or more @code{append} and @code{append!} are used to concatenate two or more
lists in order to form a new list. @code{reverse} and @code{reverse!} lists in order to form a new list. @code{reverse} and @code{reverse!}
return lists with the same elements as their arguments, but in reverse return lists with the same elements as their arguments, but in reverse
@ -356,7 +344,7 @@ if the last argument is not a proper list.
@deffn {Scheme Procedure} append! . lists @deffn {Scheme Procedure} append! . lists
@deffnx {C Function} scm_append_x (lists) @deffnx {C Function} scm_append_x (lists)
A destructive version of @code{append} (@pxref{Pairs and A destructive version of @code{append} (@pxref{Pairs and
Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field
of each list's final pair is changed to point to the head of of each list's final pair is changed to point to the head of
the next list, so no consing is performed. Return a pointer to the next list, so no consing is performed. Return a pointer to
the mutated list. the mutated list.
@ -372,7 +360,7 @@ in reverse order.
@c NJFIXME explain new_tail @c NJFIXME explain new_tail
@deffn {Scheme Procedure} reverse! lst [new_tail] @deffn {Scheme Procedure} reverse! lst [new_tail]
@deffnx {C Function} scm_reverse_x (lst, new_tail) @deffnx {C Function} scm_reverse_x (lst, new_tail)
A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, A destructive version of @code{reverse} (@pxref{Pairs and lists,,,r5rs,
The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is
modified to point to the previous list element. Return a pointer to the modified to point to the previous list element. Return a pointer to the
head of the reversed list. head of the reversed list.
@ -463,8 +451,6 @@ Like @code{delete!}, but only deletes the first occurrence of
@node List Searching @node List Searching
@subsection List Searching @subsection List Searching
@c FIXME::martin: Review me!
The following procedures search lists for particular elements. They use The following procedures search lists for particular elements. They use
different comparison predicates for comparing list elements with the different comparison predicates for comparing list elements with the
object to be searched. When they fail, they return @code{#f}, otherwise object to be searched. When they fail, they return @code{#f}, otherwise
@ -509,18 +495,21 @@ high level at all? Maybe these docs should be relegated to a "Guile
Internals" node or something. -twp] Internals" node or something. -twp]
@deffn {Scheme Procedure} sloppy-memq x lst @deffn {Scheme Procedure} sloppy-memq x lst
@deffnx {C Function} scm_sloppy_memq (x, lst)
This procedure behaves like @code{memq}, but does no type or error checking. This procedure behaves like @code{memq}, but does no type or error checking.
Its use is recommended only in writing Guile internals, Its use is recommended only in writing Guile internals,
not for high-level Scheme programs. not for high-level Scheme programs.
@end deffn @end deffn
@deffn {Scheme Procedure} sloppy-memv x lst @deffn {Scheme Procedure} sloppy-memv x lst
@deffnx {C Function} scm_sloppy_memv (x, lst)
This procedure behaves like @code{memv}, but does no type or error checking. This procedure behaves like @code{memv}, but does no type or error checking.
Its use is recommended only in writing Guile internals, Its use is recommended only in writing Guile internals,
not for high-level Scheme programs. not for high-level Scheme programs.
@end deffn @end deffn
@deffn {Scheme Procedure} sloppy-member x lst @deffn {Scheme Procedure} sloppy-member x lst
@deffnx {C Function} scm_sloppy_member (x, lst)
This procedure behaves like @code{member}, but does no type or error checking. This procedure behaves like @code{member}, but does no type or error checking.
Its use is recommended only in writing Guile internals, Its use is recommended only in writing Guile internals,
not for high-level Scheme programs. not for high-level Scheme programs.
@ -529,8 +518,6 @@ not for high-level Scheme programs.
@node List Mapping @node List Mapping
@subsection List Mapping @subsection List Mapping
@c FIXME::martin: Review me!
List processing is very convenient in Scheme because the process of List processing is very convenient in Scheme because the process of
iterating over the elements of a list can be highly abstracted. The iterating over the elements of a list can be highly abstracted. The
procedures in this section are the most basic iterating procedures for procedures in this section are the most basic iterating procedures for
@ -565,11 +552,6 @@ return value is not specified.
@section Vectors @section Vectors
@tpindex Vectors @tpindex Vectors
@c FIXME::martin: Review me!
@c FIXME::martin: Should the subsections of this section be nodes
@c of their own, or are the resulting nodes too short, then?
Vectors are sequences of Scheme objects. Unlike lists, the length of a Vectors are sequences of Scheme objects. Unlike lists, the length of a
vector, once the vector is created, cannot be changed. The advantage of vector, once the vector is created, cannot be changed. The advantage of
vectors over lists is that the time required to access one element of a vector vectors over lists is that the time required to access one element of a vector
@ -893,7 +875,7 @@ The field holds a Scheme value and is GC protected. When a structure is
created with this type of field, the field is initialized to refer to created with this type of field, the field is initialized to refer to
the structure's own handle. This kind of field is mainly useful when the structure's own handle. This kind of field is mainly useful when
mixing Scheme and C code in which the C code may need to compute a mixing Scheme and C code in which the C code may need to compute a
structure's handle given only the address of its malloc-ed data. structure's handle given only the address of its malloc'd data.
@end itemize @end itemize
@ -1713,19 +1695,19 @@ because association lists are so useful, Guile also provides specific
procedures for manipulating them. procedures for manipulating them.
@menu @menu
* Alist Key Equality:: * Alist Key Equality::
* Adding or Setting Alist Entries:: * Adding or Setting Alist Entries::
* Retrieving Alist Entries:: * Retrieving Alist Entries::
* Removing Alist Entries:: * Removing Alist Entries::
* Sloppy Alist Functions:: * Sloppy Alist Functions::
* Alist Example:: * Alist Example::
@end menu @end menu
@node Alist Key Equality @node Alist Key Equality
@subsubsection Alist Key Equality @subsubsection Alist Key Equality
All of Guile's dedicated association list procedures, apart from All of Guile's dedicated association list procedures, apart from
@code{acons}, come in three flavors, depending on the level of equality @code{acons}, come in three flavours, depending on the level of equality
that is required to decide whether an existing key in the association that is required to decide whether an existing key in the association
list is the same as the key that the procedure call uses to identify the list is the same as the key that the procedure call uses to identify the
required entry. required entry.
@ -1864,7 +1846,7 @@ function is @emph{not} destructive; @var{alist} is not modified.
@deffnx {C Function} scm_assq_set_x (alist, key, val) @deffnx {C Function} scm_assq_set_x (alist, key, val)
@deffnx {C Function} scm_assv_set_x (alist, key, val) @deffnx {C Function} scm_assv_set_x (alist, key, val)
@deffnx {C Function} scm_assoc_set_x (alist, key, val) @deffnx {C Function} scm_assoc_set_x (alist, key, val)
Re-associate @var{key} in @var{alist} with @var{value}: find any existing Reassociate @var{key} in @var{alist} with @var{value}: find any existing
@var{alist} entry for @var{key} and associate it with the new @var{alist} entry for @var{key} and associate it with the new
@var{value}. If @var{alist} does not contain an entry for @var{key}, @var{value}. If @var{alist} does not contain an entry for @var{key},
add a new one. Return the (possibly new) alist. add a new one. Return the (possibly new) alist.

File diff suppressed because it is too large Load diff

View file

@ -32,10 +32,14 @@ designed languages: ML, Python, Perl, and Modula 3 all allow the
clutter the global name space. clutter the global name space.
@cindex name space - private @cindex name space - private
In addition, Guile offers variables as first-class objects. They can
be used for interacting with the module system.
@menu @menu
* Scheme and modules:: How modules are handled in standard Scheme. * Scheme and modules:: How modules are handled in standard Scheme.
* The Guile module system:: How Guile does it. * The Guile module system:: How Guile does it.
* Dynamic Libraries:: Loading libraries of compiled code at run time. * Dynamic Libraries:: Loading libraries of compiled code at run time.
* Variables:: First-class variables.
@end menu @end menu
@ -624,6 +628,67 @@ the Guile contrib archive to make @file{libffi} accessible from Guile.
XXX - document @code{load-extension}, @code{scm_register_extension} XXX - document @code{load-extension}, @code{scm_register_extension}
@node Variables
@section Variables
@tpindex Variables
Variables are objects with two fields. They contain a value and they
can contain a symbol, which is the name of the variable. A variable is
said to be bound if it does not contain the object denoting unbound
variables in the value slot.
Variables do not have a read syntax, they have to be created by calling
one of the constructor procedures @code{make-variable} or
@code{make-undefined-variable} or retrieved by @code{builtin-variable}.
First-class variables are especially useful for interacting with the
current module system (@pxref{The Guile module system}).
@deffn {Scheme Procedure} builtin-variable name
@deffnx {C Function} scm_builtin_variable (name)
Return the built-in variable with the name @var{name}.
@var{name} must be a symbol (not a string).
Then use @code{variable-ref} to access its value.
@end deffn
@deffn {Scheme Procedure} make-undefined-variable
@deffnx {C Function} scm_make_undefined_variable ()
Return a variable that is initially unbound.
@end deffn
@deffn {Scheme Procedure} make-variable init
@deffnx {C Function} scm_make_variable (init)
Return a variable initialized to value @var{init}.
@end deffn
@deffn {Scheme Procedure} variable-bound? var
@deffnx {C Function} scm_variable_bound_p (var)
Return @code{#t} iff @var{var} is bound to a value.
Throws an error if @var{var} is not a variable object.
@end deffn
@deffn {Scheme Procedure} variable-ref var
@deffnx {C Function} scm_variable_ref (var)
Dereference @var{var} and return its value.
@var{var} must be a variable object; see @code{make-variable}
and @code{make-undefined-variable}.
@end deffn
@deffn {Scheme Procedure} variable-set! var val
@deffnx {C Function} scm_variable_set_x (var, val)
Set the value of the variable @var{var} to @var{val}.
@var{var} must be a variable object, @var{val} can be any
value. Return an unspecified value.
@end deffn
@deffn {Scheme Procedure} variable? obj
@deffnx {C Function} scm_variable_p (obj)
Return @code{#t} iff @var{obj} is a variable object, else
return @code{#f}.
@end deffn
@c Local Variables: @c Local Variables:
@c TeX-master: "guile.texi" @c TeX-master: "guile.texi"
@c End: @c End:

View file

@ -1,3 +1,7 @@
2002-03-24 Neil Jerram <neil@ossau.uklinux.net>
* guile.m4 (GUILE_PROGS): In docstring, change `are' to `is'.
2002-03-03 Rob Browning <rlb@defaultvalue.org> 2002-03-03 Rob Browning <rlb@defaultvalue.org>
* guile-config.in (build-link): don't output -L/usr/lib. * guile-config.in (build-link): don't output -L/usr/lib.

View file

@ -67,7 +67,7 @@
# This macro looks for programs @code{guile}, @code{guile-config} and # This macro looks for programs @code{guile}, @code{guile-config} and
# @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and # @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and
# @var{GUILE_TOOLS}, to their paths, respectively. If either of the first two # @var{GUILE_TOOLS}, to their paths, respectively. If either of the first two
# are not found, signal error. # is not found, signal error.
# #
# The variables are marked for substitution, as by @code{AC_SUBST}. # The variables are marked for substitution, as by @code{AC_SUBST}.
# #

View file

@ -1,3 +1,8 @@
2002-03-24 Neil Jerram <neil@ossau.uklinux.net>
* snarf-guile-m4-docs (display-texi): Strip off `# ' from start of
docstring lines if possible, rather than just `#'.
2002-03-14 Neil Jerram <neil@ossau.uklinux.net> 2002-03-14 Neil Jerram <neil@ossau.uklinux.net>
These changes add a @deffnx C function declaration and function These changes add a @deffnx C function declaration and function

View file

@ -43,9 +43,12 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
(define (display-texi lines) (define (display-texi lines)
(display "@deffn {Autoconf Macro}") (display "@deffn {Autoconf Macro}")
(for-each (lambda (line) (for-each (lambda (line)
(display (if (string=? "#" (substring line 0 1)) (display (cond ((and (>= (string-length line) 2)
(substring line 1) (string=? "# " (substring line 0 2)))
line)) (substring line 2))
((string=? "#" (substring line 0 1))
(substring line 1))
(else line)))
(newline)) (newline))
lines) lines)
(display "@end deffn") (display "@end deffn")