diff --git a/.gitignore b/.gitignore
index 6375f2bc5..36f897261 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ config.h
*.x
*.lo
*.la
+*.exe
aclocal.m4
libtool
ltmain.sh
@@ -142,6 +143,7 @@ INSTALL
/test-suite/standalone/test-scm-spawn-thread
/test-suite/standalone/test-pthread-create
/test-suite/standalone/test-pthread-create-secondary
+/test-suite/standalone/test-smob-mark-race
/lib/fcntl.h
/lib/sys/uio.h
/lib/stdalign.h
@@ -163,3 +165,6 @@ INSTALL
/libguile/vm-operations.h
/test-suite/standalone/test-foreign-object-c
/test-suite/standalone/test-srfi-4
+/meta/build-env
+/lib/limits.h
+/lib/stdint.h
diff --git a/.gnuploadrc b/.gnuploadrc
deleted file mode 100644
index 29acf7312..000000000
--- a/.gnuploadrc
+++ /dev/null
@@ -1 +0,0 @@
---user ludo@gnu.org
diff --git a/ANNOUNCE b/ANNOUNCE
deleted file mode 100644
index bfbda7316..000000000
--- a/ANNOUNCE
+++ /dev/null
@@ -1,60 +0,0 @@
-We are pleased to announce the release of Guile 1.8.0. It can be
-found here:
-
- ftp://ftp.gnu.org/gnu/guile/guile-1.8.0.tar.gz
-
-Its SHA1 checksum is
-
- 22462680feeda1e5400195c01dee666162503d66 guile-1.8.0.tar.gz
-
-We already know about some issues with 1.8.0, please check the mailing
-lists:
-
- http://www.gnu.org/software/guile/mail/mail.html
-
-The NEWS file is quite long. Here are the most interesting entries:
-
- Changes since 1.6:
-
- * Guile is now licensed with the GNU Lesser General Public License.
-
- * The manual is now licensed with the GNU Free Documentation License.
-
- * We now use GNU MP for bignums.
-
- * We now have exact rationals, such as 1/3.
-
- * We now use native POSIX threads for real concurrent threads.
-
- * There is a new way to initalize Guile that allows one to use Guile
- from threads that have not been created by Guile.
-
- * Mutexes and condition variables are now always fair. A recursive
- mutex must be requested explicitly.
-
- * The low-level thread API has been removed.
-
- * There is now support for copy-on-write substrings and
- mutation-sharing substrings.
-
- * A new family of functions for converting between C values and
- Scheme values has been added that is future-proof and thread-safe.
-
- * The INUM macros like SCM_MAKINUM have been deprecated.
-
- * The macros SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_LENGTH,
- SCM_SYMBOL_CHARS, and SCM_SYMBOL_LENGTH have been deprecated.
-
- * There is a new way to deal with non-local exits and re-entries in
- C code, which is nicer than scm_internal_dynamic_wind.
-
- * There are new malloc-like functions that work better than
- scm_must_malloc, etc.
-
- * There is a new way to access all kinds of vectors and arrays from
- C that is efficient and thread-safe.
-
- * The concept of dynamic roots has been factored into continuation
- barriers and dynamic states.
-
-See NEWS and the manual for more details.
diff --git a/GNUmakefile b/GNUmakefile
index 4ab642943..a2f81118e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -5,7 +5,7 @@
# It is necessary if you want to build targets usually of interest
# only to the maintainer.
-# Copyright (C) 2001, 2003, 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2006-2017 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/GUILE-VERSION b/GUILE-VERSION
index 4a3f4fcef..223a2935f 100644
--- a/GUILE-VERSION
+++ b/GUILE-VERSION
@@ -2,8 +2,8 @@
# Note: `GUILE_VERSION' is defined in `configure.ac' using `git-version-gen'.
GUILE_MAJOR_VERSION=2
-GUILE_MINOR_VERSION=1
-GUILE_MICRO_VERSION=0
+GUILE_MINOR_VERSION=2
+GUILE_MICRO_VERSION=2
GUILE_EFFECTIVE_VERSION=2.2
@@ -16,7 +16,7 @@ GUILE_EFFECTIVE_VERSION=2.2
# See libtool info pages for more information on how and when to
# change these.
-LIBGUILE_INTERFACE_CURRENT=0
+LIBGUILE_INTERFACE_CURRENT=3
LIBGUILE_INTERFACE_REVISION=0
-LIBGUILE_INTERFACE_AGE=0
+LIBGUILE_INTERFACE_AGE=2
LIBGUILE_INTERFACE="${LIBGUILE_INTERFACE_CURRENT}:${LIBGUILE_INTERFACE_REVISION}:${LIBGUILE_INTERFACE_AGE}"
diff --git a/HACKING b/HACKING
index b08f7c2d4..181530fd4 100644
--- a/HACKING
+++ b/HACKING
@@ -1,6 +1,6 @@
-*-text-*-
Guile Hacking Guide
-Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2008, 2012 Free software Foundation, Inc.
+Copyright (c) 1996-2002,2008,2012,2015,2017 Free Software Foundation, Inc.
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
@@ -20,13 +20,8 @@ What to Hack =========================================================
You can hack whatever you want, thank GNU.
-However, to see what others have indicated as their interest (and avoid
-potential wasteful duplication of effort), see file TODO. Note that
-the version you find may be out of date; a CVS checkout is recommended:
-see below for details (see also the files ANON-CVS and SNAPSHOTS).
-
-It's also a good idea to join the guile-devel@gnu.org mailing list.
-See http://www.gnu.org/software/guile/mail/mail.html for more info.
+It's a good idea to join the guile-devel@gnu.org mailing list. See
+http://www.gnu.org/software/guile/mail/mail.html for more info.
Hacking It Yourself ==================================================
@@ -69,7 +64,7 @@ gettext --- a system for rigging a program so that it can output its
itself.
flex --- a scanner generator. It's probably not essential to have the
- latest version.
+ latest version; Flex 2.5.37 is known to work.
One false move and you will be lost in a little maze of automatically
generated files, all different.
@@ -77,67 +72,11 @@ generated files, all different.
Here is the authoritative list of tool/version/platform tuples that
have been known to cause problems, and a short description of the problem.
-- automake 1.4 adds extraneous rules to the top-level Makefile if
- you specify specific Makefiles to rebuild on the command line.
-
-- automake 1.4-p4 (debian "1:1.4-p4-1.1") all platforms
- automake "include" facility does not recognize filenames w/ "-".
-
-- libtool 1.4 uses acconfig.h, which is deprecated by newest autoconf
- (which constructs the equivalent through 3rd arg of AC_DEFINE forms).
-
-- autoreconf from autoconf prior to 2.59 will run gettextize, which
- will mess up the Guile tree.
-
-- libtool 1.5.26 does not know that it should remove the -R options
- that the Gnulib libunistring and havelib modules generate (because
- gcc doesn't actually support -R).
-
-- (add here.)
-
Sample GDB Initialization File=========================================
-Here is a sample .gdbinit posted by Bill Schottstaedt (modified to
-use `set' instead of `call' in some places):
-
- define gp
- set gdb_print($arg0)
- print gdb_output
- end
- document gp
- Executes (object->string arg)
- end
-
- define ge
- call gdb_read($arg0)
- call gdb_eval(gdb_result)
- set gdb_print(gdb_result)
- print gdb_output
- end
- document ge
- Executes (print (eval (read arg))): ge "(+ 1 2)" => 3
- end
-
- define gh
- call g_help(scm_str2symbol($arg0), 20)
- set gdb_print($1)
- print gdb_output
- end
- document gh
- Prints help string for arg: gh "enved-target"
- end
-
-Bill further writes:
-
- so in gdb if you see something useless like:
-
- #32 0x081ae8f4 in scm_primitive_load (filename=1112137128) at load.c:129
-
- You can get the file name with gp:
-
- (gdb) gp 1112137128
- $1 = 0x40853fac "\"/home/bil/test/share/guile/1.5.0/ice-9/session.scm\""
+In GDB, you probably want to load the gdbinit file included with Guile,
+which defines a number of GDB helpers to inspect Scheme values.
Contributing Your Changes ============================================
@@ -178,19 +117,15 @@ To make sure of this, you can use the --enable-error-on-warning option
to configure. This option will make GCC fail if it hits a warning.
Note that the warnings generated vary from one version of GCC to the
-next, and from one architecture to the next (apparently). To provide
-a concrete common standard, Guile should compile without warnings from
-GCC 2.7.2.3 in a Red Hat 5.2 i386 Linux machine. Furthermore, each
-developer should pursue any additional warnings noted by on their
-compiler. This means that people using more stringent compilers will
-have more work to do, and assures that everyone won't switch to the
-most lenient compiler they can find. :)
+next, and from one architecture to the next. For this reason,
+--enable-error-on-warning is not enabled by default.
- If you add code which uses functions or other features that are not
entirely portable, please make sure the rest of Guile will still
function properly on systems where they are missing. This usually
entails adding a test to configure.in, and then adding #ifdefs to your
-code to disable it if the system's features are missing.
+code to disable it if the system's features are missing. Do check first
+if the function has a Gnulib wrapper, though.
- The normal way of removing a function, macro or variable is to mark
it as "deprecated", keep it for a while, and remove it in a later
@@ -224,10 +159,6 @@ When deprecating a definition, always follow this procedure:
4. Add an entry that the definition has been deprecated in NEWS and
explain what to do instead.
-5. In file TODO, there is a list of releases with reminders about what
- to do at each release. Add a reminder about the removal of the
- deprecated defintion at the appropriate release.
-
- Write commit messages for functions written in C using the
functions' C names, and write entries for functions written in Scheme
using the functions' Scheme names. For example,
@@ -265,12 +196,12 @@ Maintainers of GNU Software":
has signed copyright papers, and that the Free Software Foundation has
received them.
-If you receive contributions you want to use from someone, let me know
-and I'll take care of the administrivia. Put the contributions aside
-until we have the necessary papers.
+If you receive contributions you want to use from someone, let a
+maintainer know and they will take care of the administrivia. Put the
+contributions aside until we have the necessary papers.
Once you accept a contribution, be sure to keep the files AUTHORS and
-THANKS uptodate.
+THANKS up-to-date.
- When you make substantial changes to a file, add the current year to
the list of years in the copyright notice at the top of the file.
@@ -324,27 +255,3 @@ The follwing syllables also have a technical meaning:
str - this denotes a zero terminated C string
mem - a C string with an explicit count
-
-
-See also the file `devel/names.text'.
-
-
-Helpful hints ========================================================
-
-- [From Mikael Djurfeldt] When working on the Guile internals, it is
-quite often practical to implement a scheme-level procedure which
-helps you examine the feature you're working on.
-
-Examples of such procedures are: pt-size, debug-hand and
-current-pstate.
-
-I've now put #ifdef GUILE_DEBUG around all such procedures, so that
-they are not compiled into the "normal" Guile library. Please do the
-same when you add new procedures/C functions for debugging purpose.
-
-You can define the GUILE_DEBUG flag by passing --enable-guile-debug to
-the configure script.
-
-
-Jim Blandy, and others
-
diff --git a/Makefile.am b/Makefile.am
index 8f9e014c7..ebbf6d476 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
##
## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006, 2007,
## 2008, 2009, 2010, 2011, 2012, 2013,
-## 2014 Free Software Foundation, Inc.
+## 2014, 2015, 2016 Free Software Foundation, Inc.
##
## This file is part of GUILE.
##
@@ -30,6 +30,7 @@ SUBDIRS = \
lib \
meta \
libguile \
+ bootstrap \
module \
guile-readline \
examples \
@@ -40,6 +41,8 @@ SUBDIRS = \
am \
doc
+DIST_SUBDIRS = $(SUBDIRS) prebuilt
+
libguileincludedir = $(pkgincludedir)/$(GUILE_EFFECTIVE_VERSION)
libguileinclude_HEADERS = libguile.h
@@ -88,7 +91,7 @@ DISTCLEANFILES = check-guile.log
DISTCHECK_CONFIGURE_FLAGS = --enable-error-on-warning
-dist-hook: gen-ChangeLog gen-tarball-version
+dist-hook: gen-ChangeLog gen-tarball-version assert-no-store-file-names
clean-local:
rm -rf cache/
@@ -105,6 +108,16 @@ gen-ChangeLog:
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
fi
+# Make sure we're not shipping a file that embeds a /gnu/store file
+# name, for maintainers who use Guix.
+.PHONY: assert-no-store-file-names
+assert-no-store-file-names:
+ if grep -rE "/gnu/store/[a-z0-9]{32}-" $(distdir) ; \
+ then \
+ echo "error: store file names embedded in the distribution" >&2 ; \
+ exit 1 ; \
+ fi
+
BUILT_SOURCES += $(top_srcdir)/.version
$(top_srcdir)/.version:
echo $(VERSION) > $@-t && mv $@-t $@
diff --git a/NEWS b/NEWS
index 208ec9ebd..7ce583b9b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,12 +1,149 @@
Guile NEWS --- history of user-visible changes.
-Copyright (C) 1996-2015 Free Software Foundation, Inc.
+Copyright (C) 1996-2017 Free Software Foundation, Inc.
See the end for copying conditions.
Please send Guile bug reports to bug-guile@gnu.org.
-Changes in 2.1.1 (changes since the 2.0.x series):
+Changes in 2.2.3 (since 2.2.2):
+
+* New interfaces
+
+** (web uri) module has better support for RFC 3986
+
+The URI standard, RFC 3986, defines additional "relative-ref" and
+"URI-reference" data types. Thanks to Daniel Hartwig, Guile's support
+for these URI subtypes has been improved. See "Universal Resource
+Identifiers" in the manual, for more.
+
+* New deprecations
+
+** Using `uri?' as a predicate on relative-refs deprecated
+
+If you don't care whether the URI is a relative-ref or not, use
+`uri-reference?'. If you do, use `uri-reference?' and `relative-ref?'.
+In the future `uri?' will return a true value only for URIs that specify
+a scheme.
+
+* Bug fixes
+
+** Enable GNU Readline 7.0's support for "bracketed paste".
+
+Before, when pasting an expression that contained TAB characters into
+Guile's REPL with GNU Readline support enabled, the pasted TAB
+characters would trigger autocompletion in Readline. This was never
+what you wanted. Guile now sets the new "bracketed-paste" option in GNU
+Readline 7.0 to on by default, making readline treat pastes into the
+terminal as atomic units without control characters. See "Readline
+Options" in the manual for full details.
+
+** Fix time-monotonic from SRFI-19; broken in 2.2.1.
+
+
+Changes in 2.2.2 (since 2.2.1):
+
+* Bug fixes
+
+** Syntax objects are once more comparable with 'equal?'
+
+The syntax object change in 2.2.1 had the unintended effect of making
+syntax objects no longer comparable with equal?. This release restores
+the previous behavior.
+
+** Restore libgc dependency
+
+The change to throw exceptions when mutating literal constants partly
+relied on an interface that was added to our garbage collector (BDW-GC)
+after its 7.2 release. Guile 2.2.2 adds a workaround to allow Guile to
+continue be used with libgc as old as 7.2.
+
+** SRFI-37 bug fix to not error on empty-string arguments.
+
+Thanks to Thomas Danckaert for fixing this long-standing bug.
+
+
+
+Changes in 2.2.1 (since 2.2.0):
+
+* Notable changes
+
+** New sandboxed evaluation facility
+
+Guile now has a way to execute untrusted code in a safe way. See
+"Sandboxed Evaluation" in the manual for full details, including some
+important notes on limitations on the sandbox's ability to prevent
+resource exhaustion.
+
+** All literal constants are read-only
+
+According to the Scheme language definition, it is an error to attempt
+to mutate a "constant literal". A constant literal is data that is a
+literal quoted part of a program. For example, all of these are errors:
+
+ (set-car! '(1 . 2) 42)
+ (append! '(1 2 3) '(4 5 6))
+ (vector-set! '#(a b c) 1 'B)
+
+Guile takes advantage of this provision of Scheme to deduplicate shared
+structure in constant literals within a compilation unit, and to
+allocate constant data directly in the compiled object file. If the
+data needs no relocation at run-time, as is the case for pairs or
+vectors that only contain immediate values, then the data can actually
+be shared between different Guile processes, using the operating
+system's virtual memory facilities.
+
+However, in Guile 2.2.0, constants that needed relocation were actually
+mutable -- though (vector-set! '#(a b c) 1 'B) was an error, Guile
+wouldn't actually cause an exception to be raised, silently allowing the
+mutation. This could affect future users of this constant, or indeed of
+any constant in the compilation unit that shared structure with the
+original vector.
+
+Additionally, attempting to mutate constant literals mapped in the
+read-only section of files would actually cause a segmentation fault, as
+the operating system prohibits writes to read-only memory. "Don't do
+that" isn't a very nice solution :)
+
+Both of these problems have been fixed. Any attempt to mutate a
+constant literal will now raise an exception, whether the constant needs
+relocation or not.
+
+** Syntax objects are now a distinct type
+
+It used to be that syntax objects were represented as a tagged vector.
+These values could be forged by users to break scoping abstractions,
+preventing the implementation of sandboxing facilities in Guile. We are
+as embarrassed about the previous situation as we pleased are about the
+fact that we've fixed it.
+
+Unfortunately, during the 2.2 stable series (or at least during part of
+it), we need to support files compiled with Guile 2.2.0. These files
+may contain macros that contain legacy syntax object constants. See the
+discussion of "allow-legacy-syntax-objects?" in "Syntax Transformer
+Helpers" in the manual for full details.
+
+* Bug fixes
+
+*** Fix snarfing with -ggdb3 (#25803)
+*** Fix spurious snarf warnings for net_db.c
+*** Output statprof flat display to correct port
+*** Document guile-2.2 cond-expand feature
+*** Add --with-bdw-gc for BSDs that use bdw-gc-threaded (see README)
+*** Documentation typo fixes (#26188)
+*** Fix SRFI-9 date->string bugs with ~N and ~F (#26261, #26260, #26259)
+*** SRFI-19 current-time-monotonic returns time of right type (#26329)
+*** Avoid causing GC when looking up exception handler
+*** Increment objcode version, in a compatible way
+*** Fix compile warning in (system base types)
+*** Only run tests that require fork if it is provided
+*** Speed up procedure-minimum-arity for fixed arity
+*** REPL server tests catch ECONNABORTED
+*** Avoid deprecated argument to setvbuf in (web client)
+*** Remove non-existent 'open-connection-for-uri' export from (web client)
+
+
+Changes in 2.2.0 (changes since the 2.0.x stable release series):
* Notable changes
@@ -21,9 +158,9 @@ better memory usage, and faster execution of user code. See the
This new release series takes the ABI-break opportunity to fix some
interfaces that were difficult to use correctly from multiple threads.
-Notably, weak hash tables are now transparently thread-safe. Ports are
-also thread-safe; see "New interfaces" below for details on the changes
-to the C interface.
+Notably, weak hash tables and ports are now transparently thread-safe.
+See "Scheduling" in the manual, for updated documentation on threads and
+communications primitives.
** Better space-safety
@@ -55,14 +192,14 @@ hash-bang line (e.g. "#!/usr/bin/guile"), it now installs the current
locale via a call to `(setlocale LC_ALL "")'. For users with a unicode
locale, this makes all ports unicode-capable by default, without the
need to call `setlocale' in your program. This behavior may be
-controlled via the GUILE_INSTALL_LOCALE environment variable; see the
-manual for more.
+controlled via the GUILE_INSTALL_LOCALE environment variable; see
+"Environment Variables" in the manual, for more.
** Complete Emacs-compatible Elisp implementation
-Thanks to the work of BT Templeton, Guile's Elisp implementation is now
-fully Emacs-compatible, implementing all of Elisp's features and quirks
-in the same way as the editor we know and love.
+Thanks to the work of Robin Templeton, Guile's Elisp implementation is
+now fully Emacs-compatible, implementing all of Elisp's features and
+quirks in the same way as the editor we know and love.
** Dynamically expandable stacks
@@ -101,6 +238,40 @@ in Scheme. This decreases its maintenance burden on the rest of Guile,
while also makes it possible to implement new features in the future,
such as method combinations or `eqv?' specializers.
+** Better handling of GUILE_LOAD_COMPILED_PATH
+
+It used to be that Guile would stop at the first .go file it found in
+the GUILE_LOAD_COMPILED_PATH. If that file turned out to be out of
+date, then no .go file would be loaded. Now Guile will continue to
+search the path for a file which is both present and up-to-date, with
+respect to the .scm file.
+
+** C99 required
+
+Following Emacs, you must use a C99-capable compiler when building
+Guile. In the future we also expect require C99 to use Guile's C
+interface, at least for `stdint' support.
+
+** Lightweight pre-emptive threading primitives
+
+The compiler now inserts special "handle-interrupts" opcodes before each
+call, return, and backwards jump target. This allows the user to
+interrupt any computation and to accurately profile code using
+interrupts. It used to be that interrupts were run by calling a C
+function from the VM; now interrupt thunks are run directly from the VM.
+This allows interrupts to save a delimited continuation and, if the
+continuation was established from the same VM invocation (the usual
+restriction), that continuation can then be resumed. In this way users
+can implement lightweight pre-emptive threading facilities.
+
+** with-dynamic-state in VM
+
+Similarly, `with-dynamic-state' no longer recurses out of the VM,
+allowing captured delimited continuations that include a
+`with-dynamic-state' invocation to be resumed. This is a precondition
+to allow lightweight threading libraries to establish a dynamic state
+per lightweight fiber.
+
* Performance improvements
** Faster programs via new virtual machine
@@ -132,10 +303,11 @@ Guile's compiler now uses a Continuation-Passing Style (CPS)
intermediate language, allowing it to reason easily about temporary
values and control flow. Examples of optimizations that this permits
are optimal contification, optimal common subexpression elimination,
-dead code elimination, parallel moves with at most one temporary,
-allocation of stack slots using precise liveness information, and
-closure optimization. For more, see "Continuation-Passing Style" in the
-manual.
+dead code elimination, loop-invariant code motion, loop peeling, loop
+inversion, parallel moves with at most one temporary, allocation of
+stack slots using precise liveness information, unboxing of 64-bit
+integers and floating point values, and closure optimization. For more,
+see "Continuation-Passing Style" in the manual.
** Faster interpreter
@@ -169,6 +341,20 @@ Thanks to work by Daniel Llorens, the generic array facility is much
faster now, as it is internally better able to dispatch on the type of
the underlying backing store.
+** All ports are now buffered, can be targets of `setvbuf'
+
+See "Buffering" in the manual, for more. A port with a buffer size of 1
+is equivalent to an unbuffered port. Ports may set their default buffer
+sizes, and some ports (for example soft ports) are unbuffered by default
+for historical reasons.
+
+** Mutexes are now faster under contention
+
+Guile implements its own mutexes, so that threads that are trying to
+acquire a mutex can be interrupted. These mutexes used to be quite
+inefficient when many threads were trying to acquire them, causing many
+spurious wakeups and contention. This has been fixed.
+
* New interfaces
** New `cond-expand' feature: `guile-2.2'
@@ -185,29 +371,55 @@ Since the compiler was rewritten, there are new modules for the back-end
of the compiler and the low-level loader and introspection interfaces.
See the "Guile Implementation" chapter in the manual for all details.
-** New functions: `scm_to_intptr_t', `scm_from_intptr_t'
-** New functions: `scm_to_uintptr_t', `scm_from_uintptr_t'
+** Add "tree" display mode for statprof.
-See "Integers" in the manual, for more.
+See the newly updated "Statprof" section of the manual, for more.
-** New thread-safe port API
+** Support for non-blocking I/O
-For details on `scm_c_make_port', `scm_c_make_port_with_encoding',
-`scm_c_lock_port', `scm_c_try_lock_port', `scm_c_unlock_port',
-`scm_c_port_type_ref', `scm_c_port_type_add_x', `SCM_PORT_DESCRIPTOR',
-and `scm_dynwind_lock_port', see XXX.
+See "Non-Blocking I/O" in the manual, for more.
-There is now a routine to atomically adjust port "revealed counts". See
-XXX for more on `scm_adjust_port_revealed_x' and
-`adjust-port-revealed!',
+** Implement R6RS custom binary input/output ports
-All other port API now takes the lock on the port if needed. There are
-some C interfaces if you know that you don't need to take a lock; see
-XXX for details on `scm_get_byte_or_eof_unlocked',
-`scm_peek_byte_or_eof_unlocked' `scm_c_read_unlocked',
-`scm_getc_unlocked' `scm_unget_byte_unlocked', `scm_ungetc_unlocked',
-`scm_ungets_unlocked', `scm_fill_input_unlocked' `scm_putc_unlocked',
-`scm_puts_unlocked', and `scm_lfwrite_unlocked'.
+See "Custom Ports" in the manual.
+
+** Implement R6RS output-buffer-mode
+** Implement R6RS bytevector->string, string->bytevector
+
+See "R6RS Transcoders" in the manual.
+
+** `accept' now takes optional flags argument
+
+These flags can include `SOCK_NONBLOCK' and `SOCK_CLOEXEC', indicating
+options to apply to the returned socket, potentially removing the need
+for additional system calls to set these options. See "Network Sockets
+and Communication" in the manual, for more.
+
+** Thread-safe atomic boxes (references)
+
+See "Atomics" in the manual.
+
+** Thread-local fluids
+
+Guile now has support for fluids whose values are not captured by
+`current-dynamic-state' and not inheritied by child threads, and thus
+are local to the kernel thread they run on. See "Thread-Local
+Variables" in the manual, for more.
+
+** suspendable-continuation?
+
+This predicate returns true if the delimited continuation captured by
+aborting to a prompt would be able to be resumed. See "Prompt
+Primitives" in the manual for more.
+
+** scm_c_prepare_to_wait_on_fd, scm_c_prepare_to_wait_on_cond,
+** scm_c_wait_finished
+
+See "Asyncs" in the manual for more.
+
+** File descriptor finalizers
+
+See "Ports and File Descriptors" in the manual.
** New inline functions: `scm_new_smob', `scm_new_double_smob'
@@ -224,14 +436,22 @@ For more on `SCM_HAS_TYP7', `SCM_HAS_TYP7S', `SCM_HAS_TYP16', see XXX.
the old `SCM2PTR' and `PTR2SCM'. Also, `SCM_UNPACK_POINTER' yields a
void*.
+** `TCP_NODELAY' and `TCP_CORK' socket options, if provided by the system
+
+** `scm_c_put_latin1_chars', `scm_c_put_utf32_chars'
+
+Use these instead of `scm_lfwrite'. See the new "Using Ports from C"
+section of the manual, for more.
+
** , standard-vtable-fields
-See "Structures" in the manual for more on these
+See "Structures" in the manual for more on these.
** Convenience utilities for ports and strings.
-See XXX for more on `scm_from_port_string', `scm_from_port_stringn',
-`scm_to_port_string', and `scm_to_port_stringn'.
+See "Conversion to/from C" for more on `scm_from_port_string',
+`scm_from_port_stringn', `scm_to_port_string', and
+`scm_to_port_stringn'.
** New expressive PEG parser
@@ -264,6 +484,97 @@ ASCII as ISO-8859-1. This is likely to be a problem only if the user's
locale is set to ASCII, and the user or a program writes non-ASCII
codepoints to a port.
+** Decoding errors do not advance the read pointer before erroring
+
+When the user sets a port's conversion strategy to "error", indicating
+that Guile should throw an error if it tries to read from a port whose
+incoming bytes are not valid for the port's encoding, it used to be that
+Guile would advance the read pointer past the bad bytes, and then throw
+an error. This would allow the following `read-char' invocation to
+proceed after the bad bytes. This behavior is incompatible with the
+final R6RS standard, and besides contravenes the user's intention to
+raise an error on bad input. Guile now raises an error without
+advancing the read pointer. To skip over a bad encoding, set the port
+conversion strategy to "substitute" and read a substitute character.
+
+** Decoding errors with `substitute' strategy return U+FFFD
+
+It used to be that decoding errors with the `substitute' conversion
+strategy would replace the bad bytes with a `?' character. This has
+been changed to use the standard U+FFFD REPLACEMENT CHARACTER, in
+accordance with the Unicode recommendations.
+
+** API to define new port types from C has changed
+
+Guile's ports have been completely overhauled to allow Guile developers
+and eventually Guile users to write low-level input and output routines
+in Scheme. The new internals will eventually allow for user-space
+tasklets or green threads that suspend to a scheduler when they would
+cause blocking I/O, allowing users to write straightforward network
+services that parse their input and send their output as if it were
+blocking, while under the hood Guile can multiplex many active
+connections at once.
+
+At the same time, this change makes Guile's ports implementation much
+more maintainable, rationalizing the many legacy port internals and
+making sure that the abstractions between the user, Guile's core ports
+facility, and the port implementations result in a system that is as
+performant and expressive as possible.
+
+The interface to the user has no significant change, neither on the C
+side nor on the Scheme side. However this refactoring has changed the
+interface to the port implementor in an incompatible way. See the newly
+expanded "I/O Extensions" in the manual, for full details.
+
+*** Remove `scm_set_port_mark'
+
+Port mark functions have not been called since the switch to the BDW
+garbage collector.
+
+*** Remove `scm_set_port_equalp'
+
+Likewise port equal functions weren't being called. Given that ports
+have their own internal buffers, it doesn't make sense to hook them into
+equal? anyway.
+
+*** Remove `scm_set_port_free'
+
+It used to be that if an open port became unreachable, a special "free"
+function would be called instead of the "close" function. Now that the
+BDW-GC collector allows us to run arbitrary code in finalizers, we can
+simplify to just call "close" on the port and remove the separate free
+functions. Note that hooking into the garbage collector has some
+overhead. For that reason Guile exposes a new interface,
+`scm_set_port_needs_close_on_gc', allowing port implementations to
+indicate to Guile whether they need closing on GC or not.
+
+*** Remove `scm_set_port_end_input', `scm_set_port_flush'
+
+As buffering is handled by Guile itself, these functions which were to
+manage an implementation-side buffer are no longer needed.
+
+*** Change prototype of `scm_make_port_type'
+
+The `read' (renamed from `fill_input') and `write' functions now operate
+on bytevectors. Also the `mode_bits' argument now inplicitly includes
+SCM_OPN, so you don't need to include these.
+
+*** Change prototype of port `close' function
+
+The port close function now returns void.
+
+*** Port and port type data structures are now opaque
+
+Port type implementations should now use API to access port state.
+However, since the change to handle port buffering centrally, port type
+implementations rarely need to access unrelated port state.
+
+*** Port types are now `scm_t_port_type*', not a tc16 value
+
+`scm_make_port_type' now returns an opaque pointer, not a tc16.
+Relatedly, the limitation that there only be 256 port types has been
+lifted.
+
** String ports default to UTF-8
Guile 2.0 would use the `%default-port-encoding' when creating string
@@ -285,6 +596,122 @@ ports are both textual and binary, Guile's R6RS ports are also both
textual and binary, and thus both kinds have port transcoders. This is
an incompatibility with respect to R6RS.
+** Threading facilities moved to (ice-9 threads)
+
+It used to be that call-with-new-thread and other threading primitives
+were available in the default environment. This is no longer the case;
+they have been moved to (ice-9 threads) instead. Existing code will not
+break, however; we used the deprecation facility to signal a warning
+message while also providing these bindings in the root environment for
+the duration of the 2.2 series.
+
+** cancel-thread uses asynchronous interrupts, not pthread_cancel
+
+See "Asyncs" in the manual, for more on asynchronous interrupts.
+
+** SRFI-18 threads, mutexes, cond vars disjoint from Guile
+
+When we added support for the SRFI-18 threading library in Guile 2.0, we
+did so in a way that made SRFI-18 mutexes the same as Guile mutexes.
+This was a mistake. In Guile our goal is to provide basic,
+well-thought-out, well-implemented, minimal primitives, on top of which
+we can build a variety of opinionated frameworks. Incorporating SRFI-18
+functionality into core Guile caused us to bloat and slow down our core
+threading primitives. Worse, they became very hard to describe; they
+did many things, did them poorly, and all that they did was never
+adequately specified.
+
+For all of these reasons we have returned to a situation where SRFI-18
+concepts are implemented only in the `(srfi srfi-18)' module. This
+means that SRFI-18 threads are built on Guile threads, but aren't the
+same as Guile threads; calling Guile `thread?' on a thread no longer
+returns true.
+
+We realize this causes inconvenience to users who use both Guile
+threading interfaces and SRFI-18 interfaces, and we lament the change --
+but we are better off now. We hope the newly revised "Scheduling"
+section in the manual compensates for the headache.
+
+** Remove `lock-mutex' "owner" argument
+
+Mutex owners are a SRFI-18 concept; use SRFI-18 mutexes instead.
+Relatedly, `scm_lock_mutex_timed' taking the owner argument is now
+deprecated; use `scm_timed_lock_mutex' instead.
+
+** Remove `unlock-mutex' cond var and timeout arguments
+
+It used to be that `unlock-mutex' included `wait-condition-variable'
+functionality. This has been deprecated; use SRFI-18 if you want this
+behavior from `mutex-unlock!'. Relatedly, `scm_unlock_mutex_timed' is
+deprecated; use `scm_unlock_mutex' instead.
+
+** Removed `unchecked-unlock' mutex flag
+
+This flag was introduced for internal use by SRFI-18; use SRFI-18
+mutexes if you need this behaviour.
+
+** SRFI-18 mutexes no longer recursive
+
+Contrary to specification, SRFI-18 mutexes in Guile were recursive.
+This is no longer the case.
+
+** Thread cleanup handlers removed
+
+The `set-thread-cleanup!' and `thread-cleanup' functions that were added
+in Guile 2.0 to support cleanup after thread cancellation are no longer
+needed, since threads can declare cleanup handlers via `dynamic-wind'.
+
+** Only threads created by Guile are joinable
+
+`join-thread' used to work on "foreign" threads that were not created by
+Guile itself, though their join value was always `#f'. This is no
+longer the case; attempting to join a foreign thread will throw an
+error.
+
+** Dynamic states capture values, not locations
+
+Dynamic states used to capture the locations of fluid-value
+associations. Capturing the current dynamic state then setting a fluid
+would result in a mutation of that captured state. Now capturing a
+dynamic state simply captures the current values, and calling
+`with-dynamic-state' copies those values into the Guile virtual machine
+instead of aliasing them in a way that could allow them to be mutated in
+place. This change allows Guile's fluid variables to be thread-safe.
+To capture the locations of a dynamic state, capture a
+`with-dynamic-state' invocation using partial continuations instead.
+
+** Remove `frame-procedure'
+
+Several optimizations in Guile make `frame-procedure' an interface that
+we can no longer support. For background, `frame-procedure' used to
+return the value at slot 0 in a frame, which usually corresponds to the
+SCM value of the procedure being applied. However it could be that this
+slot is re-used for some other value, because the closure was not needed
+in the function. Such a re-use might even be for an untagged value, in
+which case treating slot 0 as a SCM value is quite dangerous. It's also
+possible that so-called "well-known" closures (closures whose callers
+are all known) are optimized in such a way that slot 0 is not a
+procedure but some optimized representation of the procedure's free
+variables. Instead, developers building debugging tools that would like
+access to `frame-procedure' are invited to look at the source for the
+`(system vm frame)' module for alternate interfaces, including the new
+`frame-procedure-name'.
+
+** Remove `,procedure' REPL command
+
+Not all procedures have values, so it doesn't make sense to expose this
+interface to the user. Instead, the `,locals' REPL command will include
+the callee, if it is live.
+
+** Remove `frame-local-ref', `frame-local-set!', `frame-num-locals'
+
+These procedures reference values in a frame on the stack. Since we now
+have unboxed values of different kinds, it is now necessary to specify
+the type when reference locals, and once this incompatible change needs
+to be made, we might as well make these interfaces private. See
+"Frames' in the manual, for more information on the replacements for
+these low-level interfaces.
+
** Vtable hierarchy changes
In an attempt to make Guile's structure and record types integrate
@@ -351,6 +778,37 @@ are matched by binding. This allows literals to be reliably bound to
values, renamed by imports or exports, et cetera. See "Syntax-rules
Macros" in the manual for more on literals.
+** Fix bug importing specific bindings with #:select
+
+It used to be that if #:select didn't find a binding in the public
+interface of a module, it would actually grovel in the module's
+unexported private bindings. This was not intended and is now fixed.
+
+** Statically scoped module duplicate handlers
+
+It used to be that if a module did not specify a #:duplicates handler,
+when a name was first referenced in that module and multiple imported
+modules provide that name, the value of the
+`default-duplicate-binding-handlers' parameter would be used to resolve
+the duplicate bindings. We have changed so that instead a module
+defaults to the set of handlers described in the manual. If the module
+specifies #:duplicates, of course we use that. The
+`default-duplicate-binding-handlers' parameter now simply accesses the
+handlers of the current module, instead of some global value.
+
+** Fix too-broad capture of dynamic stack by delimited continuations
+
+Guile was using explicit stacks to represent, for example, the chain of
+current exception handlers. This means that a delimited continuation
+that captured a "catch" expression would capture the whole stack of
+exception handlers, not just the exception handler added by the "catch".
+This led to strangeness when resuming the continuation in some other
+context like other threads; "throw" could see an invalid stack of
+exception handlers. This has been fixed by the addition of the new
+"fluid-ref*" procedure that can access older values of fluids; in this
+way the exception handler stack is now implicit. See "Fluids and
+Dynamic States" in the manual, for more on fluid-ref*.
+
** `dynamic-wind' doesn't check that guards are thunks
Checking that the dynamic-wind out-guard procedure was actually a thunk
@@ -472,6 +930,62 @@ scm_t_debug_info', `scm_pure_generic_p', `SCM_PUREGENERICP',
* New deprecations
+** `SCM_FDES_RANDOM_P'
+
+Instead, use `lseek (fd, 0, SEEK_CUR)' directly.
+
+** `_IONBF', `_IOLBF', and `_IOFBF'
+
+Instead, use the symbol values `none', `line', or `block', respectively,
+as arguments to the `setvbuf' function.
+
+** `SCM_FDES_RANDOM_P'
+
+Instead, use `lseek (fd, 0, SEEK_CUR)' directly.
+
+** Arbiters
+
+Arbiters were an experimental mutual exclusion facility from 20 years
+ago that didn't survive the test of time. Use mutexes or atomic boxes
+instead.
+
+** User asyncs
+
+Guile had (and still has) "system asyncs", which are asynchronous
+interrupts, and also had this thing called "user asyncs", which was a
+trivial unused data structure. Now that we have deprecated the old
+`async', `async-mark', and `run-asyncs' procedures that comprised the
+"user async" facility, we have been able to clarify our documentation to
+only refer to "asyncs".
+
+** Critical sections
+
+Critical sections have long been just a fancy way to lock a mutex and
+defer asynchronous interrupts. Instead of SCM_CRITICAL_SECTION_START,
+make sure you're in a "scm_dynwind_begin (0)" and use
+scm_dynwind_pthread_mutex_lock instead, possibly also with
+scm_dynwind_block_asyncs.
+
+** `scm_make_mutex_with_flags'
+
+Use `scm_make_mutex_with_kind' instead. See "Mutexes and Condition
+Variables" in the manual, for more.
+
+** Dynamic roots
+
+This was a facility that predated threads, was unused as far as we can
+tell, and was never documented. Still, a grep of your code for
+dynamic-root or dynamic_root would not be amiss.
+
+** `make-dynamic-state'
+
+Use `current-dynamic-state' to get an immutable copy of the current
+fluid-value associations.
+
+** `with-statprof' macro
+
+Use the `statprof' procedure instead.
+
** SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1, SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_N
** SCM_GASSERT0, SCM_GASSERT1, SCM_GASSERT2, SCM_GASSERTn
** SCM_WTA_DISPATCH_1_SUBR
@@ -524,6 +1038,19 @@ Instead use the normal `scm_slot_ref' and similar procedures.
* Changes to the distribution
+** Pre-built binary files in the tarball
+
+Building Guile from a tarball can now take advantage of a "prebuilt/"
+tree of prebuilt .go files. These compiled files are created when a
+tarball is made, and are used to speed up the build for users of
+official releases.
+
+These pre-built binaries are not necessary, however: they are not stored
+in revision control and can always be re-created from the source, given
+that Guile can bootstrap itself from its minimal bootstrap C
+interpreter. If you do not want to depend on these pre-built binaries,
+you can "make -C prebuilt clean" before building.
+
** New minor version
The "effective version" of Guile is now 2.2, which allows parallel
@@ -533,6 +1060,15 @@ Notably, the `pkg-config' file is now `guile-2.2'.
** Bump required libgc version to 7.2, released March 2012.
+** GUILE_PROGS searches for versioned Guile
+
+The GUILE_PROGS autoconf macro can take a required version argument. As
+a new change, that version argument is additionally searched for as a
+suffix. For example, GUILE_PROGS(2.2) would look for guile-2.2,
+guile2.2, guile-2, guile2, and then guile. The found prefix is also
+applied to guild, guile-config, and the like. Thanks to Freja Nordsiek
+for this work.
+
** The readline extension is now installed in the extensionsdir
The shared library that implements Guile's readline extension is no
@@ -540,6 +1076,277 @@ longer installed to the libdir. This change should be transparent to
users, but packagers may be interested.
+
+Changes in 2.0.14 (since 2.0.13):
+
+* Bug fixes
+
+** Builds of .go files and of Guile itself are now bit-reproducible
+ ()
+
+** 'number->locale-string' and 'monetary-amount->locale-string' fixes
+ ()
+
+** (system base target) now recognizes "sh3" as a cross-compilation target
+
+** Fix race condition in '00-repl-server.test'
+ ()
+
+** 'scandir' from (ice-9 ftw) no longer calls 'stat' for each entry
+
+** Several documentation improvements
+
+
+Changes in 2.0.13 (since 2.0.12):
+
+* Security fixes
+
+** CVE-2016-8606: REPL server now protects against HTTP inter-protocol
+ attacks
+
+Guile 2.x provides a "REPL server" started by the '--listen'
+command-line option or equivalent API (see "REPL Servers" in the
+manual).
+
+The REPL server is vulnerable to the HTTP inter-protocol attack as
+described at
+, notably the
+HTML form protocol attack described at
+. A "DNS rebinding attack"
+can be combined with this attack and allow an attacker to send arbitrary
+Guile code to the REPL server through web pages accessed by the
+developer, even though the REPL server is listening to a loopback device
+("localhost"). This was demonstrated in an article entitled "How to
+steal any developer's local database" available at
+ .
+
+The REPL server in Guile 2.0.13 now detects attempts to exploit this
+vulnerability. It immediately closes the connection when it receives a
+line that looks like an HTTP request.
+
+Nevertheless, we recommend binding the REPL server to a Unix-domain
+socket, for instance by running:
+
+ guile --listen=/tmp/guile-socket
+
+** CVE-2016-8605: 'mkdir' procedure no longer calls umask(2)
+ ()
+
+When the second argument to the 'mkdir' procedure was omitted, it would
+call umask(0) followed by umask(previous_umask) and apply the umask to
+mode #o777.
+
+This was unnecessary and a security issue for multi-threaded
+applications: during a small window the process' umask was set to zero,
+so other threads calling mkdir(2) or open(2) could end up creating
+world-readable/writable/executable directories or files.
+
+* New interfaces
+
+** mkstemp! takes optional "mode" argument
+
+See "File System" in the manual, for more.
+
+** New 'scm_to_uintptr_t' and 'scm_from_uintptr_t' C functions
+
+* Bug fixes
+
+** Fix optimizer bug when compiling fixpoint operator
+** Fix build error on MinGW
+** Update 'uname' implementation on MinGW
+** 'port-encoding' and 'set-port-encoding!' ensure they are passed an
+ open port
+** (system base target) now recognizes Alpha as a cross-compilation target
+
+
+Changes in 2.0.12 (since 2.0.11):
+
+* Notable changes
+
+** FFI: Add support for functions that set 'errno'
+
+When accessing POSIX functions from a system's libc via Guile's dynamic
+FFI, you commonly want to access the 'errno' variable to be able to
+produce useful diagnostic messages.
+
+This is now possible using 'pointer->procedure' or
+'scm_pointer_to_procedure_with_errno'. See "Dynamic FFI" in the manual.
+
+** The #!r6rs directive now influences read syntax
+
+The #!r6rs directive now changes the per-port reader options to make
+Guile's reader conform more closely to the R6RS syntax. In particular:
+
+ - It makes the reader case sensitive.
+ - It disables the recognition of keyword syntax in conflict with the
+ R6RS (and R5RS).
+ - It enables the `square-brackets', `hungry-eol-escapes' and
+ `r6rs-hex-escapes' reader options.
+
+** 'read' now accepts "\(" as equivalent to "("
+
+This is indented for use at the beginning of lines in multi-line strings
+to avoid confusing Emacs' lisp modes. Previously "\(" was an error.
+
+** SRFI-14 character data set upgraded to Unicode 8.0.0
+
+** SRFI-19 table of leap seconds updated
+
+** 'string-hash', 'read-string', and 'write' have been optimized
+
+** GOOPS bug fix for inherited accessor methods
+
+In the port of GOOPS to Guile 2.0, we introduced a bug related to
+accessor methods. The bug resulted in GOOPS assuming that a slot S in
+an object whose class is C would always be present in instances of all
+subclasses C, and allocated to the same struct index. This is not the
+case for multiple inheritance. This behavior has been fixed to be as it
+was in 1.8.
+
+One aspect of this change may cause confusion among users. Previously
+if you defined a class C:
+
+ (use-modules (oop goops))
+ (define-class C ()
+ (a #:getter get-a))
+
+And now you define a subclass, intending to provide an #:init-value for
+the slot A:
+
+ (define-class D (A)
+ (a #:init-value 42))
+
+Really what you have done is define in D a new slot with the same name,
+overriding the existing slot. The problem comes in that before fixing
+this bug (but not in 1.8), the getter 'get-a' would succeed for
+instances of D, even though 'get-a' should only work for the slot 'a'
+that is defined on class C, not any other slot that happens to have the
+same name and be in a class with C as a superclass.
+
+It would be possible to "merge" the slot definitions on C and D, but
+that part of the meta-object protocol (`compute-slots' et al) is not
+fully implemented.
+
+Somewhat relatedly, GOOPS also had a fix around #:init-value on
+class-allocated slots. GOOPS was re-initializing the value of slots
+with #:class or #:each-subclass allocation every time instances of that
+class was allocated. This has been fixed.
+
+* New interfaces
+
+** New SRFI-28 string formatting implementation
+
+See "SRFI-28" in the manual.
+
+** New (ice-9 unicode) module
+
+See "Characters" in the manual.
+
+** Web server
+
+The (web server) module now exports 'make-server-impl', 'server-impl?',
+and related procedures. Likewise, (web server http) exports 'http'.
+
+** New procedures: 'string-utf8-length' and 'scm_c_string_utf8_length'
+
+See "Bytevectors as Strings" in the manual, for more.
+
+** New 'EXIT_SUCCESS' and 'EXIT_FAILURE' Scheme variables
+
+See "Processes" in the manual.
+
+** New C functions to disable automatic SMOB finalization
+
+The new 'scm_set_automatic_finalization_enabled' C function allows you
+to choose whether automatic object finalization should be enabled (as
+was the case until now, and still is by default.) This is meant for
+applications that are not thread-safe nor async-safe; such applications
+can disable automatic finalization and call the new 'scm_run_finalizers'
+function when appropriate.
+
+See the "Garbage Collecting Smobs" and "Smobs" sections in the manual.
+
+** Cross-compilation to ARM
+
+More ARM cross-compilation targets are supported: "arm.*eb",
+"^aarch64.*be", and "aarch64".
+
+* New deprecation
+
+** The undocumented and unused C function 'scm_string_hash' is now deprecated
+
+* Bugs fixed
+
+** Compiler
+*** 'call-with-prompt' does not truncate multiple-value returns
+ ()
+*** Use permissions of source file for compiled file
+ ()
+*** Fix bug when inlining some functions with optional arguments
+ ()
+*** Avoid quadratic expansion time in 'and' and 'or' macros
+ ()
+*** Fix expander bug introduced when adding support for tail patterns
+ ()
+*** Handle ~p in 'format' warnings ()
+*** Fix bug that exposed `list' invocations to CSE
+ ()
+*** Reduce eq? and eqv? over constants using equal?
+ ()
+*** Skip invalid .go files found in GUILE_LOAD_COMPILED_PATH
+
+** Threads
+*** Fix data races leading to corruption ()
+
+** Memory management
+*** Fix race between SMOB marking and finalization
+ ()
+
+** Ports
+*** Fix port position handling on binary input ports
+ ()
+*** Bytevector and custom binary ports to use ISO-8859-1
+ ()
+*** Fix buffer overrun with unbuffered custom binary input ports
+ ()
+*** Fix memory corruption that arose when using 'get-bytevector-n'
+ ()
+
+** System
+*** {get,set}sockopt now expect type 'int' for SO_SNDBUF/SO_RCVBUF
+*** 'system*' now available on MS-Windows
+*** 'open-pipe' now available on MS-Windows
+*** Better support for file names containing backslashes on Windows
+
+** Web
+*** 'split-and-decode-uri-path' no longer decodes "+" to space
+*** HTTP: Support date strings with a leading space for hours
+ ()
+*** HTTP: Accept empty reason phrases ()
+*** HTTP: 'Location' header can now contain URI references, not just
+ absolute URIs
+*** HTTP: Improve chunked-mode support ()
+*** HTTP: 'open-socket-for-uri' now sets better OS buffering parameters
+ ()
+
+** Miscellaneous
+*** Fix 'atan' procedure when applied to complex numbers
+*** Fix Texinfo to HTML conversion for @itemize and @acronym
+ ()
+*** 'bytevector-fill!' accepts fill arguments greater than 127
+ ()
+*** 'bytevector-copy' correctly copies SRFI-4 homogeneous vectors
+ ()
+*** 'strerror' no longer hangs when passed a non-integer argument
+ ()
+*** 'scm_boot_guile' now gracefully handles argc == 0
+ ()
+*** Fix 'SCM_SMOB_OBJECT_LOC' definition ()
+*** Fix bug where 'bit-count*' was not using its second argument
+*** SRFI-1 'length+' raises an error for non-lists and dotted lists
+ ()
+*** Add documentation for SXPath ()
+
Changes in 2.0.11 (since 2.0.10):
diff --git a/NEWS.guile-vm b/NEWS.guile-vm
deleted file mode 100644
index c82942f4f..000000000
--- a/NEWS.guile-vm
+++ /dev/null
@@ -1,57 +0,0 @@
-Guile-VM NEWS
-
-
-Guile-VM is a bytecode compiler and virtual machine for Guile.
-
-
-guile-vm 0.7 -- 2008-05-20
-==========================
-
-* Initial release with NEWS.
-
-* Revived from Keisuke Nishida's Guile-VM project from 2000-2001, with
- the help of Ludovic Courtès.
-
-* Meta-level changes
-** Updated to compile with Guile 1.8.
-** Documentation updated, including documentation on the instructions.
-** Added benchmarking and a test harness.
-
-* Changes to the inventory
-** Renamed the library from libguilevm to libguile-vm.
-** Added new executable script, guile-disasm.
-
-* New features
-** Add support for compiling macros, both defmacros and syncase macros.
-Primitive macros produced with the procedure->macro family of procedures
-are not supported, however.
-** Improvements to the REPL
-Multiple values support, readline integration, ice-9 history integration
-** Add support for eval-case
-The compiler recognizes compile-toplevel in addition to load-toplevel
-** Completely self-compiling
-Almost, anyway: not (system repl describe), because it uses GOOPS
-
-* Internal cleanups
-** Internal objects are now based on Guile records.
-** Guile-VM's code doesn't use the dot-syntax any more.
-** Changed (ice-9 match) for Kiselyov's pmatch.scm
-** New instructions: define, link-later, link-now, late-variable-{ref,set}
-** Object code now represented as u8vectors instead of strings.
-** Remove local import of an old version of slib
-
-* Bugfixes
-** The `optimize' procedure is coming out of bitrot
-** The Scheme compiler is now more strict about placement of internal
- defines
-** set! is now compiled differently from define
-** Module-level variables are now bound at first use instead of in the
- program prolog
-** Bugfix to load-program (stack misinterpretation)
-
-
-Copyright (C) 2008 Free Software Foundation, Inc.
-
-Copying and distribution of this file, with or without modification, are
-permitted in any medium without royalty provided the copyright notice
-and this notice are preserved.
diff --git a/README b/README
index 92d786c06..575ea5c3b 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is version 2.0 of Guile, Project GNU's extension language library.
+This is version 2.2 of Guile, Project GNU's extension language library.
Guile is an implementation of the Scheme programming language, packaged
as a library that can be linked into applications to give them their own
extension language. Guile supports other languages as well, giving
@@ -78,7 +78,7 @@ Guile requires the following external packages:
`utf*->string' procedures. It is available from
http://www.gnu.org/software/libunistring/ .
- - libgc, at least version 7.0
+ - libgc, at least version 7.2
libgc (aka. the Boehm-Demers-Weiser garbage collector) is the
conservative garbage collector used by Guile. It is available
@@ -124,7 +124,20 @@ instructions above, but it seems that a few systems still need special
treatment. If you can send us fixes for these problems, we'd be
grateful.
-
+FreeBSD 11.0:
+ For a build supporting threads, please `pkg install' the following
+ - pkgconf : provides pkg-config
+ - gmake : /usr/bin/make does not work
+ - boehm-gc-threaded : needed for threaded support
+
+ Configure as:
+
+ ./configure --with-bdw-gc=bdw-gc-threaded
+
+ Alternately if you want a Guile without threads, then install boehm-gc
+ and configure as:
+
+ ./configure --without-threads
Guile specific flags Accepted by Configure =================================
@@ -244,7 +257,7 @@ switches specific to Guile you may find useful in some circumstances.
Cross building Guile =====================================================
-As of Guile 2.0.x, the build process produces a library, libguile-2.0,
+As of Guile 2.2.x, the build process produces a library, libguile-2.2,
along with Guile "object files" containing bytecode to be interpreted by
Guile's virtual machine. The bytecode format depends on the endianness
and word size of the host CPU.
@@ -401,8 +414,6 @@ Documentation in Info format, in ${prefix}/info:
guile --- Guile reference manual.
- guile-tut --- Guile tutorial.
-
GOOPS --- GOOPS reference manual.
r5rs --- Revised(5) Report on the Algorithmic Language Scheme.
@@ -413,9 +424,7 @@ The Guile source tree is laid out as follows:
libguile:
The Guile Scheme interpreter --- both the object library
for you to link with your programs, and the executable you can run.
-ice-9: Guile's module system, initialization code, and other infrastructure.
-guile-config:
- Source for the guile-config script.
+module: Scheme libraries included with Guile.
guile-readline:
The glue code for using GNU readline with Guile. This
will be build when configure can find a recent enough readline
diff --git a/README.guile-vm b/README.guile-vm
deleted file mode 100644
index 72ab6c914..000000000
--- a/README.guile-vm
+++ /dev/null
@@ -1,117 +0,0 @@
-This is an attempt to revive the Guile-VM project by Keisuke Nishida
-written back in the years 2000 and 2001. Below are a few pointers to
-relevant threads on Guile's development mailing list.
-
-Enjoy!
-
-Ludovic Courts , Apr. 2005.
-
-
-Pointers
---------
-
-Status of the last release, 0.5
- http://lists.gnu.org/archive/html/guile-devel/2001-04/msg00266.html
-
-The very first release, 0.0
- http://sources.redhat.com/ml/guile/2000-07/msg00418.html
-
-Simple benchmark
- http://sources.redhat.com/ml/guile/2000-07/msg00425.html
-
-Performance, portability, GNU Lightning
- http://lists.gnu.org/archive/html/guile-devel/2001-03/msg00132.html
-
-Playing with GNU Lightning
- http://lists.gnu.org/archive/html/guile-devel/2001-03/msg00185.html
-
-On things left to be done
- http://lists.gnu.org/archive/html/guile-devel/2001-03/msg00146.html
-
-
----8<--- Original README below. -----------------------------------------
-
-Installation
-------------
-
-1. Install the latest Guile from CVS.
-
-2. Install Guile VM:
-
- % configure
- % make install
- % ln -s module/{guile,system,language} /usr/local/share/guile/
-
-3. Add the following lines to your ~/.guile:
-
- (use-modules (system vm core)
-
- (cond ((string=? (car (command-line)) "guile-vm")
- (use-modules (system repl repl))
- (start-repl 'scheme)
- (quit)))
-
-Example Session
----------------
-
- % guile-vm
- Guile Scheme interpreter 0.5 on Guile 1.4.1
- Copyright (C) 2001 Free Software Foundation, Inc.
-
- Enter `,help' for help.
- scheme@guile-user> (+ 1 2)
- 3
- scheme@guile-user> ,c -c (+ 1 2) ;; Compile into GLIL
- (@asm (0 1 0 0)
- (module-ref #f +)
- (const 1)
- (const 2)
- (tail-call 2))
- scheme@guile-user> ,c (+ 1 2) ;; Compile into object code
- Disassembly of #:
-
- nlocs = 0 nexts = 0
-
- 0 link "+" ;; (+ . ???)
- 3 variable-ref
- 4 make-int8:1 ;; 1
- 5 make-int8 2 ;; 2
- 7 tail-call 2
-
- scheme@guile-user> (define (add x y) (+ x y))
- scheme@guile-user> (add 1 2)
- 3
- scheme@guile-user> ,x add ;; Disassemble
- Disassembly of #:
-
- nargs = 2 nrest = 0 nlocs = 0 nexts = 0
-
- Bytecode:
-
- 0 object-ref 0 ;; (+ . #)
- 2 variable-ref
- 3 local-ref 0
- 5 local-ref 1
- 7 tail-call 2
-
- Objects:
-
- 0 (+ . #)
-
- scheme@guile-user>
-
-Compile Modules
----------------
-
-Use `guilec' to compile your modules:
-
- % cat fib.scm
- (define-module (fib) :export (fib))
- (define (fib n) (if (< n 2) 1 (+ (fib (- n 1)) (fib (- n 2)))))
-
- % guilec fib.scm
- Wrote fib.go
- % guile
- guile> (use-modules (fib))
- guile> (fib 8)
- 34
diff --git a/THANKS b/THANKS
index d5e8222fb..616d3b04b 100644
--- a/THANKS
+++ b/THANKS
@@ -134,6 +134,7 @@ For fixes or providing information which led to a fix:
Dan McMahill
Roger Mc Murtrie
Scott McPeak
+ David Michael
Glenn Michaels
Andrew Milkowski
Tim Mooney
@@ -170,6 +171,7 @@ For fixes or providing information which led to a fix:
Dale Smith
Cesar Strauss
Klaus Stehle
+ Kouhei Sutou
Rainer Tammer
Frank Terbeck
Samuel Thibault
@@ -199,6 +201,7 @@ For fixes or providing information which led to a fix:
Jon Wilson
Andy Wingo
Keith Wright
+ Ricardo Wurmus
William Xu
Atom X Zane
diff --git a/acinclude.m4 b/acinclude.m4
index 6a1470f24..70cb247aa 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -557,6 +557,8 @@ AC_DEFUN([GUILE_CHECK_GUILE_FOR_BUILD], [
if test "$GUILE_FOR_BUILD" = "not-found"; then
AC_MSG_ERROR([a native Guile $PACKAGE_VERSION is required to cross-build Guile])
fi
+ else
+ GUILE_FOR_BUILD=$(which "$GUILE_FOR_BUILD" || echo "$GUILE_FOR_BUILD")
fi
AC_MSG_CHECKING([guile for build])
AC_MSG_RESULT([$GUILE_FOR_BUILD])
diff --git a/am/bootstrap.am b/am/bootstrap.am
new file mode 100644
index 000000000..e0d4764f5
--- /dev/null
+++ b/am/bootstrap.am
@@ -0,0 +1,155 @@
+## Copyright (C) 2009, 2010, 2011, 2012, 2013,
+## 2014, 2015 Free Software Foundation, Inc.
+##
+## This file is part of GNU Guile.
+##
+## GNU Guile is free software; you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as
+## published by the Free Software Foundation; either version 3, or (at
+## your option) any later version.
+##
+## GNU Guile is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with GNU Guile; see the file COPYING.LESSER. If not,
+## write to the Free Software Foundation, Inc., 51 Franklin Street,
+## Fifth Floor, Boston, MA 02110-1301 USA
+
+# These variables can be set before you include bootstrap.am.
+GUILE_WARNINGS ?= -Wunbound-variable -Warity-mismatch -Wformat
+GUILE_OPTIMIZATIONS ?= -O2
+GUILE_TARGET ?= $(host)
+GUILE_BUILD_TAG ?= BOOTSTRAP
+
+GOBJECTS = $(SOURCES:%.scm=%.go)
+nobase_noinst_DATA = $(GOBJECTS)
+CLEANFILES = $(GOBJECTS)
+
+VM_TARGETS = system/vm/assembler.go system/vm/disassembler.go
+$(VM_TARGETS): $(top_builddir)/libguile/vm-operations.h
+
+AM_V_GUILEC = $(AM_V_GUILEC_$(V))
+AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY))
+AM_V_GUILEC_0 = @echo " $(GUILE_BUILD_TAG) GUILEC" $@;
+
+vpath %.scm @top_srcdir@/module
+
+SUFFIXES = .scm .go
+
+.scm.go:
+ $(AM_V_GUILEC)GUILE_AUTO_COMPILE=0 \
+ $(top_builddir)/meta/build-env \
+ guild compile --target="$(GUILE_TARGET)" \
+ $(GUILE_WARNINGS) $(GUILE_OPTIMIZATIONS) \
+ -L "$(abs_top_srcdir)/module" \
+ -L "$(abs_top_srcdir)/guile-readline" \
+ -o "$@" "$<"
+
+# A subset of sources that are used by the compiler. We can compile
+# these in any order; the order below is designed to hopefully result in
+# the lowest total compile time.
+SOURCES = \
+ ice-9/eval.scm \
+ ice-9/psyntax-pp.scm \
+ language/cps/intmap.scm \
+ language/cps/intset.scm \
+ language/cps/utils.scm \
+ ice-9/vlist.scm \
+ srfi/srfi-1.scm \
+ \
+ language/tree-il.scm \
+ language/tree-il/analyze.scm \
+ language/tree-il/canonicalize.scm \
+ language/tree-il/compile-cps.scm \
+ language/tree-il/debug.scm \
+ language/tree-il/effects.scm \
+ language/tree-il/fix-letrec.scm \
+ language/tree-il/optimize.scm \
+ language/tree-il/peval.scm \
+ language/tree-il/primitives.scm \
+ language/tree-il/spec.scm \
+ \
+ language/cps.scm \
+ language/cps/closure-conversion.scm \
+ language/cps/compile-bytecode.scm \
+ language/cps/constructors.scm \
+ language/cps/contification.scm \
+ language/cps/cse.scm \
+ language/cps/dce.scm \
+ language/cps/effects-analysis.scm \
+ language/cps/elide-values.scm \
+ language/cps/handle-interrupts.scm \
+ language/cps/licm.scm \
+ language/cps/peel-loops.scm \
+ language/cps/primitives.scm \
+ language/cps/prune-bailouts.scm \
+ language/cps/prune-top-level-scopes.scm \
+ language/cps/reify-primitives.scm \
+ language/cps/renumber.scm \
+ language/cps/rotate-loops.scm \
+ language/cps/optimize.scm \
+ language/cps/simplify.scm \
+ language/cps/self-references.scm \
+ language/cps/slot-allocation.scm \
+ language/cps/spec.scm \
+ language/cps/specialize-primcalls.scm \
+ language/cps/specialize-numbers.scm \
+ language/cps/split-rec.scm \
+ language/cps/type-checks.scm \
+ language/cps/type-fold.scm \
+ language/cps/types.scm \
+ language/cps/verify.scm \
+ language/cps/with-cps.scm \
+ \
+ language/scheme/spec.scm \
+ language/scheme/compile-tree-il.scm \
+ language/scheme/decompile-tree-il.scm \
+ \
+ language/bytecode.scm \
+ language/bytecode/spec.scm \
+ \
+ language/value/spec.scm \
+ \
+ system/base/pmatch.scm \
+ system/base/syntax.scm \
+ system/base/compile.scm \
+ system/base/language.scm \
+ system/base/lalr.scm \
+ system/base/message.scm \
+ system/base/target.scm \
+ system/base/types.scm \
+ system/base/ck.scm \
+ \
+ ice-9/boot-9.scm \
+ ice-9/ports.scm \
+ ice-9/r5rs.scm \
+ ice-9/deprecated.scm \
+ ice-9/binary-ports.scm \
+ ice-9/command-line.scm \
+ ice-9/control.scm \
+ ice-9/format.scm \
+ ice-9/getopt-long.scm \
+ ice-9/i18n.scm \
+ ice-9/match.scm \
+ ice-9/networking.scm \
+ ice-9/posix.scm \
+ ice-9/rdelim.scm \
+ ice-9/receive.scm \
+ ice-9/regex.scm \
+ ice-9/session.scm \
+ ice-9/pretty-print.scm \
+ \
+ system/vm/assembler.scm \
+ system/vm/debug.scm \
+ system/vm/disassembler.scm \
+ system/vm/dwarf.scm \
+ system/vm/elf.scm \
+ system/vm/frame.scm \
+ system/vm/linker.scm \
+ system/vm/loader.scm \
+ system/vm/program.scm \
+ system/vm/vm.scm \
+ system/foreign.scm
diff --git a/am/guilec b/am/guilec
index 5ef07faa4..fa2054eeb 100644
--- a/am/guilec
+++ b/am/guilec
@@ -1,7 +1,7 @@
# -*- makefile -*-
GOBJECTS = $(SOURCES:%.scm=%.go) $(ELISP_SOURCES:%.el=%.go)
-GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
+GUILE_WARNINGS = -Wunbound-variable -Wmacro-use-before-definition -Warity-mismatch -Wformat
moddir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
nobase_mod_DATA = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
@@ -28,7 +28,7 @@ SUFFIXES = .scm .el .go
.scm.go:
$(AM_V_GUILEC)GUILE_AUTO_COMPILE=0 \
- $(top_builddir)/meta/uninstalled-env \
+ $(top_builddir)/meta/build-env \
guild compile --target="$(host)" $(GUILE_WARNINGS) \
-L "$(abs_srcdir)" -L "$(abs_builddir)" \
-L "$(abs_top_srcdir)/guile-readline" \
@@ -36,7 +36,7 @@ SUFFIXES = .scm .el .go
.el.go:
$(AM_V_GUILEC)GUILE_AUTO_COMPILE=0 \
- $(top_builddir)/meta/uninstalled-env \
+ $(top_builddir)/meta/build-env \
guild compile --target="$(host)" $(GUILE_WARNINGS) \
-L "$(abs_srcdir)" -L "$(abs_builddir)" \
-L "$(abs_top_srcdir)/guile-readline" \
diff --git a/benchmark-suite/benchmarks/read.bm b/benchmark-suite/benchmarks/read.bm
index f0b25f541..a4ff9936f 100644
--- a/benchmark-suite/benchmarks/read.bm
+++ b/benchmark-suite/benchmarks/read.bm
@@ -51,20 +51,20 @@
(with-benchmark-prefix "read"
- (benchmark "_IONBF" 5 ;; this one is very slow
- (exercise-read (list _IONBF)))
+ (benchmark "'none" 5 ;; this one is very slow
+ (exercise-read (list 'none)))
- (benchmark "_IOLBF" 10
- (exercise-read (list _IOLBF)))
+ (benchmark "'line" 10
+ (exercise-read (list 'line)))
- (benchmark "_IOFBF 4096" 10
- (exercise-read (list _IOFBF 4096)))
+ (benchmark "'block 4096" 10
+ (exercise-read (list 'block 4096)))
- (benchmark "_IOFBF 8192" 10
- (exercise-read (list _IOFBF 8192)))
+ (benchmark "'block 8192" 10
+ (exercise-read (list 'block 8192)))
- (benchmark "_IOFBF 16384" 10
- (exercise-read (list _IOFBF 16384)))
+ (benchmark "'block 16384" 10
+ (exercise-read (list 'block 16384)))
(benchmark "small strings" 100000
(call-with-input-string small read))
diff --git a/benchmark-suite/benchmarks/uniform-vector-read.bm b/benchmark-suite/benchmarks/uniform-vector-read.bm
index 8cda82457..01b747836 100644
--- a/benchmark-suite/benchmarks/uniform-vector-read.bm
+++ b/benchmark-suite/benchmarks/uniform-vector-read.bm
@@ -43,7 +43,7 @@
(benchmark "uniform-vector-read!" 20000
(let ((input (open-input-file file-name)))
- (setvbuf input _IONBF)
+ (setvbuf input 'none)
(uniform-vector-read! buf input)
(close input)))
diff --git a/bootstrap/Makefile.am b/bootstrap/Makefile.am
new file mode 100644
index 000000000..496d5301a
--- /dev/null
+++ b/bootstrap/Makefile.am
@@ -0,0 +1,31 @@
+## Process this file with automake to produce Makefile.in.
+##
+## Copyright (C) 2009, 2010, 2011, 2012, 2013,
+## 2014, 2015 Free Software Foundation, Inc.
+##
+## This file is part of GUILE.
+##
+## GUILE is free software; you can redistribute it and/or modify it
+## under the terms of the GNU Lesser General Public License as
+## published by the Free Software Foundation; either version 3, or
+## (at your option) any later version.
+##
+## GUILE is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with GUILE; see the file COPYING.LESSER. If not,
+## write to the Free Software Foundation, Inc., 51 Franklin Street,
+## Fifth Floor, Boston, MA 02110-1301 USA
+
+
+GUILE_WARNINGS =
+GUILE_OPTIMIZATIONS = -O1
+
+include $(top_srcdir)/am/bootstrap.am
+
+# We must build the evaluator first, so that we can be sure to control
+# the stack.
+$(filter-out ice-9/eval.go, $(GOBJECTS)): ice-9/eval.go
diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index db9ed50a7..e789b13a8 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -1,15 +1,15 @@
-eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
+eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
& eval 'exec perl -wS "$0" $argv:q'
if 0;
# Generate a release announcement message.
-my $VERSION = '2012-06-08 06:53'; # UTC
+my $VERSION = '2016-01-12 23:09'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
# do its job. Otherwise, update this string manually.
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2017 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,15 +29,18 @@ my $VERSION = '2012-06-08 06:53'; # UTC
use strict;
use Getopt::Long;
-use Digest::MD5;
-eval { require Digest::SHA; }
- or eval 'use Digest::SHA1';
use POSIX qw(strftime);
(my $ME = $0) =~ s|.*/||;
my %valid_release_types = map {$_ => 1} qw (alpha beta stable);
my @archive_suffixes = ('tar.gz', 'tar.bz2', 'tar.lzma', 'tar.xz');
+my %digest_classes =
+ (
+ 'md5' => (eval { require Digest::MD5; } and 'Digest::MD5'),
+ 'sha1' => ((eval { require Digest::SHA; } and 'Digest::SHA')
+ or (eval { require Digest::SHA1; } and 'Digest::SHA1'))
+ );
my $srcdir = '.';
sub usage ($)
@@ -157,15 +160,13 @@ sub print_checksums (@)
foreach my $meth (qw (md5 sha1))
{
+ my $class = $digest_classes{$meth} or next;
foreach my $f (@file)
{
open IN, '<', $f
or die "$ME: $f: cannot open for reading: $!\n";
binmode IN;
- my $dig =
- ($meth eq 'md5'
- ? Digest::MD5->new->addfile(*IN)->hexdigest
- : Digest::SHA1->new->addfile(*IN)->hexdigest);
+ my $dig = $class->new->addfile(*IN)->hexdigest;
close IN;
print "$dig $f\n";
}
@@ -416,14 +417,15 @@ sub get_tool_versions ($$)
@url_dir_list
or (warn "URL directory name(s) not specified\n"), $fail = 1;
- my @tool_list = split ',', $bootstrap_tools;
+ my @tool_list = split ',', $bootstrap_tools
+ if $bootstrap_tools;
grep (/^gnulib$/, @tool_list) ^ defined $gnulib_version
and (warn "when specifying gnulib as a tool, you must also specify\n"
. "--gnulib-version=V, where V is the result of running git describe\n"
. "in the gnulib source directory.\n"), $fail = 1;
- exists $valid_release_types{$release_type}
+ !$release_type || exists $valid_release_types{$release_type}
or (warn "'$release_type': invalid release type\n"), $fail = 1;
@ARGV
@@ -550,6 +552,6 @@ EOF
## eval: (add-hook 'write-file-hooks 'time-stamp)
## time-stamp-start: "my $VERSION = '"
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
-## time-stamp-time-zone: "UTC"
+## time-stamp-time-zone: "UTC0"
## time-stamp-end: "'; # UTC"
## End:
diff --git a/build-aux/config.rpath b/build-aux/config.rpath
index ab6fd995f..af3c41559 100755
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -2,7 +2,7 @@
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
-# Copyright 1996-2014 Free Software Foundation, Inc.
+# Copyright 1996-2017 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit , 1996
#
@@ -367,11 +367,7 @@ else
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
- freebsd2.2*)
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- ;;
- freebsd2*)
+ freebsd2.[01]*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
@@ -548,13 +544,11 @@ case "$host_os" in
dgux*)
library_names_spec='$libname$shrext'
;;
+ freebsd[23].*)
+ library_names_spec='$libname$shrext$versuffix'
+ ;;
freebsd* | dragonfly*)
- case "$host_os" in
- freebsd[123]*)
- library_names_spec='$libname$shrext$versuffix' ;;
- *)
- library_names_spec='$libname$shrext' ;;
- esac
+ library_names_spec='$libname$shrext'
;;
gnu*)
library_names_spec='$libname$shrext'
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index f9ec9df76..3b71b36a2 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,10 +2,9 @@
# gendocs.sh -- generate a GNU manual in many formats. This script is
# mentioned in maintain.texi. See the help message below for usage details.
-scriptversion=2013-10-10.09
+scriptversion=2016-12-31.18
-# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
-# Free Software Foundation, Inc.
+# Copyright 2003-2017 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,17 +20,16 @@ scriptversion=2013-10-10.09
# along with this program. If not, see .
#
# Original author: Mohit Agarwal.
-# Send bug reports and any other correspondence to bug-texinfo@gnu.org.
+# Send bug reports and any other correspondence to bug-gnulib@gnu.org.
#
# The latest version of this script, and the companion template, is
-# available from Texinfo CVS:
-# http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs.sh
-# http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs_template
+# available from the Gnulib repository:
#
-# An up-to-date copy is also maintained in Gnulib (gnu.org/software/gnulib).
+# http://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/gendocs.sh
+# http://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/gendocs_template
# TODO:
-# - image importation was only implemented for HTML generated by
+# - image importing was only implemented for HTML generated by
# makeinfo. But it should be simple enough to adjust.
# - images are not imported in the source tarball. All the needed
# formats (PDF, PNG, etc.) should be included.
@@ -39,12 +37,12 @@ scriptversion=2013-10-10.09
prog=`basename "$0"`
srcdir=`pwd`
-scripturl="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/util/gendocs.sh"
-templateurl="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/util/gendocs_template"
+scripturl="http://git.savannah.gnu.org/cgit/gnulib.git/plain/build-aux/gendocs.sh"
+templateurl="http://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_template"
: ${SETLANG="env LANG= LC_MESSAGES= LC_ALL= LANGUAGE="}
: ${MAKEINFO="makeinfo"}
-: ${TEXI2DVI="texi2dvi -t @finalout"}
+: ${TEXI2DVI="texi2dvi"}
: ${DOCBOOK2HTML="docbook2html"}
: ${DOCBOOK2PDF="docbook2pdf"}
: ${DOCBOOK2TXT="docbook2txt"}
@@ -54,9 +52,27 @@ templateurl="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/
unset CDPATH
unset use_texi2html
+MANUAL_TITLE=
+PACKAGE=
+EMAIL=webmasters@gnu.org # please override with --email
+commonarg= # passed to all makeinfo/texi2html invcations.
+dirargs= # passed to all tools (-I dir).
+dirs= # -I directories.
+htmlarg="--css-ref=/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual"
+infoarg=--no-split
+generate_ascii=true
+generate_html=true
+generate_info=true
+generate_tex=true
+outdir=manual
+source_extra=
+split=node
+srcfile=
+texarg="-t @finalout"
+
version="gendocs.sh $scriptversion
-Copyright 2013 Free Software Foundation, Inc.
+Copyright 2017 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
@@ -75,11 +91,16 @@ Options:
-o OUTDIR write files into OUTDIR, instead of manual/.
-I DIR append DIR to the Texinfo search path.
--common ARG pass ARG in all invocations.
- --html ARG pass ARG to makeinfo or texi2html for HTML targets.
+ --html ARG pass ARG to makeinfo or texi2html for HTML targets,
+ instead of '$htmlarg'.
--info ARG pass ARG to makeinfo for Info, instead of --no-split.
--no-ascii skip generating the plain text output.
+ --no-html skip generating the html output.
+ --no-info skip generating the info output.
+ --no-tex skip generating the dvi and pdf output.
--source ARG include ARG in tar archive of sources.
--split HOW make split HTML by node, section, chapter; default node.
+ --tex ARG pass ARG to texi2dvi for DVI and PDF, instead of -t @finalout.
--texi2html use texi2html to make HTML target, with all split versions.
--docbook convert through DocBook too (xml, txt, html, pdf).
@@ -131,23 +152,9 @@ locale, since that's the language of most Texinfo manuals. If you
happen to have a non-English manual and non-English web site, see the
SETLANG setting in the source.
-Email bug reports or enhancement requests to bug-texinfo@gnu.org.
+Email bug reports or enhancement requests to bug-gnulib@gnu.org.
"
-MANUAL_TITLE=
-PACKAGE=
-EMAIL=webmasters@gnu.org # please override with --email
-commonarg= # passed to all makeinfo/texi2html invcations.
-dirargs= # passed to all tools (-I dir).
-dirs= # -I's directories.
-htmlarg=
-infoarg=--no-split
-generate_ascii=true
-outdir=manual
-source_extra=
-split=node
-srcfile=
-
while test $# -gt 0; do
case $1 in
-s) shift; srcfile=$1;;
@@ -159,8 +166,12 @@ while test $# -gt 0; do
--html) shift; htmlarg=$1;;
--info) shift; infoarg=$1;;
--no-ascii) generate_ascii=false;;
+ --no-html) generate_ascii=false;;
+ --no-info) generate_info=false;;
+ --no-tex) generate_tex=false;;
--source) shift; source_extra=$1;;
--split) shift; split=$1;;
+ --tex) shift; texarg=$1;;
--texi2html) use_texi2html=1;;
--help) echo "$usage"; exit 0;;
@@ -221,8 +232,9 @@ calcsize()
# copy_images OUTDIR HTML-FILE...
# -------------------------------
-# Copy all the images needed by the HTML-FILEs into OUTDIR. Look
-# for them in the -I directories.
+# Copy all the images needed by the HTML-FILEs into OUTDIR.
+# Look for them in . and the -I directories; this is simpler than what
+# makeinfo supports with -I, but hopefully it will suffice.
copy_images()
{
local odir
@@ -232,7 +244,7 @@ copy_images()
BEGIN {
\$me = '$prog';
\$odir = '$odir';
- @dirs = qw($dirs);
+ @dirs = qw(. $dirs);
}
" -e '
/ ${srcdir}/$PACKAGE-db.xml"
@@ -431,7 +457,8 @@ if test -n "$docbook"; then
mv $PACKAGE-db.pdf "$outdir/"
fi
-printf "\nMaking index file...\n"
+#
+printf "\nMaking index.html for $PACKAGE...\n"
if test -z "$use_texi2html"; then
CONDS="/%%IF *HTML_SECTION%%/,/%%ENDIF *HTML_SECTION%%/d;\
/%%IF *HTML_CHAPTER%%/,/%%ENDIF *HTML_CHAPTER%%/d"
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 1e5d556e9..c1c18c0c5 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,8 +1,8 @@
#!/bin/sh
# Print a version string.
-scriptversion=2012-12-31.23; # UTC
+scriptversion=2017-01-09.19; # UTC
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2017 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -85,9 +85,10 @@ Print a version string.
Options:
- --prefix prefix of git tags (default 'v')
+ --prefix PREFIX prefix of git tags (default 'v')
--match pattern for git tags to match (default: '\$prefix*')
- --fallback fallback version to use if \"git --version\" fails
+ --fallback VERSION
+ fallback version to use if \"git --version\" fails
--help display this help and exit
--version output version information and exit
@@ -104,9 +105,9 @@ while test $# -gt 0; do
case $1 in
--help) echo "$usage"; exit 0;;
--version) echo "$version"; exit 0;;
- --prefix) shift; prefix="$1";;
+ --prefix) shift; prefix=${1?};;
--match) shift; match="$1";;
- --fallback) shift; fallback="$1";;
+ --fallback) shift; fallback=${1?};;
-*)
echo "$0: Unknown option '$1'." >&2
echo "$0: Try '--help' for more information." >&2
@@ -205,7 +206,7 @@ v=`echo "$v" |sed "s/^$prefix//"`
# string we're using came from git. I.e., skip the test if it's "UNKNOWN"
# or if it came from .tarball-version.
if test "x$v_from_git" != x; then
- # Don't declare a version "dirty" merely because a time stamp has changed.
+ # Don't declare a version "dirty" merely because a timestamp has changed.
git update-index --refresh > /dev/null 2>&1
dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty=
@@ -220,12 +221,12 @@ if test "x$v_from_git" != x; then
fi
# Omit the trailing newline, so that m4_esyscmd can use the result directly.
-echo "$v" | tr -d "$nl"
+printf %s "$v"
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 78afff4e8..cf1642546 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -1,15 +1,15 @@
-eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
+eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
& eval 'exec perl -wS "$0" $argv:q'
if 0;
# Convert git log output to ChangeLog format.
-my $VERSION = '2012-07-29 06:11'; # UTC
+my $VERSION = '2016-03-22 21:49'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
# do its job. Otherwise, update this string manually.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2017 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -72,6 +72,9 @@ OPTIONS:
directory can be derived.
--since=DATE convert only the logs since DATE;
the default is to convert all log entries.
+ --until=DATE convert only the logs older than DATE.
+ --ignore-matching=PAT ignore commit messages whose first lines match PAT.
+ --ignore-line=PAT ignore lines of commit messages that match PAT.
--format=FMT set format string for commit subject and body;
see 'man git-log' for the list of format metacharacters;
the default is '%s%n%b%n'
@@ -220,10 +223,13 @@ sub git_dir_option($)
{
my $since_date;
+ my $until_date;
my $format_string = '%s%n%b%n';
my $amend_file;
my $append_dot = 0;
my $cluster = 1;
+ my $ignore_matching;
+ my $ignore_line;
my $strip_tab = 0;
my $strip_cherry_pick = 0;
my $srcdir;
@@ -232,10 +238,13 @@ sub git_dir_option($)
help => sub { usage 0 },
version => sub { print "$ME version $VERSION\n"; exit },
'since=s' => \$since_date,
+ 'until=s' => \$until_date,
'format=s' => \$format_string,
'amend=s' => \$amend_file,
'append-dot' => \$append_dot,
'cluster!' => \$cluster,
+ 'ignore-matching=s' => \$ignore_matching,
+ 'ignore-line=s' => \$ignore_line,
'strip-tab' => \$strip_tab,
'strip-cherry-pick' => \$strip_cherry_pick,
'srcdir=s' => \$srcdir,
@@ -243,6 +252,8 @@ sub git_dir_option($)
defined $since_date
and unshift @ARGV, "--since=$since_date";
+ defined $until_date
+ and unshift @ARGV, "--until=$until_date";
# This is a hash that maps an SHA1 to perl code (i.e., s/old/new/)
# that makes a correction in the log or attribution of that commit.
@@ -259,6 +270,7 @@ sub git_dir_option($)
my $prev_multi_paragraph;
my $prev_date_line = '';
my @prev_coauthors = ();
+ my @skipshas = ();
while (1)
{
defined (my $in = )
@@ -279,6 +291,19 @@ sub git_dir_option($)
$sha =~ /^[0-9a-fA-F]{40}$/
or die "$ME:$.: invalid SHA1: $sha\n";
+ my $skipflag = 0;
+ if (@skipshas)
+ {
+ foreach(@skipshas)
+ {
+ if ($sha =~ /^$_/)
+ {
+ $skipflag = $_;
+ last;
+ }
+ }
+ }
+
# If this commit's log requires any transformation, do it now.
my $code = $amend_code->{$sha};
if (defined $code)
@@ -306,7 +331,7 @@ sub git_dir_option($)
$rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
}
- my @line = split "\n", $rest;
+ my @line = split /[ \t]*\n/, $rest;
my $author_line = shift @line;
defined $author_line
or die "$ME:$.: unexpected EOF\n";
@@ -316,17 +341,18 @@ sub git_dir_option($)
# Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog
# `(tiny change)' annotation.
- my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line)
+ my $tiny = (grep (/^(?:Copyright-paperwork-exempt|Tiny-change):\s+[Yy]es$/, @line)
? ' (tiny change)' : '');
my $date_line = sprintf "%s %s$tiny\n",
- strftime ("%F", localtime ($1)), $2;
+ strftime ("%Y-%m-%d", localtime ($1)), $2;
my @coauthors = grep /^Co-authored-by:.*$/, @line;
# Omit meta-data lines we've already interpreted.
@line = grep !/^(?:Signed-off-by:[ ].*>$
|Co-authored-by:[ ]
|Copyright-paperwork-exempt:[ ]
+ |Tiny-change:[ ]
)/x, @line;
# Remove leading and trailing blank lines.
@@ -336,68 +362,109 @@ sub git_dir_option($)
while ($line[$#line] =~ /^\s*$/) { pop @line; }
}
- # Record whether there are two or more paragraphs.
- my $multi_paragraph = grep /^\s*$/, @line;
+ # Handle Emacs gitmerge.el "skipped" commits.
+ # Yes, this should be controlled by an option. So sue me.
+ if ( grep /^(; )?Merge from /, @line )
+ {
+ my $found = 0;
+ foreach (@line)
+ {
+ if (grep /^The following commit.*skipped:$/, $_)
+ {
+ $found = 1;
+ ## Reset at each merge to reduce chance of false matches.
+ @skipshas = ();
+ next;
+ }
+ if ($found && $_ =~ /^([0-9a-fA-F]{7,}) [^ ]/)
+ {
+ push ( @skipshas, $1 );
+ }
+ }
+ }
- # Format 'Co-authored-by: A U Thor ' lines in
- # standard multi-author ChangeLog format.
- for (@coauthors)
+ # Ignore commits that match the --ignore-matching pattern, if specified.
+ if (defined $ignore_matching && @line && $line[0] =~ /$ignore_matching/)
{
- s/^Co-authored-by:\s*/\t /;
- s/\s* ;
-
- /<.*?@.*\..*>/
- or warn "$ME: warning: missing email address for "
- . substr ($_, 5) . "\n";
+ $skipflag = 1;
+ }
+ elsif ($skipflag)
+ {
+ ## Perhaps only warn if a pattern matches more than once?
+ warn "$ME: warning: skipping $sha due to $skipflag\n";
}
- # If clustering of commit messages has been disabled, if this header
- # would be different from the previous date/name/email/coauthors header,
- # or if this or the previous entry consists of two or more paragraphs,
- # then print the header.
- if ( ! $cluster
- || $date_line ne $prev_date_line
- || "@coauthors" ne "@prev_coauthors"
- || $multi_paragraph
- || $prev_multi_paragraph)
+ if (! $skipflag)
{
- $prev_date_line eq ''
- or print "\n";
- print $date_line;
- @coauthors
- and print join ("\n", @coauthors), "\n";
- }
- $prev_date_line = $date_line;
- @prev_coauthors = @coauthors;
- $prev_multi_paragraph = $multi_paragraph;
-
- # If there were any lines
- if (@line == 0)
- {
- warn "$ME: warning: empty commit message:\n $date_line\n";
- }
- else
- {
- if ($append_dot)
+ if (defined $ignore_line && @line)
{
- # If the first line of the message has enough room, then
- if (length $line[0] < 72)
- {
- # append a dot if there is no other punctuation or blank
- # at the end.
- $line[0] =~ /[[:punct:]\s]$/
- or $line[0] .= '.';
- }
+ @line = grep ! /$ignore_line/, @line;
+ while ($line[$#line] =~ /^\s*$/) { pop @line; }
}
- # Remove one additional leading TAB from each line.
- $strip_tab
- and map { s/^\t// } @line;
+ # Record whether there are two or more paragraphs.
+ my $multi_paragraph = grep /^\s*$/, @line;
- # Prefix each non-empty line with a TAB.
- @line = map { length $_ ? "\t$_" : '' } @line;
+ # Format 'Co-authored-by: A U Thor ' lines in
+ # standard multi-author ChangeLog format.
+ for (@coauthors)
+ {
+ s/^Co-authored-by:\s*/\t /;
+ s/\s* ;
- print "\n", join ("\n", @line), "\n";
+ /<.*?@.*\..*>/
+ or warn "$ME: warning: missing email address for "
+ . substr ($_, 5) . "\n";
+ }
+
+ # If clustering of commit messages has been disabled, if this header
+ # would be different from the previous date/name/etc. header,
+ # or if this or the previous entry consists of two or more paragraphs,
+ # then print the header.
+ if ( ! $cluster
+ || $date_line ne $prev_date_line
+ || "@coauthors" ne "@prev_coauthors"
+ || $multi_paragraph
+ || $prev_multi_paragraph)
+ {
+ $prev_date_line eq ''
+ or print "\n";
+ print $date_line;
+ @coauthors
+ and print join ("\n", @coauthors), "\n";
+ }
+ $prev_date_line = $date_line;
+ @prev_coauthors = @coauthors;
+ $prev_multi_paragraph = $multi_paragraph;
+
+ # If there were any lines
+ if (@line == 0)
+ {
+ warn "$ME: warning: empty commit message:\n $date_line\n";
+ }
+ else
+ {
+ if ($append_dot)
+ {
+ # If the first line of the message has enough room, then
+ if (length $line[0] < 72)
+ {
+ # append a dot if there is no other punctuation or blank
+ # at the end.
+ $line[0] =~ /[[:punct:]\s]$/
+ or $line[0] .= '.';
+ }
+ }
+
+ # Remove one additional leading TAB from each line.
+ $strip_tab
+ and map { s/^\t// } @line;
+
+ # Prefix each non-empty line with a TAB.
+ @line = map { length $_ ? "\t$_" : '' } @line;
+
+ print "\n", join ("\n", @line), "\n";
+ }
}
defined ($in = )
@@ -427,6 +494,6 @@ sub git_dir_option($)
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "my $VERSION = '"
# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "'; # UTC"
# End:
diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update
index 7af2f185f..a8ed60952 100755
--- a/build-aux/gnu-web-doc-update
+++ b/build-aux/gnu-web-doc-update
@@ -2,9 +2,9 @@
# Run this after each non-alpha release, to update the web documentation at
# http://www.gnu.org/software/$pkg/manual/
-VERSION=2012-12-16.14; # UTC
+VERSION=2016-01-12.23; # UTC
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -40,6 +40,7 @@ assumes all documentation is in the doc/ sub-directory.
Options:
-C, --builddir=DIR location of (configured) Makefile (default: .)
-n, --dry-run don't actually commit anything
+ -m, --mirror remove out of date files from document server
--help print this help, then exit
--version print version number, then exit
@@ -107,6 +108,7 @@ find_tool XARGS gxargs xargs
builddir=.
dryrun=
+rm_stale='echo'
while test $# != 0
do
# Handle --option=value by splitting apart and putting back on argv.
@@ -115,7 +117,7 @@ do
opt=$(echo "$1" | sed -e 's/=.*//')
val=$(echo "$1" | sed -e 's/[^=]*=//')
shift
- set dummy "$opt" "$val" ${1+"$@"}; shift
+ set dummy "$opt" "$val" "$@"; shift
;;
esac
@@ -123,6 +125,7 @@ do
--help|--version) ${1#--};;
-C|--builddir) shift; builddir=$1; shift ;;
-n|--dry-run) dryrun=echo; shift;;
+ -m|--mirror) rm_stale=''; shift;;
--*) die "unrecognized option: $1";;
*) break;;
esac
@@ -159,6 +162,7 @@ $GIT submodule update --recursive
./bootstrap
srcdir=$(pwd)
cd "$builddir"
+builddir=$(pwd)
./config.status --recheck
./config.status
make
@@ -175,13 +179,25 @@ $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
cd $tmp/$pkg/manual
# Add all the files. This is simpler than trying to add only the
- # new ones because of new directories: it would require iterating on
- # adding the outer directories, and then their contents.
- #
- # find guarantees that we add outer directories first.
- find . -name CVS -prune -o -print \
+ # new ones because of new directories
+ # First add non empty dirs individually
+ find . -name CVS -prune -o -type d \! -empty -print \
+ | $XARGS -n1 --no-run-if-empty -- $dryrun $CVS add -ko
+ # Now add all files
+ find . -name CVS -prune -o -type f -print \
| $XARGS --no-run-if-empty -- $dryrun $CVS add -ko
+ # Report/Remove stale files
+ # excluding doc server specific files like CVS/* and .symlinks
+ if test -n "$rm_stale"; then
+ echo 'Consider the --mirror option if all of the manual is generated,' >&2
+ echo 'which will run `cvs remove` to remove stale files.' >&2
+ fi
+ { find . \( -name CVS -o -type f -name '.*' \) -prune -o -type f -print
+ (cd "$builddir"/doc/manual/ && find . -type f -print | sed p)
+ } | sort | uniq -u \
+ | $XARGS --no-run-if-empty -- ${rm_stale:-$dryrun} $CVS remove -f
+
$dryrun $CVS ci -m $version
)
@@ -189,6 +205,6 @@ $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "VERSION="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/build-aux/gnupload b/build-aux/gnupload
index 2da97d894..d4d95ee9b 100755
--- a/build-aux/gnupload
+++ b/build-aux/gnupload
@@ -1,9 +1,9 @@
#!/bin/sh
# Sign files and upload them.
-scriptversion=2013-03-19.17; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2017 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -435,6 +435,6 @@ exit 0
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/build-aux/snippet/arg-nonnull.h b/build-aux/snippet/arg-nonnull.h
index 9ee8b1555..1e62cc898 100644
--- a/build-aux/snippet/arg-nonnull.h
+++ b/build-aux/snippet/arg-nonnull.h
@@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h
index 67b12335d..f03f3591c 100644
--- a/build-aux/snippet/c++defs.h
+++ b/build-aux/snippet/c++defs.h
@@ -1,5 +1,5 @@
/* C++ compatible function declaration macros.
- Copyright (C) 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2010-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -17,6 +17,15 @@
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
+/* Begin/end the GNULIB_NAMESPACE namespace. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
+# define _GL_END_NAMESPACE }
+#else
+# define _GL_BEGIN_NAMESPACE
+# define _GL_END_NAMESPACE
+#endif
+
/* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some
@@ -111,14 +120,25 @@
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
- */
+
+ Wrapping rpl_func in an object with an inline conversion operator
+ avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
- rettype (*const func) parameters = ::rpl_func; \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::rpl_func; \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
@@ -135,8 +155,15 @@
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
- rettype (*const func) parameters = \
- reinterpret_cast(::rpl_func); \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast(::rpl_func); \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
@@ -150,19 +177,24 @@
is defined.
Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
- */
+
+ Wrapping func in an object with an inline conversion operator
+ avoids a reference to func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
- /* If we were to write
- rettype (*const func) parameters = ::func;
- like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
- better (remove an indirection through a 'static' pointer variable),
- but then the _GL_CXXALIASWARN macro below would cause a warning not only
- for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
-# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
- namespace GNULIB_NAMESPACE \
- { \
- static rettype (*func) parameters = ::func; \
- } \
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::func; \
+ } \
+ } func = {}; \
+ } \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
@@ -178,8 +210,15 @@
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \
{ \
- static rettype (*func) parameters = \
- reinterpret_cast(::func); \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast(::func); \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
@@ -202,9 +241,15 @@
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \
{ \
- static rettype (*func) parameters = \
- reinterpret_cast( \
- (rettype2(*)parameters2)(::func)); \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast((rettype2 (*) parameters2)(::func)); \
+ } \
+ } func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy
#else
diff --git a/build-aux/snippet/unused-parameter.h b/build-aux/snippet/unused-parameter.h
deleted file mode 100644
index 41d9510ca..000000000
--- a/build-aux/snippet/unused-parameter.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* A C macro for declaring that specific function parameters are not used.
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see . */
-
-/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter
- declarations for parameters that are not used. This helps to reduce
- warnings, such as from GCC -Wunused-parameter. The syntax is as follows:
- type param _GL_UNUSED_PARAMETER
- or more generally
- param_decl _GL_UNUSED_PARAMETER
- For example:
- int param _GL_UNUSED_PARAMETER
- int *(*param)(void) _GL_UNUSED_PARAMETER
- Other possible, but obscure and discouraged syntaxes:
- int _GL_UNUSED_PARAMETER *(*param)(void)
- _GL_UNUSED_PARAMETER int *(*param)(void)
- */
-#ifndef _GL_UNUSED_PARAMETER
-# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__))
-# else
-# define _GL_UNUSED_PARAMETER
-# endif
-#endif
diff --git a/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h
index 1c4d7bd4e..3c0eb579f 100644
--- a/build-aux/snippet/warn-on-use.h
+++ b/build-aux/snippet/warn-on-use.h
@@ -1,5 +1,5 @@
/* A C macro for emitting warnings if a function is used.
- Copyright (C) 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2010-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
index 4c76c75d7..4e3f3a265 100755
--- a/build-aux/useless-if-before-free
+++ b/build-aux/useless-if-before-free
@@ -1,16 +1,16 @@
-eval '(exit $?0)' && eval 'exec perl -wST "$0" ${1+"$@"}'
+eval '(exit $?0)' && eval 'exec perl -wST "$0" "$@"'
& eval 'exec perl -wST "$0" $argv:q'
if 0;
# Detect instances of "if (p) free (p);".
# Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces.
-my $VERSION = '2012-01-06 07:23'; # UTC
+my $VERSION = '2016-08-01 17:47'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
# do its job. Otherwise, update this string manually.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2017 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -129,6 +129,9 @@ sub is_NULL ($)
$err = EXIT_ERROR, next;
while (defined (my $line = ))
{
+ # Skip non-matching lines early to save time
+ $line =~ /\bif\b/
+ or next;
while ($line =~
/\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\)
# 1 2 3
@@ -202,6 +205,6 @@ EOF
## eval: (add-hook 'write-file-hooks 'time-stamp)
## time-stamp-start: "my $VERSION = '"
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
-## time-stamp-time-zone: "UTC"
+## time-stamp-time-zone: "UTC0"
## time-stamp-end: "'; # UTC"
## End:
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index b2bca54c9..2d17eaf69 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -2,9 +2,9 @@
# List version-controlled file names.
# Print a version string.
-scriptversion=2011-05-16.22; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2017 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -108,6 +108,6 @@ done
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/configure.ac b/configure.ac
index 19e00d818..374b4297a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ dnl
define(GUILE_CONFIGURE_COPYRIGHT,[[
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Free Software Foundation, Inc.
This file is part of GUILE
@@ -39,7 +39,7 @@ dnl Use `serial-tests' so the output `check-guile' is not hidden
dnl (`parallel-tests' is the default in Automake 1.13.)
dnl `serial-tests' was introduced in Automake 1.12.
AM_INIT_AUTOMAKE([1.12 gnu no-define -Wall -Wno-override \
- serial-tests color-tests dist-xz])
+ serial-tests color-tests dist-lzip dist-xz])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)])
AC_COPYRIGHT(GUILE_CONFIGURE_COPYRIGHT)
@@ -66,6 +66,18 @@ AC_LIBTOOL_WIN32_DLL
AC_PROG_INSTALL
AC_PROG_CC
+
+# Sadly, there is no released version of Autoconf with a nice
+# C11-ensuring macro. This should work for gcc/clang within the last 5
+# years though.
+AC_MSG_CHECKING([how to enable C11 support])
+if test "$GCC" = yes; then
+ AC_MSG_RESULT([-std=gnu11])
+ CC="$CC -std=gnu11"
+else
+ AC_MSG_RESULT([assuming $CC supports C11 by default])
+fi
+
gl_EARLY
AC_PROG_CPP
AC_PROG_SED
@@ -83,7 +95,8 @@ AC_DEFINE([GNULIB_LOCK], [1],
[Define to allow Gnulib modules to use Guile's locks.])
-AC_PROG_CC_C89
+dnl Guile needs C99 or later.
+gl_PROG_CC_C99
# for per-target cflags in the libguile subdir
AM_PROG_CC_C_O
@@ -313,6 +326,7 @@ AC_SUBST([SCM_I_GSC_T_PTRDIFF])
AC_CHECK_HEADERS([stdint.h])
AC_CHECK_HEADERS([inttypes.h])
+AC_CHECK_HEADERS([stdatomic.h])
AC_CHECK_SIZEOF(intmax_t)
@@ -617,6 +631,18 @@ AC_SUBST([SCM_I_GSC_T_UINTPTR])
AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H])
AC_SUBST([SCM_I_GSC_NEEDS_INTTYPES_H])
+AC_MSG_CHECKING([for which prebuilt binary set to use during bootstrap])
+SCM_PREBUILT_BINARIES=
+case "$ac_cv_c_bigendian-$ac_cv_sizeof_void_p" in
+ yes-8) SCM_PREBUILT_BINARIES=64-bit-big-endian;;
+ yes-4) SCM_PREBUILT_BINARIES=32-bit-big-endian;;
+ no-8) SCM_PREBUILT_BINARIES=64-bit-little-endian;;
+ no-4) SCM_PREBUILT_BINARIES=32-bit-little-endian;;
+ *) AC_MSG_ERROR([Unexpected endianness+pointer size combination.])
+esac
+AC_MSG_RESULT($SCM_PREBUILT_BINARIES)
+AC_SUBST([SCM_PREBUILT_BINARIES])
+
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
@@ -715,7 +741,7 @@ case $host in
AC_CHECK_HEADER(winsock2.h, [AC_DEFINE([HAVE_WINSOCK2_H], 1,
[Define if you have the header file.])])
AC_CHECK_LIB(ws2_32, main)
- AC_LIBOBJ([win32-uname])
+ AC_LIBOBJ([posix-w32])
if test "$enable_shared" = yes ; then
EXTRA_DEFS="-DSCM_IMPORT"
AC_DEFINE([USE_DLL_IMPORT], 1,
@@ -752,21 +778,22 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
# isblank - available as a GNU extension or in C99
# _NSGetEnviron - Darwin specific
# strcoll_l, newlocale, uselocale, utimensat - POSIX.1-2008
+# strtol_l - non-POSIX, found in glibc
# fork - unavailable on Windows
# sched_getaffinity, sched_setaffinity - GNU extensions (glibc)
# sendfile - non-POSIX, found in glibc
#
AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \
fesetround ftime ftruncate fchown fchmod getcwd geteuid getsid \
- gettimeofday gmtime_r ioctl lstat mkdir mknod nice \
- readdir_r readdir64_r readlink rename rmdir setegid seteuid \
- setlocale setpgid setsid sigaction siginterrupt stat64 \
+ gettimeofday getuid getgid gmtime_r ioctl lstat mkdir mknod nice \
+ readlink rename rmdir setegid seteuid \
+ setlocale setuid setgid setpgid setsid sigaction siginterrupt stat64 \
strptime symlink sync sysconf tcgetpgrp tcsetpgrp uname waitpid \
strdup system usleep atexit on_exit chown link fcntl ttyname getpwent \
getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp \
- index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron \
- strcoll strcoll_l newlocale uselocale utimensat sched_getaffinity \
- sched_setaffinity sendfile])
+ index bcopy memcpy rindex truncate isblank _NSGetEnviron \
+ strcoll strcoll_l strtod_l strtol_l newlocale uselocale utimensat \
+ sched_getaffinity sched_setaffinity sendfile])
# Reasons for testing:
# netdb.h - not in mingw
@@ -865,6 +892,57 @@ main (void)
esac
fi
+# Cygwin and Hurd (circa 2017) and various prior versions defined stub
+# versions of the virtual and profiling itimers that would always fail
+# when called.
+if test "$ac_cv_func_getitimer" = yes; then
+
+ AC_CACHE_CHECK([whether getitimer(ITIMER_PROF) is usable],
+ guile_cv_use_getitimer_prof,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include
+int
+main (void)
+{
+ struct itimerval I;
+ if (getitimer (ITIMER_PROF, &I) == 0)
+ return 0; /* good */
+ else
+ return 1; /* bad */
+}]])],
+ [guile_cv_use_getitimer_prof=yes],
+ [guile_cv_use_getitimer_prof=no],
+ [guile_cv_use_getitimer_prof="yes, hopefully (cross-compiling)"])])
+ case $guile_cv_use_getitimer_prof in
+ yes*)
+ AC_DEFINE([HAVE_USABLE_GETITIMER_PROF], 1, [Define to 1 if getitimer(ITIMER_PROF, ...) is functional])
+ ;;
+ esac
+
+ AC_CACHE_CHECK([whether getitimer(ITIMER_VIRTUAL) is usable],
+ guile_cv_use_getitimer_virtual,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include
+int
+main (void)
+{
+ struct itimerval I;
+ if (getitimer (ITIMER_VIRTUAL, &I) == 0)
+ return 0; /* good */
+ else
+ return 1; /* bad */
+}]])],
+ [guile_cv_use_getitimer_virtual=yes],
+ [guile_cv_use_getitimer_virtual=no],
+ [guile_cv_use_getitimer_virtual="yes, hopefully (cross-compiling)"])])
+ case $guile_cv_use_getitimer_virtual in
+ yes*)
+ AC_DEFINE([HAVE_USABLE_GETITIMER_VIRTUAL], 1, [Define to 1 if getitimer(ITIMER_VIRTUAL, ...) is functional])
+ ;;
+ esac
+fi
+
+
AC_CACHE_SAVE
dnl GMP tests
@@ -890,6 +968,13 @@ if test "x$LTLIBUNISTRING" = "x"; then
AC_MSG_ERROR([GNU libunistring is required, please install it.])
fi
+dnl Sloppy check to make sure people aren't trying to use too-old libunistring.
+case "$LIBUNISTRING_VERSION" in
+ 0.9.0 | 0.9.1 | 0.9.2 )
+ AC_MSG_ERROR([libunistring too old. Please install a recent libunistring (>= 0.9.3).])
+ ;;
+esac
+
GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT
if test "x$ac_cv_libunistring_with_iconv_support" != "xyes"; then
AC_MSG_ERROR([No iconv support. Please recompile libunistring with iconv enabled.])
@@ -1124,14 +1209,15 @@ if test "$enable_regex" = yes; then
AC_DEFINE([ENABLE_REGEX], 1, [Define when regex support is enabled.])
fi
-AC_REPLACE_FUNCS([strerror memmove mkstemp])
+AC_REPLACE_FUNCS([strerror memmove])
# Reasons for testing:
# asinh, acosh, atanh, trunc - C99 standard, generally not available on
# older systems
# sincos - GLIBC extension
+# __sincos - APPLE extension
#
-AC_CHECK_FUNCS(asinh acosh atanh copysign finite sincos trunc)
+AC_CHECK_FUNCS(asinh acosh atanh copysign finite sincos __sincos trunc)
# C99 specifies isinf and isnan as macros.
# HP-UX provides only macros, no functions.
@@ -1246,7 +1332,11 @@ main (int argc, char **argv)
# Boehm's GC library
#
#--------------------------------------------------------------------
-PKG_CHECK_MODULES([BDW_GC], [bdw-gc >= 7.2])
+AC_MSG_CHECKING(for which bdw-gc pkg-config file to use)
+AC_ARG_WITH(bdw_gc, [ --with-bdw-gc=PKG name of BDW-GC pkg-config file],
+ [bdw_gc="$withval"], [bdw_gc=bdw-gc])
+AC_MSG_RESULT($bdw_gc)
+PKG_CHECK_MODULES([BDW_GC], [$bdw_gc >= 7.2])
save_LIBS="$LIBS"
LIBS="$BDW_GC_LIBS $LIBS"
@@ -1256,7 +1346,7 @@ CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
AC_CHECK_FUNCS([GC_pthread_exit GC_pthread_cancel GC_pthread_sigmask])
# Functions from GC 7.3.
-AC_CHECK_FUNCS([GC_move_disappearing_link])
+AC_CHECK_FUNCS([GC_move_disappearing_link GC_is_heap_ptr])
LIBS="$save_LIBS"
@@ -1643,12 +1733,19 @@ AC_CONFIG_FILES([
test-suite/standalone/Makefile
test-suite/vm/Makefile
meta/Makefile
+ bootstrap/Makefile
module/Makefile
+ prebuilt/Makefile
+ prebuilt/x86_64-unknown-linux-gnu/Makefile
+ prebuilt/i686-pc-linux-gnu/Makefile
+ prebuilt/mips-unknown-linux-gnu/Makefile
])
+
GUILE_CONFIG_SCRIPT([check-guile])
GUILE_CONFIG_SCRIPT([benchmark-guile])
GUILE_CONFIG_SCRIPT([meta/guile])
+GUILE_CONFIG_SCRIPT([meta/build-env])
GUILE_CONFIG_SCRIPT([meta/uninstalled-env])
GUILE_CONFIG_SCRIPT([meta/gdb-uninstalled-guile])
GUILE_CONFIG_SCRIPT([libguile/guile-snarf])
diff --git a/doc/gendocs_template b/doc/gendocs_template
index 4836df787..178f6cb4c 100644
--- a/doc/gendocs_template
+++ b/doc/gendocs_template
@@ -1,5 +1,6 @@
-%%TITLE%% - GNU Project - Free Software Foundation (FSF)
+
+%%TITLE%% - GNU Project - Free Software Foundation
%%TITLE%%
@@ -67,19 +68,22 @@ script.)
diff --git a/doc/gendocs_template_min b/doc/gendocs_template_min
new file mode 100644
index 000000000..112fa3bfb
--- /dev/null
+++ b/doc/gendocs_template_min
@@ -0,0 +1,93 @@
+
+
+
+
+
+%%TITLE%% - GNU Project - Free Software Foundation
+
+
+
+
+
+
+%%TITLE%%
+
+Free Software Foundation
+last updated %%DATE%%
+
+
+
+
+
+
+
+This manual (%%PACKAGE%%) is available in the following formats:
+
+
+
+(This page generated by the %%SCRIPTNAME%%
+script .)
+
+
+
+Copyright © 2017 Free Software Foundation, Inc.
+
+This page is licensed under a Creative
+Commons Attribution-NoDerivs 3.0 United States License .
+
+
+
+
+
+
diff --git a/doc/guile.1 b/doc/guile.1
index 5d8b4e158..7b3d23292 100644
--- a/doc/guile.1
+++ b/doc/guile.1
@@ -125,7 +125,7 @@ is being run interactively.
Compile source files automatically (default behavior).
.
.TP
-.B --no-autocompile
+.B --no-auto-compile
Disable automatic source file compilation.
.
.TP
diff --git a/doc/maint/ChangeLog-2008 b/doc/maint/ChangeLog-2008
deleted file mode 100644
index 0c6e618d6..000000000
--- a/doc/maint/ChangeLog-2008
+++ /dev/null
@@ -1,75 +0,0 @@
-2004-08-25 Marius Vollmer
-
- * docstring.el (docstring-process-alist): Consider entries in
- reverse order. That puts them in new-docstrings.texi in the same
- order as in the C source.
-
-2004-08-23 Marius Vollmer
-
- * docstring.el: Replaced all "@c module" markers with "@c
- module-for-docstring", making it less likely to collide with a
- real commentary.
-
-2002-10-19 Neil Jerram
-
- * guile.texi: Replaced by regenerated libguile version.
-
-2002-07-10 Gary Houston
-
- * docstring.el: optional 2nd environment variable to locate
- built files.
-
-2002-07-09 Gary Houston
-
- * docstring.el: defined caddr, used in several places but missing
- for some reason.
-
-2002-04-02 Thien-Thi Nguyen
-
- * doctring.el: List commands in commentary; nfc.
-
-2002-03-15 Neil Jerram
-
- * guile.texi: Replaced by regenerated libguile version.
-
-2002-03-12 Neil Jerram
-
- * guile.texi: Replaced by regenerated libguile version.
-
-2002-03-08 Neil Jerram
-
- * docstring.el (docstring-libguile-directory,
- docstring-display-location, docstring-show-source): New.
-
-2001-11-16 Neil Jerram
-
- * guile.texi: Replaced by regenerated libguile version.
-
- * docstring.el (make-module-description-list): Exclude @deffn's
- with category {C Function}.
- (docstring-process-alist): Bind key "d" to
- docstring-ediff-this-line in the docstring output buffer.
-
-2001-11-13 Neil Jerram
-
- * guile.texi: Replaced by libguile version (after automatically
- updating docstrings in the reference manual).
-
-2001-11-07 Neil Jerram
-
- * guile.texi: Replaced by libguile version (after automatically
- updating docstrings in the reference manual).
-
- * docstring.el (docstring-manual-directory): Added "/ref" to end.
- (docstring-manual-files): Now calculated automatically, since by
- definition all the .texi files in doc/ref are reference manual
- files.
-
-2001-04-03 Martin Grabmueller
-
- * guile.texi: Automated docstring merging.
-
-2001-03-23 Neil Jerram
-
- * ChangeLog, README, docstring.el, guile.texi: New files.
-
diff --git a/doc/maint/README b/doc/maint/README
deleted file mode 100644
index adfa13f82..000000000
--- a/doc/maint/README
+++ /dev/null
@@ -1,35 +0,0 @@
-README for guile-core/doc/maint -*- text -*-
-
-The files in this directory are used by the maintainers to automate
-the process of updating the Guile reference manual when the docstrings
-in the libguile C source change.
-
-- ChangeLog is the change log for files in this directory.
-
-- README is this file.
-
-- docstring.el is a helpful Emacs Lisp library (see source for
- customization). The two key entry points are:
- `docstring-process-module' and
- `docstring-ediff-this-line'.
-
-- guile.texi is a snapshot of the built file libguile/guile.texi,
- copied last time the reference manual was determined to be in sync
- with the libguile source.
-
-docstring.el requires the setting of an environment variable, e.g.,
-
-export GUILE_MAINTAINER_GUILE_CORE_DIR=$HOME/guile/guile-core
-
-If the build directory differs from the source directory, an additional
-variable is required:
-
-export GUILE_MAINTAINER_BUILD_CORE_DIR=$HOME/guile/guile-core-build
-
-If you've just fixed a docstring in, say, ../libguile/strop.c, do in emacs:
-
- M-x load-file RET .../doc/maint/docstring.el RET
- M-x docstring-process-module RET (guile) RET
-
-Save all modified .texi files and copy the current ../libguile/guile.texi
-to ./guile.texi, then commit. See elisp var `docstring-snarfed-roots'.
diff --git a/doc/maint/docstring.el b/doc/maint/docstring.el
deleted file mode 100644
index ef271930f..000000000
--- a/doc/maint/docstring.el
+++ /dev/null
@@ -1,622 +0,0 @@
-;;; docstring.el --- utilities for Guile docstring maintenance
-;;;
-;;; Copyright (C) 2001, 2004 Neil Jerram
-;;;
-;;; This file is not part of GUILE, but the same permissions apply.
-;;;
-;;; GUILE is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU Lesser General Public License as
-;;; published by the Free Software Foundation; either version 3, or
-;;; (at your option) any later version.
-;;;
-;;; GUILE is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;;; Lesser General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU Lesser General Public
-;;; License along with GUILE; see the file COPYING.LESSER. If not,
-;;; write to the Free Software Foundation, Inc., 51 Franklin Street,
-;;; Fifth Floor, Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; The basic premise of these utilities is that - at least in the
-;; short term - we can get a lot of reference manual mileage by
-;; co-opting the docstrings that are snarfed automatically from
-;; Guile's C and Scheme source code. But this leads to problems of
-;; synchronization... How do you track when a docstring has been
-;; updated in the source and so needs updating in the reference
-;; manual. What if a procedure is removed from the Guile source? And
-;; so on. To complicate matters, the exact snarfed docstring text
-;; will probably need to be modified so that it fits into the flow of
-;; the manual section in which it appears. Can we design solutions to
-;; synchronization problems that continue to work even when the manual
-;; text has been enhanced in this way?
-;;
-;; This file implements an approach to this problem that I have found
-;; useful. It involves keeping track of three copies of each
-;; docstring:
-;;
-;; "MANUAL" = the docstring as it appears in the reference manual.
-;;
-;; "SNARFED" = the docstring as snarfed from the current C or Scheme
-;; source.
-;;
-;; "TRACKING" = the docstring as it appears in a tracking file whose
-;; purpose is to record the most recent snarfed docstrings
-;; that are known to be in sync with the reference manual.
-;;
-;; The approaches are as follows.
-;;
-;; 1. Comparison of MANUAL-DOC, SOURCE-DOC and TRACK-DOC, to produce a
-;; summary output buffer in which keystrokes are defined to bring up
-;; detailed comparisons.
-;;
-;; 2. Comparison of MANUAL-DOC, SOURCE-DOC and TRACK-DOC using Ediff.
-;;
-;; Here is a brief list of commands available (via "M-x COMMAND"):
-;;
-;; docstring-process-current-buffer
-;; docstring-process-current-region BEG END
-;; docstring-process-module MODULE
-;; docstring-ediff-this-line
-;; docstring-show-source
-
-
-(defvar guile-core-dir (or (getenv "GUILE_MAINTAINER_GUILE_CORE_DIR")
- (error "GUILE_MAINTAINER_GUILE_CORE_DIR not set"))
- "*Full path of guile-core source directory.")
-
-(defvar guile-build-dir (or (getenv "GUILE_MAINTAINER_BUILD_CORE_DIR")
- guile-core-dir)
- "*Full path of guile-core build directory. Defaults to guile-core-dir.")
-
-(defvar docstring-manual-directory (expand-file-name "doc/ref" guile-core-dir)
- "*The directory containing the Texinfo source for the Guile reference manual.")
-
-(defvar docstring-tracking-root (expand-file-name "doc/maint" guile-core-dir)
- "*Root directory for docstring tracking files. The tracking file
-for module (a b c) is expected to be in the file
-/a/b/c.texi.")
-
-(defvar docstring-snarfed-roots (mapcar
- #'(lambda (frag)
- (expand-file-name frag guile-build-dir))
- '("libguile" "ice-9" "oop"))
- "*List of possible root directories for snarfed docstring files.
-For each entry in this list, the snarfed docstring file for module (a
-b c) is looked for in the file /a/b/c.texi.")
-
-(defvar docstring-manual-files
- (directory-files docstring-manual-directory nil "\\.texi$" t)
- "List of Texinfo source files that comprise the Guile reference manual.")
-
-(defvar docstring-new-docstrings-file "new-docstrings.texi"
- "The name of a file in the Guile reference manual source directory
-to which new docstrings should be added.")
-
-;; Apply FN in turn to each element in the list CANDIDATES until the
-;; first application that returns non-nil.
-(defun or-map (fn candidates args)
- (let ((result nil))
- (while candidates
- (setq result (apply fn (car candidates) args))
- (if result
- (setq result (cons (car candidates) result)
- candidates nil)
- (setq candidates (cdr candidates))))
- result))
-
-;; Return t if the current buffer position is in the scope of the
-;; specified MODULE, as determined by "@c module-for-docstring ..." comments in the
-;; buffer. DEFAULT-OK specifies the return value in the case that
-;; there are no preceding module comments at all.
-(defun docstring-in-module (module default-ok)
- (save-excursion
- (if (re-search-backward "^@c module-for-docstring " nil t)
- (progn
- (search-forward "@c module-for-docstring ")
- (equal module (read (current-buffer))))
- default-ok)))
-
-;; Find a docstring in the specified FILE-NAME for the item in module
-;; MODULE and with description DESCRIPTION. MODULE should be a list
-;; of symbols, Guile-style, for example: '(ice-9 session).
-;; DESCRIPTION should be the string that is expected after the @deffn,
-;; for example "primitive acons" or "syntax let*".
-(defun find-docstring (file-name module description)
- (and (file-exists-p file-name)
- (let ((buf (find-file-noselect file-name))
- (deffn-regexp (concat "^@deffnx? "
- (regexp-quote description)
- "[ \n\t]"))
- found
- result)
- (save-excursion
- (set-buffer buf)
- (goto-char (point-min))
- (while (and (not found)
- (re-search-forward deffn-regexp nil t))
- (save-excursion
- (goto-char (match-beginning 0))
- (beginning-of-line)
- (if (docstring-in-module module t)
- (setq found t))))
- (if found
- (setq result
- (list (current-buffer)
- (progn
- (re-search-backward "^@deffn ")
- (beginning-of-line)
- (point))
- (progn
- (re-search-forward "^@end deffn")
- (forward-line 1)
- (point))))))
- result)))
-
-;; Find the reference manual version of the specified docstring.
-;; MODULE and DESCRIPTION specify the docstring as per
-;; `find-docstring'. The set of files that `find-manual-docstring'
-;; searches is determined by the value of the `docstring-manual-files'
-;; variable.
-(defun find-manual-docstring (module description)
- (let* ((result
- (or-map 'find-docstring
- (mapcar (function (lambda (file-name)
- (concat docstring-manual-directory
- "/"
- file-name)))
- (cons docstring-new-docstrings-file
- docstring-manual-files))
- (list module
- description)))
- (matched-file-name (and (cdr result)
- (file-name-nondirectory (car result)))))
- (if matched-file-name
- (setq docstring-manual-files
- (cons matched-file-name
- (delete matched-file-name docstring-manual-files))))
- (cdr result)))
-
-;; Convert MODULE to a directory subpath.
-(defun module-to-path (module)
- (mapconcat (function (lambda (component)
- (symbol-name component)))
- module
- "/"))
-
-;; Find the current snarfed version of the specified docstring.
-;; MODULE and DESCRIPTION specify the docstring as per
-;; `find-docstring'. The file that `find-snarfed-docstring' looks in
-;; is automatically generated from MODULE.
-(defun find-snarfed-docstring (module description)
- (let ((modpath (module-to-path module)))
- (cdr (or-map (function (lambda (root)
- (find-docstring (concat root
- "/"
- modpath
- ".texi")
- module
- description)))
- docstring-snarfed-roots
- nil))))
-
-;; Find the tracking version of the specified docstring. MODULE and
-;; DESCRIPTION specify the docstring as per `find-docstring'. The
-;; file that `find-tracking-docstring' looks in is automatically
-;; generated from MODULE.
-(defun find-tracking-docstring (module description)
- (find-docstring (concat docstring-tracking-root
- "/"
- (module-to-path module)
- ".texi")
- module
- description))
-
-;; Extract an alist of modules and descriptions from the current
-;; buffer.
-(defun make-module-description-list ()
- (let ((alist nil)
- (module '(guile)))
- (save-excursion
- (goto-char (point-min))
- (while (re-search-forward "^\\(@c module-for-docstring \\|@deffnx? \\({[^}]+}\\|[^ ]+\\) \\([^ \n]+\\)\\)"
- nil
- t)
- (let ((matched (buffer-substring (match-beginning 1)
- (match-end 1))))
- (if (string-equal matched "@c module-for-docstring ")
- (setq module (read (current-buffer)))
- (let ((type (buffer-substring (match-beginning 2)
- (match-end 2))))
- (if (string-equal type "{C Function}")
- nil
- (setq matched
- (concat type
- " "
- (buffer-substring (match-beginning 3)
- (match-end 3))))
- (message "Found docstring: %S: %s" module matched)
- (let ((descriptions (assoc module alist)))
- (setq alist
- (cons (cons module (cons matched (cdr-safe descriptions)))
- (if descriptions
- (delete descriptions alist)
- alist))))))))))
- alist))
-
-;; missing in some environments?
-(defun caddr (list)
- (nth 2 list))
-
-;; Return the docstring from the specified LOCATION. LOCATION is a
-;; list of three elements: buffer, start position and end position.
-(defun location-to-docstring (location)
- (and location
- (save-excursion
- (set-buffer (car location))
- (buffer-substring (cadr location) (caddr location)))))
-
-;; Perform a comparison of the specified docstring. MODULE and
-;; DESCRIPTION are as per usual.
-(defun docstring-compare (module description)
- (let* ((manual-location (find-manual-docstring module description))
- (snarf-location (find-snarfed-docstring module description))
- (track-location (find-tracking-docstring module description))
-
- (manual-docstring (location-to-docstring manual-location))
- (snarf-docstring (location-to-docstring snarf-location))
- (track-docstring (location-to-docstring track-location))
-
- action
- issue)
-
- ;; Decide what to do.
- (cond ((null snarf-location)
- (setq action nil
- issue (if manual-location
- 'consider-removal
- nil)))
-
- ((null manual-location)
- (setq action 'add-to-manual issue nil))
-
- ((null track-location)
- (setq action nil
- issue (if (string-equal manual-docstring snarf-docstring)
- nil
- 'check-needed)))
-
- ((string-equal track-docstring snarf-docstring)
- (setq action nil issue nil))
-
- ((string-equal track-docstring manual-docstring)
- (setq action 'auto-update-manual issue nil))
-
- (t
- (setq action nil issue 'update-needed)))
-
- ;; Return a pair indicating any automatic action that can be
- ;; taken, and any issue for resolution.
- (cons action issue)))
-
-;; Add the specified docstring to the manual.
-(defun docstring-add-to-manual (module description)
- (let ((buf (find-file-noselect (concat docstring-manual-directory
- "/"
- docstring-new-docstrings-file))))
- (save-excursion
- (set-buffer buf)
- (goto-char (point-max))
- (or (docstring-in-module module nil)
- (insert "\n@c module-for-docstring " (prin1-to-string module) "\n"))
- (insert "\n" (location-to-docstring (find-snarfed-docstring module
- description))))))
-
-;; Auto-update the specified docstring in the manual.
-(defun docstring-auto-update-manual (module description)
- (let ((manual-location (find-manual-docstring module description))
- (track-location (find-tracking-docstring module description)))
- (save-excursion
- (set-buffer (car manual-location))
- (goto-char (cadr manual-location))
- (delete-region (cadr manual-location) (caddr manual-location))
- (insert (location-to-docstring (find-snarfed-docstring module
- description))))))
-
-;; Process an alist of modules and descriptions, and produce a summary
-;; buffer describing actions taken and issues to be resolved.
-(defun docstring-process-alist (alist)
- (let (check-needed-list
- update-needed-list
- consider-removal-list
- added-to-manual-list
- auto-updated-manual-list)
-
- (mapcar
- (function (lambda (module-list)
- (let ((module (car module-list)))
- (message "Module: %S" module)
- (mapcar
- (function (lambda (description)
- (message "Comparing docstring: %S: %s" module description)
- (let* ((ai (docstring-compare module description))
- (action (car ai))
- (issue (cdr ai)))
-
- (cond ((eq action 'add-to-manual)
- (docstring-add-to-manual module description)
- (setq added-to-manual-list
- (cons (cons module description)
- added-to-manual-list)))
-
- ((eq action 'auto-update-manual)
- (docstring-auto-update-manual module description)
- (setq auto-updated-manual-list
- (cons (cons module description)
- auto-updated-manual-list))))
-
- (cond ((eq issue 'check-needed)
- (setq check-needed-list
- (cons (cons module description)
- check-needed-list)))
-
- ((eq issue 'update-needed)
- (setq update-needed-list
- (cons (cons module description)
- update-needed-list)))
-
- ((eq issue 'consider-removal)
- (setq consider-removal-list
- (cons (cons module description)
- consider-removal-list)))))))
- (reverse (cdr module-list))))))
- alist)
-
- ;; Prepare a buffer describing the results.
- (set-buffer (get-buffer-create "*Docstring Results*"))
- (erase-buffer)
-
- (insert "
-The following items have been automatically added to the manual in
-file `" docstring-manual-directory "/" docstring-new-docstrings-file "'.\n\n")
- (if added-to-manual-list
- (mapcar (function (lambda (moddesc)
- (insert (prin1-to-string (car moddesc))
- ": "
- (cdr moddesc)
- "\n")))
- added-to-manual-list)
- (insert "(none)\n"))
-
- (insert "
-The following items have been automatically updated in the manual.\n\n")
- (if auto-updated-manual-list
- (mapcar (function (lambda (moddesc)
- (insert (prin1-to-string (car moddesc))
- ": "
- (cdr moddesc)
- "\n")))
- auto-updated-manual-list)
- (insert "(none)\n"))
-
- (insert "
-The following items are already documented in the manual but are not
-mentioned in the reference copy of the snarfed docstrings file.
-You should check that the manual documentation matches the docstring
-in the current snarfed docstrings file.\n\n")
- (if check-needed-list
- (mapcar (function (lambda (moddesc)
- (insert (prin1-to-string (car moddesc))
- ": "
- (cdr moddesc)
- "\n")))
- check-needed-list)
- (insert "(none)\n"))
-
- (insert "
-The following items have manual documentation that is different from
-the docstring in the reference copy of the snarfed docstrings file,
-and the snarfed docstring has changed. You need to update the manual
-documentation by hand with reference to the snarfed docstring changes.\n\n")
- (if update-needed-list
- (mapcar (function (lambda (moddesc)
- (insert (prin1-to-string (car moddesc))
- ": "
- (cdr moddesc)
- "\n")))
- update-needed-list)
- (insert "(none)\n"))
-
- (insert "
-The following items are documented in the manual but are no longer
-present in the snarfed docstrings file. You should consider whether
-the existing manual documentation is still pertinent. If it is, its
-docstring module comment may need updating, to connect it with a
-new snarfed docstring file.\n\n")
- (if consider-removal-list
- (mapcar (function (lambda (moddesc)
- (insert (prin1-to-string (car moddesc))
- ": "
- (cdr moddesc)
- "\n")))
- consider-removal-list)
- (insert "(none)\n"))
- (insert "\n")
-
- (goto-char (point-min))
- (local-set-key "d" 'docstring-ediff-this-line)
-
- ;; Popup the issues buffer.
- (let ((pop-up-frames t))
- (set-window-point (display-buffer (current-buffer))
- (point-min)))))
-
-(defun docstring-process-current-buffer ()
- (interactive)
- (docstring-process-alist (make-module-description-list)))
-
-(defun docstring-process-current-region (beg end)
- (interactive "r")
- (narrow-to-region beg end)
- (unwind-protect
- (save-excursion
- (docstring-process-alist (make-module-description-list)))
- (widen)))
-
-(defun docstring-process-module (module)
- (interactive "xModule: ")
- (let ((modpath (module-to-path module))
- (mdlist nil))
- (mapcar (function (lambda (root)
- (let ((fn (concat root
- "/"
- modpath
- ".texi")))
- (if (file-exists-p fn)
- (save-excursion
- (find-file fn)
- (message "Getting docstring list from %s" fn)
- (setq mdlist
- (append mdlist
- (make-module-description-list))))))))
- docstring-snarfed-roots)
- (docstring-process-alist mdlist)))
-
-(defun docstring-ediff-this-line ()
- (interactive)
- (let (module
- description)
- (save-excursion
- (beginning-of-line)
- (setq module (read (current-buffer)))
- (forward-char 2)
- (setq description (buffer-substring (point)
- (progn
- (end-of-line)
- (point)))))
-
- (message "Ediff docstring: %S: %s" module description)
-
- (let ((track-location (or (find-tracking-docstring module description)
- (docstring-temp-location "No docstring in tracking file")))
- (snarf-location (or (find-snarfed-docstring module description)
- (docstring-temp-location "No docstring in snarfed file")))
- (manual-location (or (find-manual-docstring module description)
- (docstring-temp-location "No docstring in manual"))))
-
- (setq docstring-ediff-buffers
- (list (car track-location)
- (car snarf-location)
- (car manual-location)))
-
- (docstring-narrow-to-location track-location)
- (docstring-narrow-to-location snarf-location)
- (docstring-narrow-to-location manual-location)
-
- (add-hook 'ediff-quit-hook 'docstring-widen-ediff-buffers)
-
- (ediff-buffers3 (nth 0 docstring-ediff-buffers)
- (nth 1 docstring-ediff-buffers)
- (nth 2 docstring-ediff-buffers)))))
-
-(defun docstring-narrow-to-location (location)
- (save-excursion
- (set-buffer (car location))
- (narrow-to-region (cadr location) (caddr location))))
-
-(defun docstring-temp-location (str)
- (let ((buf (generate-new-buffer "*Docstring Temp*")))
- (save-excursion
- (set-buffer buf)
- (erase-buffer)
- (insert str "\n")
- (list buf (point-min) (point-max)))))
-
-(require 'ediff)
-
-(defvar docstring-ediff-buffers '())
-
-(defun docstring-widen-ediff-buffers ()
- (remove-hook 'ediff-quit-hook 'docstring-widen-ediff-buffers)
- (save-excursion
- (mapcar (function (lambda (buffer)
- (set-buffer buffer)
- (widen)))
- docstring-ediff-buffers)))
-
-
-;;; Tests:
-
-;(find-docstring "/home/neil/Guile/cvs/guile-core/doc/maint/guile.texi" nil "primitive sloppy-assq")
-;(find-manual-docstring '(guile) "primitive sloppy-assq")
-;(find-tracking-docstring '(guile) "primitive sloppy-assq")
-;(find-snarfed-docstring '(guile) "primitive sloppy-assq")
-
-(defvar docstring-libguile-directory (expand-file-name "libguile"
- guile-core-dir)
- "*The directory containing the C source for libguile.")
-
-(defvar docstring-libguile-build-directory (expand-file-name "libguile"
- guile-build-dir)
- "*The directory containing the libguile build directory.")
-
-(defun docstring-display-location (file line)
- (let ((buffer (find-file-noselect
- (expand-file-name file docstring-libguile-directory))))
- (if buffer
- (let* ((window (or (get-buffer-window buffer)
- (display-buffer buffer)))
- (pos (save-excursion
- (set-buffer buffer)
- (goto-line line)
- (point))))
- (set-window-point window pos)))))
-
-(defun docstring-show-source ()
- "Given that point is sitting in a docstring in one of the Texinfo
-source files for the Guile manual, and that that docstring may be
-snarfed automatically from a libguile C file, determine whether the
-docstring is from libguile and, if it is, display the relevant C file
-at the line from which the docstring was snarfed.
-
-Why? When updating snarfed docstrings, you should usually edit the C
-source rather than the Texinfo source, so that your updates benefit
-Guile's online help as well. This function locates the C source for a
-docstring so that it is easy for you to do this."
- (interactive)
- (let* ((deffn-line
- (save-excursion
- (end-of-line)
- (or (re-search-backward "^@deffn " nil t)
- (error "No docstring here!"))
- (buffer-substring (point)
- (progn
- (end-of-line)
- (point)))))
- (guile-texi-file
- (expand-file-name "guile.texi" docstring-libguile-build-directory))
- (source-location
- (save-excursion
- (set-buffer (find-file-noselect guile-texi-file))
- (save-excursion
- (goto-char (point-min))
- (or (re-search-forward (concat "^"
- (regexp-quote deffn-line)
- "$")
- nil t)
- (error "Docstring not from libguile"))
- (forward-line -1)
- (if (looking-at "^@c snarfed from \\([^:]+\\):\\([0-9]+\\)$")
- (cons (match-string 1)
- (string-to-int (match-string 2)))
- (error "Corrupt docstring entry in guile.texi"))))))
- (docstring-display-location (car source-location)
- (cdr source-location))))
-
-
-(provide 'docstring)
-
-;;; docstring.el ends here
diff --git a/doc/maint/guile.texi b/doc/maint/guile.texi
deleted file mode 100644
index c0570f24b..000000000
--- a/doc/maint/guile.texi
+++ /dev/null
@@ -1,11091 +0,0 @@
-
-acons
-@c snarfed from alist.c:36
-@deffn {Scheme Procedure} acons key value alist
-@deffnx {C Function} scm_acons (key, value, alist)
-Add a new key-value pair to @var{alist}. A new pair is
-created whose car is @var{key} and whose cdr is @var{value}, and the
-pair is consed onto @var{alist}, and the new list is returned. This
-function is @emph{not} destructive; @var{alist} is not modified.
-@end deffn
-
-sloppy-assq
-@c snarfed from alist.c:50
-@deffn {Scheme Procedure} sloppy-assq key alist
-@deffnx {C Function} scm_sloppy_assq (key, alist)
-Behaves like @code{assq} but does not do any error checking.
-Recommended only for use in Guile internals.
-@end deffn
-
-sloppy-assv
-@c snarfed from alist.c:68
-@deffn {Scheme Procedure} sloppy-assv key alist
-@deffnx {C Function} scm_sloppy_assv (key, alist)
-Behaves like @code{assv} but does not do any error checking.
-Recommended only for use in Guile internals.
-@end deffn
-
-sloppy-assoc
-@c snarfed from alist.c:86
-@deffn {Scheme Procedure} sloppy-assoc key alist
-@deffnx {C Function} scm_sloppy_assoc (key, alist)
-Behaves like @code{assoc} but does not do any error checking.
-Recommended only for use in Guile internals.
-@end deffn
-
-assq
-@c snarfed from alist.c:113
-@deffn {Scheme Procedure} assq key alist
-@deffnx {Scheme Procedure} assv key alist
-@deffnx {Scheme Procedure} assoc key alist
-@deffnx {C Function} scm_assq (key, alist)
-Fetch the entry in @var{alist} that is associated with @var{key}. To
-decide whether the argument @var{key} matches a particular entry in
-@var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv}
-uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key}
-cannot be found in @var{alist} (according to whichever equality
-predicate is in use), then return @code{#f}. These functions
-return the entire alist entry found (i.e. both the key and the value).
-@end deffn
-
-assv
-@c snarfed from alist.c:134
-@deffn {Scheme Procedure} assv key alist
-@deffnx {C Function} scm_assv (key, alist)
-Behaves like @code{assq} but uses @code{eqv?} for key comparison.
-@end deffn
-
-assoc
-@c snarfed from alist.c:155
-@deffn {Scheme Procedure} assoc key alist
-@deffnx {C Function} scm_assoc (key, alist)
-Behaves like @code{assq} but uses @code{equal?} for key comparison.
-@end deffn
-
-assq-ref
-@c snarfed from alist.c:199
-@deffn {Scheme Procedure} assq-ref alist key
-@deffnx {Scheme Procedure} assv-ref alist key
-@deffnx {Scheme Procedure} assoc-ref alist key
-@deffnx {C Function} scm_assq_ref (alist, key)
-Like @code{assq}, @code{assv} and @code{assoc}, except that only the
-value associated with @var{key} in @var{alist} is returned. These
-functions are equivalent to
-
-@lisp
-(let ((ent (@var{associator} @var{key} @var{alist})))
- (and ent (cdr ent)))
-@end lisp
-
-where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}.
-@end deffn
-
-assv-ref
-@c snarfed from alist.c:216
-@deffn {Scheme Procedure} assv-ref alist key
-@deffnx {C Function} scm_assv_ref (alist, key)
-Behaves like @code{assq-ref} but uses @code{eqv?} for key comparison.
-@end deffn
-
-assoc-ref
-@c snarfed from alist.c:233
-@deffn {Scheme Procedure} assoc-ref alist key
-@deffnx {C Function} scm_assoc_ref (alist, key)
-Behaves like @code{assq-ref} but uses @code{equal?} for key comparison.
-@end deffn
-
-assq-set!
-@c snarfed from alist.c:262
-@deffn {Scheme Procedure} assq-set! alist key val
-@deffnx {Scheme Procedure} assv-set! alist key value
-@deffnx {Scheme Procedure} assoc-set! alist key value
-@deffnx {C Function} scm_assq_set_x (alist, key, val)
-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{value}. If @var{alist} does not contain an entry for @var{key},
-add a new one. Return the (possibly new) alist.
-
-These functions do not attempt to verify the structure of @var{alist},
-and so may cause unusual results if passed an object that is not an
-association list.
-@end deffn
-
-assv-set!
-@c snarfed from alist.c:280
-@deffn {Scheme Procedure} assv-set! alist key val
-@deffnx {C Function} scm_assv_set_x (alist, key, val)
-Behaves like @code{assq-set!} but uses @code{eqv?} for key comparison.
-@end deffn
-
-assoc-set!
-@c snarfed from alist.c:298
-@deffn {Scheme Procedure} assoc-set! alist key val
-@deffnx {C Function} scm_assoc_set_x (alist, key, val)
-Behaves like @code{assq-set!} but uses @code{equal?} for key comparison.
-@end deffn
-
-assq-remove!
-@c snarfed from alist.c:322
-@deffn {Scheme Procedure} assq-remove! alist key
-@deffnx {Scheme Procedure} assv-remove! alist key
-@deffnx {Scheme Procedure} assoc-remove! alist key
-@deffnx {C Function} scm_assq_remove_x (alist, key)
-Delete the first entry in @var{alist} associated with @var{key}, and return
-the resulting alist.
-@end deffn
-
-assv-remove!
-@c snarfed from alist.c:338
-@deffn {Scheme Procedure} assv-remove! alist key
-@deffnx {C Function} scm_assv_remove_x (alist, key)
-Behaves like @code{assq-remove!} but uses @code{eqv?} for key comparison.
-@end deffn
-
-assoc-remove!
-@c snarfed from alist.c:354
-@deffn {Scheme Procedure} assoc-remove! alist key
-@deffnx {C Function} scm_assoc_remove_x (alist, key)
-Behaves like @code{assq-remove!} but uses @code{equal?} for key comparison.
-@end deffn
-
-make-arbiter
-@c snarfed from arbiters.c:99
-@deffn {Scheme Procedure} make-arbiter name
-@deffnx {C Function} scm_make_arbiter (name)
-Return an arbiter object, initially unlocked. Currently
-@var{name} is only used for diagnostic output.
-@end deffn
-
-try-arbiter
-@c snarfed from arbiters.c:116
-@deffn {Scheme Procedure} try-arbiter arb
-@deffnx {C Function} scm_try_arbiter (arb)
-If @var{arb} is unlocked, then lock it and return @code{#t}.
-If @var{arb} is already locked, then do nothing and return
-@code{#f}.
-@end deffn
-
-release-arbiter
-@c snarfed from arbiters.c:142
-@deffn {Scheme Procedure} release-arbiter arb
-@deffnx {C Function} scm_release_arbiter (arb)
-If @var{arb} is locked, then unlock it and return @code{#t}.
-If @var{arb} is already unlocked, then do nothing and return
-@code{#f}.
-
-Typical usage is for the thread which locked an arbiter to
-later release it, but that's not required, any thread can
-release it.
-@end deffn
-
-async
-@c snarfed from async.c:97
-@deffn {Scheme Procedure} async thunk
-@deffnx {C Function} scm_async (thunk)
-Create a new async for the procedure @var{thunk}.
-@end deffn
-
-async-mark
-@c snarfed from async.c:106
-@deffn {Scheme Procedure} async-mark a
-@deffnx {C Function} scm_async_mark (a)
-Mark the async @var{a} for future execution.
-@end deffn
-
-run-asyncs
-@c snarfed from async.c:117
-@deffn {Scheme Procedure} run-asyncs list_of_a
-@deffnx {C Function} scm_run_asyncs (list_of_a)
-Execute all thunks from the asyncs of the list @var{list_of_a}.
-@end deffn
-
-system-async
-@c snarfed from async.c:180
-@deffn {Scheme Procedure} system-async thunk
-@deffnx {C Function} scm_system_async (thunk)
-This function is deprecated. You can use @var{thunk} directly
-instead of explicitly creating an async object.
-
-@end deffn
-
-system-async-mark
-@c snarfed from async.c:296
-@deffn {Scheme Procedure} system-async-mark proc [thread]
-@deffnx {C Function} scm_system_async_mark_for_thread (proc, thread)
-Mark @var{proc} (a procedure with zero arguments) for future execution
-in @var{thread}. If @var{proc} has already been marked for
-@var{thread} but has not been executed yet, this call has no effect.
-If @var{thread} is omitted, the thread that called
-@code{system-async-mark} is used.
-
-This procedure is not safe to be called from C signal handlers. Use
-@code{scm_sigaction} or @code{scm_sigaction_for_thread} to install
-signal handlers.
-@end deffn
-
-noop
-@c snarfed from async.c:335
-@deffn {Scheme Procedure} noop . args
-@deffnx {C Function} scm_noop (args)
-Do nothing. When called without arguments, return @code{#f},
-otherwise return the first argument.
-@end deffn
-
-unmask-signals
-@c snarfed from async.c:350
-@deffn {Scheme Procedure} unmask-signals
-@deffnx {C Function} scm_unmask_signals ()
-Unmask signals. The returned value is not specified.
-@end deffn
-
-mask-signals
-@c snarfed from async.c:370
-@deffn {Scheme Procedure} mask-signals
-@deffnx {C Function} scm_mask_signals ()
-Mask signals. The returned value is not specified.
-@end deffn
-
-call-with-blocked-asyncs
-@c snarfed from async.c:404
-@deffn {Scheme Procedure} call-with-blocked-asyncs proc
-@deffnx {C Function} scm_call_with_blocked_asyncs (proc)
-Call @var{proc} with no arguments and block the execution
-of system asyncs by one level for the current thread while
-it is running. Return the value returned by @var{proc}.
-
-@end deffn
-
-call-with-unblocked-asyncs
-@c snarfed from async.c:430
-@deffn {Scheme Procedure} call-with-unblocked-asyncs proc
-@deffnx {C Function} scm_call_with_unblocked_asyncs (proc)
-Call @var{proc} with no arguments and unblock the execution
-of system asyncs by one level for the current thread while
-it is running. Return the value returned by @var{proc}.
-
-@end deffn
-
-display-error
-@c snarfed from backtrace.c:303
-@deffn {Scheme Procedure} display-error stack port subr message args rest
-@deffnx {C Function} scm_display_error (stack, port, subr, message, args, rest)
-Display an error message to the output port @var{port}.
-@var{stack} is the saved stack for the error, @var{subr} is
-the name of the procedure in which the error occurred and
-@var{message} is the actual error message, which may contain
-formatting instructions. These will format the arguments in
-the list @var{args} accordingly. @var{rest} is currently
-ignored.
-@end deffn
-
-display-application
-@c snarfed from backtrace.c:425
-@deffn {Scheme Procedure} display-application frame [port [indent]]
-@deffnx {C Function} scm_display_application (frame, port, indent)
-Display a procedure application @var{frame} to the output port
-@var{port}. @var{indent} specifies the indentation of the
-output.
-@end deffn
-
-display-backtrace
-@c snarfed from backtrace.c:740
-@deffn {Scheme Procedure} display-backtrace stack port [first [depth [highlights]]]
-@deffnx {C Function} scm_display_backtrace_with_highlights (stack, port, first, depth, highlights)
-Display a backtrace to the output port @var{port}. @var{stack}
-is the stack to take the backtrace from, @var{first} specifies
-where in the stack to start and @var{depth} how much frames
-to display. Both @var{first} and @var{depth} can be @code{#f},
-which means that default values will be used.
-When @var{highlights} is given,
-it should be a list and all members of it are highligthed in
-the backtrace.
-@end deffn
-
-backtrace
-@c snarfed from backtrace.c:776
-@deffn {Scheme Procedure} backtrace [highlights]
-@deffnx {C Function} scm_backtrace_with_highlights (highlights)
-Display a backtrace of the stack saved by the last error
-to the current output port. When @var{highlights} is given,
-it should be a list and all members of it are highligthed in
-the backtrace.
-@end deffn
-
-not
-@c snarfed from boolean.c:33
-@deffn {Scheme Procedure} not x
-@deffnx {C Function} scm_not (x)
-Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}.
-@end deffn
-
-boolean?
-@c snarfed from boolean.c:43
-@deffn {Scheme Procedure} boolean? obj
-@deffnx {C Function} scm_boolean_p (obj)
-Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}.
-@end deffn
-
-char?
-@c snarfed from chars.c:33
-@deffn {Scheme Procedure} char? x
-@deffnx {C Function} scm_char_p (x)
-Return @code{#t} iff @var{x} is a character, else @code{#f}.
-@end deffn
-
-char=?
-@c snarfed from chars.c:42
-@deffn {Scheme Procedure} char=? x y
-Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}.
-@end deffn
-
-char
-@c snarfed from chars.c:55
-@deffn {Scheme Procedure} char x y
-Return @code{#t} iff @var{x} is less than @var{y} in the ASCII sequence,
-else @code{#f}.
-@end deffn
-
-char<=?
-@c snarfed from chars.c:67
-@deffn {Scheme Procedure} char<=? x y
-Return @code{#t} iff @var{x} is less than or equal to @var{y} in the
-ASCII sequence, else @code{#f}.
-@end deffn
-
-char>?
-@c snarfed from chars.c:79
-@deffn {Scheme Procedure} char>? x y
-Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII
-sequence, else @code{#f}.
-@end deffn
-
-char>=?
-@c snarfed from chars.c:91
-@deffn {Scheme Procedure} char>=? x y
-Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the
-ASCII sequence, else @code{#f}.
-@end deffn
-
-char-ci=?
-@c snarfed from chars.c:103
-@deffn {Scheme Procedure} char-ci=? x y
-Return @code{#t} iff @var{x} is the same character as @var{y} ignoring
-case, else @code{#f}.
-@end deffn
-
-char-ci
-@c snarfed from chars.c:115
-@deffn {Scheme Procedure} char-ci x y
-Return @code{#t} iff @var{x} is less than @var{y} in the ASCII sequence
-ignoring case, else @code{#f}.
-@end deffn
-
-char-ci<=?
-@c snarfed from chars.c:127
-@deffn {Scheme Procedure} char-ci<=? x y
-Return @code{#t} iff @var{x} is less than or equal to @var{y} in the
-ASCII sequence ignoring case, else @code{#f}.
-@end deffn
-
-char-ci>?
-@c snarfed from chars.c:139
-@deffn {Scheme Procedure} char-ci>? x y
-Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII
-sequence ignoring case, else @code{#f}.
-@end deffn
-
-char-ci>=?
-@c snarfed from chars.c:151
-@deffn {Scheme Procedure} char-ci>=? x y
-Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the
-ASCII sequence ignoring case, else @code{#f}.
-@end deffn
-
-char-alphabetic?
-@c snarfed from chars.c:163
-@deffn {Scheme Procedure} char-alphabetic? chr
-@deffnx {C Function} scm_char_alphabetic_p (chr)
-Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}.
-
-@end deffn
-
-char-numeric?
-@c snarfed from chars.c:172
-@deffn {Scheme Procedure} char-numeric? chr
-@deffnx {C Function} scm_char_numeric_p (chr)
-Return @code{#t} iff @var{chr} is numeric, else @code{#f}.
-
-@end deffn
-
-char-whitespace?
-@c snarfed from chars.c:181
-@deffn {Scheme Procedure} char-whitespace? chr
-@deffnx {C Function} scm_char_whitespace_p (chr)
-Return @code{#t} iff @var{chr} is whitespace, else @code{#f}.
-
-@end deffn
-
-char-upper-case?
-@c snarfed from chars.c:192
-@deffn {Scheme Procedure} char-upper-case? chr
-@deffnx {C Function} scm_char_upper_case_p (chr)
-Return @code{#t} iff @var{chr} is uppercase, else @code{#f}.
-
-@end deffn
-
-char-lower-case?
-@c snarfed from chars.c:202
-@deffn {Scheme Procedure} char-lower-case? chr
-@deffnx {C Function} scm_char_lower_case_p (chr)
-Return @code{#t} iff @var{chr} is lowercase, else @code{#f}.
-
-@end deffn
-
-char-is-both?
-@c snarfed from chars.c:213
-@deffn {Scheme Procedure} char-is-both? chr
-@deffnx {C Function} scm_char_is_both_p (chr)
-Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}.
-
-@end deffn
-
-char->integer
-@c snarfed from chars.c:228
-@deffn {Scheme Procedure} char->integer chr
-@deffnx {C Function} scm_char_to_integer (chr)
-Return the number corresponding to ordinal position of @var{chr} in the
-ASCII sequence.
-@end deffn
-
-integer->char
-@c snarfed from chars.c:240
-@deffn {Scheme Procedure} integer->char n
-@deffnx {C Function} scm_integer_to_char (n)
-Return the character at position @var{n} in the ASCII sequence.
-@end deffn
-
-char-upcase
-@c snarfed from chars.c:250
-@deffn {Scheme Procedure} char-upcase chr
-@deffnx {C Function} scm_char_upcase (chr)
-Return the uppercase character version of @var{chr}.
-@end deffn
-
-char-downcase
-@c snarfed from chars.c:261
-@deffn {Scheme Procedure} char-downcase chr
-@deffnx {C Function} scm_char_downcase (chr)
-Return the lowercase character version of @var{chr}.
-@end deffn
-
-with-continuation-barrier
-@c snarfed from continuations.c:412
-@deffn {Scheme Procedure} with-continuation-barrier proc
-@deffnx {C Function} scm_with_continuation_barrier (proc)
-Call @var{proc} and return its result. Do not allow the invocation of
-continuations that would leave or enter the dynamic extent of the call
-to @code{with-continuation-barrier}. Such an attempt causes an error
-to be signaled.
-
-Throws (such as errors) that are not caught from within @var{proc} are
-caught by @code{with-continuation-barrier}. In that case, a short
-message is printed to the current error port and @code{#f} is returned.
-
-Thus, @code{with-continuation-barrier} returns exactly once.
-
-@end deffn
-
-debug-options-interface
-@c snarfed from debug.c:54
-@deffn {Scheme Procedure} debug-options-interface [setting]
-@deffnx {C Function} scm_debug_options (setting)
-Option interface for the debug options. Instead of using
-this procedure directly, use the procedures @code{debug-enable},
-@code{debug-disable}, @code{debug-set!} and @code{debug-options}.
-@end deffn
-
-with-traps
-@c snarfed from debug.c:101
-@deffn {Scheme Procedure} with-traps thunk
-@deffnx {C Function} scm_with_traps (thunk)
-Call @var{thunk} with traps enabled.
-@end deffn
-
-memoized?
-@c snarfed from debug.c:139
-@deffn {Scheme Procedure} memoized? obj
-@deffnx {C Function} scm_memoized_p (obj)
-Return @code{#t} if @var{obj} is memoized.
-@end deffn
-
-unmemoize-expr
-@c snarfed from debug.c:271
-@deffn {Scheme Procedure} unmemoize-expr m
-@deffnx {C Function} scm_i_unmemoize_expr (m)
-Unmemoize the memoized expression @var{m},
-@end deffn
-
-memoized-environment
-@c snarfed from debug.c:281
-@deffn {Scheme Procedure} memoized-environment m
-@deffnx {C Function} scm_memoized_environment (m)
-Return the environment of the memoized expression @var{m}.
-@end deffn
-
-procedure-name
-@c snarfed from debug.c:291
-@deffn {Scheme Procedure} procedure-name proc
-@deffnx {C Function} scm_procedure_name (proc)
-Return the name of the procedure @var{proc}
-@end deffn
-
-procedure-source
-@c snarfed from debug.c:317
-@deffn {Scheme Procedure} procedure-source proc
-@deffnx {C Function} scm_procedure_source (proc)
-Return the source of the procedure @var{proc}.
-@end deffn
-
-procedure-environment
-@c snarfed from debug.c:374
-@deffn {Scheme Procedure} procedure-environment proc
-@deffnx {C Function} scm_procedure_environment (proc)
-Return the environment of the procedure @var{proc}.
-@end deffn
-
-local-eval
-@c snarfed from debug.c:406
-@deffn {Scheme Procedure} local-eval exp [env]
-@deffnx {C Function} scm_local_eval (exp, env)
-Evaluate @var{exp} in its environment. If @var{env} is supplied,
-it is the environment in which to evaluate @var{exp}. Otherwise,
-@var{exp} must be a memoized code object (in which case, its environment
-is implicit).
-@end deffn
-
-debug-object?
-@c snarfed from debug.c:493
-@deffn {Scheme Procedure} debug-object? obj
-@deffnx {C Function} scm_debug_object_p (obj)
-Return @code{#t} if @var{obj} is a debug object.
-@end deffn
-
-issue-deprecation-warning
-@c snarfed from deprecation.c:99
-@deffn {Scheme Procedure} issue-deprecation-warning . msgs
-@deffnx {C Function} scm_issue_deprecation_warning (msgs)
-Output @var{msgs} to @code{(current-error-port)} when this is the first call to @code{issue-deprecation-warning} with this specific @var{msgs}. Do nothing otherwise. The argument @var{msgs} should be a list of strings; they are printed in turn, each one followed by a newline.
-@end deffn
-
-include-deprecated-features
-@c snarfed from deprecation.c:144
-@deffn {Scheme Procedure} include-deprecated-features
-@deffnx {C Function} scm_include_deprecated_features ()
-Return @code{#t} iff deprecated features should be included in public interfaces.
-@end deffn
-
-substring-move-left!
-@c snarfed from deprecated.c:73
-@deffn {Scheme Procedure} substring-move-left!
-implemented by the C function "scm_substring_move_x"
-@end deffn
-
-substring-move-right!
-@c snarfed from deprecated.c:75
-@deffn {Scheme Procedure} substring-move-right!
-implemented by the C function "scm_substring_move_x"
-@end deffn
-
-c-registered-modules
-@c snarfed from deprecated.c:178
-@deffn {Scheme Procedure} c-registered-modules
-@deffnx {C Function} scm_registered_modules ()
-Return a list of the object code modules that have been imported into
-the current Guile process. Each element of the list is a pair whose
-car is the name of the module, and whose cdr is the function handle
-for that module's initializer function. The name is the string that
-has been passed to scm_register_module_xxx.
-@end deffn
-
-c-clear-registered-modules
-@c snarfed from deprecated.c:199
-@deffn {Scheme Procedure} c-clear-registered-modules
-@deffnx {C Function} scm_clear_registered_modules ()
-Destroy the list of modules registered with the current Guile process.
-The return value is unspecified. @strong{Warning:} this function does
-not actually unlink or deallocate these modules, but only destroys the
-records of which modules have been loaded. It should therefore be used
-only by module bookkeeping operations.
-@end deffn
-
-close-all-ports-except
-@c snarfed from deprecated.c:342
-@deffn {Scheme Procedure} close-all-ports-except . ports
-@deffnx {C Function} scm_close_all_ports_except (ports)
-[DEPRECATED] Close all open file ports used by the interpreter
-except for those supplied as arguments. This procedure
-was intended to be used before an exec call to close file descriptors
-which are not needed in the new process. However it has the
-undesirable side effect of flushing buffers, so it's deprecated.
-Use port-for-each instead.
-@end deffn
-
-variable-set-name-hint!
-@c snarfed from deprecated.c:359
-@deffn {Scheme Procedure} variable-set-name-hint! var hint
-@deffnx {C Function} scm_variable_set_name_hint (var, hint)
-Do not use this function.
-@end deffn
-
-builtin-variable
-@c snarfed from deprecated.c:372
-@deffn {Scheme Procedure} builtin-variable name
-@deffnx {C Function} scm_builtin_variable (name)
-Do not use this function.
-@end deffn
-
-sloppy-memq
-@c snarfed from deprecated.c:446
-@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.
-Its use is recommended only in writing Guile internals,
-not for high-level Scheme programs.
-@end deffn
-
-sloppy-memv
-@c snarfed from deprecated.c:466
-@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.
-Its use is recommended only in writing Guile internals,
-not for high-level Scheme programs.
-@end deffn
-
-sloppy-member
-@c snarfed from deprecated.c:486
-@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.
-Its use is recommended only in writing Guile internals,
-not for high-level Scheme programs.
-@end deffn
-
-read-and-eval!
-@c snarfed from deprecated.c:508
-@deffn {Scheme Procedure} read-and-eval! [port]
-@deffnx {C Function} scm_read_and_eval_x (port)
-Read a form from @var{port} (standard input by default), and evaluate it
-(memoizing it in the process) in the top-level environment. If no data
-is left to be read from @var{port}, an @code{end-of-file} error is
-signalled.
-@end deffn
-
-string->obarray-symbol
-@c snarfed from deprecated.c:825
-@deffn {Scheme Procedure} string->obarray-symbol o s [softp]
-@deffnx {C Function} scm_string_to_obarray_symbol (o, s, softp)
-Intern a new symbol in @var{obarray}, a symbol table, with name
-@var{string}.
-
-If @var{obarray} is @code{#f}, use the default system symbol table. If
-@var{obarray} is @code{#t}, the symbol should not be interned in any
-symbol table; merely return the pair (@var{symbol}
-. @var{#}).
-
-The @var{soft?} argument determines whether new symbol table entries
-should be created when the specified symbol is not already present in
-@var{obarray}. If @var{soft?} is specified and is a true value, then
-new entries should not be added for symbols not already present in the
-table; instead, simply return @code{#f}.
-@end deffn
-
-intern-symbol
-@c snarfed from deprecated.c:863
-@deffn {Scheme Procedure} intern-symbol o s
-@deffnx {C Function} scm_intern_symbol (o, s)
-Add a new symbol to @var{obarray} with name @var{string}, bound to an
-unspecified initial value. The symbol table is not modified if a symbol
-with this name is already present.
-@end deffn
-
-unintern-symbol
-@c snarfed from deprecated.c:905
-@deffn {Scheme Procedure} unintern-symbol o s
-@deffnx {C Function} scm_unintern_symbol (o, s)
-Remove the symbol with name @var{string} from @var{obarray}. This
-function returns @code{#t} if the symbol was present and @code{#f}
-otherwise.
-@end deffn
-
-symbol-binding
-@c snarfed from deprecated.c:950
-@deffn {Scheme Procedure} symbol-binding o s
-@deffnx {C Function} scm_symbol_binding (o, s)
-Look up in @var{obarray} the symbol whose name is @var{string}, and
-return the value to which it is bound. If @var{obarray} is @code{#f},
-use the global symbol table. If @var{string} is not interned in
-@var{obarray}, an error is signalled.
-@end deffn
-
-symbol-bound?
-@c snarfed from deprecated.c:1003
-@deffn {Scheme Procedure} symbol-bound? o s
-@deffnx {C Function} scm_symbol_bound_p (o, s)
-Return @code{#t} if @var{obarray} contains a symbol with name
-@var{string} bound to a defined value. This differs from
-@var{symbol-interned?} in that the mere mention of a symbol
-usually causes it to be interned; @code{symbol-bound?}
-determines whether a symbol has been given any meaningful
-value.
-@end deffn
-
-symbol-set!
-@c snarfed from deprecated.c:1030
-@deffn {Scheme Procedure} symbol-set! o s v
-@deffnx {C Function} scm_symbol_set_x (o, s, v)
-Find the symbol in @var{obarray} whose name is @var{string}, and rebind
-it to @var{value}. An error is signalled if @var{string} is not present
-in @var{obarray}.
-@end deffn
-
-gentemp
-@c snarfed from deprecated.c:1063
-@deffn {Scheme Procedure} gentemp [prefix [obarray]]
-@deffnx {C Function} scm_gentemp (prefix, obarray)
-Create a new symbol with a name unique in an obarray.
-The name is constructed from an optional string @var{prefix}
-and a counter value. The default prefix is @code{t}. The
-@var{obarray} is specified as a second optional argument.
-Default is the system obarray where all normal symbols are
-interned. The counter is increased by 1 at each
-call. There is no provision for resetting the counter.
-@end deffn
-
-make-keyword-from-dash-symbol
-@c snarfed from discouraged.c:161
-@deffn {Scheme Procedure} make-keyword-from-dash-symbol symbol
-@deffnx {C Function} scm_make_keyword_from_dash_symbol (symbol)
-Make a keyword object from a @var{symbol} that starts with a dash.
-@end deffn
-
-keyword-dash-symbol
-@c snarfed from discouraged.c:183
-@deffn {Scheme Procedure} keyword-dash-symbol keyword
-@deffnx {C Function} scm_keyword_dash_symbol (keyword)
-Return the dash symbol for @var{keyword}.
-This is the inverse of @code{make-keyword-from-dash-symbol}.
-@end deffn
-
-dynamic-link
-@c snarfed from dynl.c:149
-@deffn {Scheme Procedure} dynamic-link filename
-@deffnx {C Function} scm_dynamic_link (filename)
-Find the shared object (shared library) denoted by
-@var{filename} and link it into the running Guile
-application. The returned
-scheme object is a ``handle'' for the library which can
-be passed to @code{dynamic-func}, @code{dynamic-call} etc.
-
-Searching for object files is system dependent. Normally,
-if @var{filename} does have an explicit directory it will
-be searched for in locations
-such as @file{/usr/lib} and @file{/usr/local/lib}.
-@end deffn
-
-dynamic-object?
-@c snarfed from dynl.c:168
-@deffn {Scheme Procedure} dynamic-object? obj
-@deffnx {C Function} scm_dynamic_object_p (obj)
-Return @code{#t} if @var{obj} is a dynamic object handle,
-or @code{#f} otherwise.
-@end deffn
-
-dynamic-unlink
-@c snarfed from dynl.c:182
-@deffn {Scheme Procedure} dynamic-unlink dobj
-@deffnx {C Function} scm_dynamic_unlink (dobj)
-Unlink a dynamic object from the application, if possible. The
-object must have been linked by @code{dynamic-link}, with
-@var{dobj} the corresponding handle. After this procedure
-is called, the handle can no longer be used to access the
-object.
-@end deffn
-
-dynamic-func
-@c snarfed from dynl.c:207
-@deffn {Scheme Procedure} dynamic-func name dobj
-@deffnx {C Function} scm_dynamic_func (name, dobj)
-Return a ``handle'' for the function @var{name} in the
-shared object referred to by @var{dobj}. The handle
-can be passed to @code{dynamic-call} to actually
-call the function.
-
-Regardless whether your C compiler prepends an underscore
-@samp{_} to the global names in a program, you should
-@strong{not} include this underscore in @var{name}
-since it will be added automatically when necessary.
-@end deffn
-
-dynamic-call
-@c snarfed from dynl.c:253
-@deffn {Scheme Procedure} dynamic-call func dobj
-@deffnx {C Function} scm_dynamic_call (func, dobj)
-Call a C function in a dynamic object. Two styles of
-invocation are supported:
-
-@itemize @bullet
-@item @var{func} can be a function handle returned by
-@code{dynamic-func}. In this case @var{dobj} is
-ignored
-@item @var{func} can be a string with the name of the
-function to call, with @var{dobj} the handle of the
-dynamic object in which to find the function.
-This is equivalent to
-@smallexample
-
-(dynamic-call (dynamic-func @var{func} @var{dobj}) #f)
-@end smallexample
-@end itemize
-
-In either case, the function is passed no arguments
-and its return value is ignored.
-@end deffn
-
-dynamic-args-call
-@c snarfed from dynl.c:285
-@deffn {Scheme Procedure} dynamic-args-call func dobj args
-@deffnx {C Function} scm_dynamic_args_call (func, dobj, args)
-Call the C function indicated by @var{func} and @var{dobj},
-just like @code{dynamic-call}, but pass it some arguments and
-return its return value. The C function is expected to take
-two arguments and return an @code{int}, just like @code{main}:
-@smallexample
-int c_func (int argc, char **argv);
-@end smallexample
-
-The parameter @var{args} must be a list of strings and is
-converted into an array of @code{char *}. The array is passed
-in @var{argv} and its size in @var{argc}. The return value is
-converted to a Scheme number and returned from the call to
-@code{dynamic-args-call}.
-@end deffn
-
-dynamic-wind
-@c snarfed from dynwind.c:97
-@deffn {Scheme Procedure} dynamic-wind in_guard thunk out_guard
-@deffnx {C Function} scm_dynamic_wind (in_guard, thunk, out_guard)
-All three arguments must be 0-argument procedures.
-@var{in_guard} is called, then @var{thunk}, then
-@var{out_guard}.
-
-If, any time during the execution of @var{thunk}, the
-continuation of the @code{dynamic_wind} expression is escaped
-non-locally, @var{out_guard} is called. If the continuation of
-the dynamic-wind is re-entered, @var{in_guard} is called. Thus
-@var{in_guard} and @var{out_guard} may be called any number of
-times.
-@lisp
-(define x 'normal-binding)
-@result{} x
-(define a-cont (call-with-current-continuation
- (lambda (escape)
- (let ((old-x x))
- (dynamic-wind
- ;; in-guard:
- ;;
- (lambda () (set! x 'special-binding))
-
- ;; thunk
- ;;
- (lambda () (display x) (newline)
- (call-with-current-continuation escape)
- (display x) (newline)
- x)
-
- ;; out-guard:
- ;;
- (lambda () (set! x old-x)))))))
-
-;; Prints:
-special-binding
-;; Evaluates to:
-@result{} a-cont
-x
-@result{} normal-binding
-(a-cont #f)
-;; Prints:
-special-binding
-;; Evaluates to:
-@result{} a-cont ;; the value of the (define a-cont...)
-x
-@result{} normal-binding
-a-cont
-@result{} special-binding
-@end lisp
-@end deffn
-
-environment?
-@c snarfed from environments.c:106
-@deffn {Scheme Procedure} environment? obj
-@deffnx {C Function} scm_environment_p (obj)
-Return @code{#t} if @var{obj} is an environment, or @code{#f}
-otherwise.
-@end deffn
-
-environment-bound?
-@c snarfed from environments.c:117
-@deffn {Scheme Procedure} environment-bound? env sym
-@deffnx {C Function} scm_environment_bound_p (env, sym)
-Return @code{#t} if @var{sym} is bound in @var{env}, or
-@code{#f} otherwise.
-@end deffn
-
-environment-ref
-@c snarfed from environments.c:132
-@deffn {Scheme Procedure} environment-ref env sym
-@deffnx {C Function} scm_environment_ref (env, sym)
-Return the value of the location bound to @var{sym} in
-@var{env}. If @var{sym} is unbound in @var{env}, signal an
-@code{environment:unbound} error.
-@end deffn
-
-environment-fold
-@c snarfed from environments.c:202
-@deffn {Scheme Procedure} environment-fold env proc init
-@deffnx {C Function} scm_environment_fold (env, proc, init)
-Iterate over all the bindings in @var{env}, accumulating some
-value.
-For each binding in @var{env}, apply @var{proc} to the symbol
-bound, its value, and the result from the previous application
-of @var{proc}.
-Use @var{init} as @var{proc}'s third argument the first time
-@var{proc} is applied.
-If @var{env} contains no bindings, this function simply returns
-@var{init}.
-If @var{env} binds the symbol sym1 to the value val1, sym2 to
-val2, and so on, then this procedure computes:
-@lisp
- (proc sym1 val1
- (proc sym2 val2
- ...
- (proc symn valn
- init)))
-@end lisp
-Each binding in @var{env} will be processed exactly once.
-@code{environment-fold} makes no guarantees about the order in
-which the bindings are processed.
-Here is a function which, given an environment, constructs an
-association list representing that environment's bindings,
-using environment-fold:
-@lisp
- (define (environment->alist env)
- (environment-fold env
- (lambda (sym val tail)
- (cons (cons sym val) tail))
- '()))
-@end lisp
-@end deffn
-
-environment-define
-@c snarfed from environments.c:237
-@deffn {Scheme Procedure} environment-define env sym val
-@deffnx {C Function} scm_environment_define (env, sym, val)
-Bind @var{sym} to a new location containing @var{val} in
-@var{env}. If @var{sym} is already bound to another location
-in @var{env} and the binding is mutable, that binding is
-replaced. The new binding and location are both mutable. The
-return value is unspecified.
-If @var{sym} is already bound in @var{env}, and the binding is
-immutable, signal an @code{environment:immutable-binding} error.
-@end deffn
-
-environment-undefine
-@c snarfed from environments.c:263
-@deffn {Scheme Procedure} environment-undefine env sym
-@deffnx {C Function} scm_environment_undefine (env, sym)
-Remove any binding for @var{sym} from @var{env}. If @var{sym}
-is unbound in @var{env}, do nothing. The return value is
-unspecified.
-If @var{sym} is already bound in @var{env}, and the binding is
-immutable, signal an @code{environment:immutable-binding} error.
-@end deffn
-
-environment-set!
-@c snarfed from environments.c:291
-@deffn {Scheme Procedure} environment-set! env sym val
-@deffnx {C Function} scm_environment_set_x (env, sym, val)
-If @var{env} binds @var{sym} to some location, change that
-location's value to @var{val}. The return value is
-unspecified.
-If @var{sym} is not bound in @var{env}, signal an
-@code{environment:unbound} error. If @var{env} binds @var{sym}
-to an immutable location, signal an
-@code{environment:immutable-location} error.
-@end deffn
-
-environment-cell
-@c snarfed from environments.c:326
-@deffn {Scheme Procedure} environment-cell env sym for_write
-@deffnx {C Function} scm_environment_cell (env, sym, for_write)
-Return the value cell which @var{env} binds to @var{sym}, or
-@code{#f} if the binding does not live in a value cell.
-The argument @var{for-write} indicates whether the caller
-intends to modify the variable's value by mutating the value
-cell. If the variable is immutable, then
-@code{environment-cell} signals an
-@code{environment:immutable-location} error.
-If @var{sym} is unbound in @var{env}, signal an
-@code{environment:unbound} error.
-If you use this function, you should consider using
-@code{environment-observe}, to be notified when @var{sym} gets
-re-bound to a new value cell, or becomes undefined.
-@end deffn
-
-environment-observe
-@c snarfed from environments.c:378
-@deffn {Scheme Procedure} environment-observe env proc
-@deffnx {C Function} scm_environment_observe (env, proc)
-Whenever @var{env}'s bindings change, apply @var{proc} to
-@var{env}.
-This function returns an object, token, which you can pass to
-@code{environment-unobserve} to remove @var{proc} from the set
-of procedures observing @var{env}. The type and value of
-token is unspecified.
-@end deffn
-
-environment-observe-weak
-@c snarfed from environments.c:395
-@deffn {Scheme Procedure} environment-observe-weak env proc
-@deffnx {C Function} scm_environment_observe_weak (env, proc)
-This function is the same as environment-observe, except that
-the reference @var{env} retains to @var{proc} is a weak
-reference. This means that, if there are no other live,
-non-weak references to @var{proc}, it will be
-garbage-collected, and dropped from @var{env}'s
-list of observing procedures.
-@end deffn
-
-environment-unobserve
-@c snarfed from environments.c:431
-@deffn {Scheme Procedure} environment-unobserve token
-@deffnx {C Function} scm_environment_unobserve (token)
-Cancel the observation request which returned the value
-@var{token}. The return value is unspecified.
-If a call @code{(environment-observe env proc)} returns
-@var{token}, then the call @code{(environment-unobserve token)}
-will cause @var{proc} to no longer be called when @var{env}'s
-bindings change.
-@end deffn
-
-make-leaf-environment
-@c snarfed from environments.c:1017
-@deffn {Scheme Procedure} make-leaf-environment
-@deffnx {C Function} scm_make_leaf_environment ()
-Create a new leaf environment, containing no bindings.
-All bindings and locations created in the new environment
-will be mutable.
-@end deffn
-
-leaf-environment?
-@c snarfed from environments.c:1040
-@deffn {Scheme Procedure} leaf-environment? object
-@deffnx {C Function} scm_leaf_environment_p (object)
-Return @code{#t} if object is a leaf environment, or @code{#f}
-otherwise.
-@end deffn
-
-make-eval-environment
-@c snarfed from environments.c:1405
-@deffn {Scheme Procedure} make-eval-environment local imported
-@deffnx {C Function} scm_make_eval_environment (local, imported)
-Return a new environment object eval whose bindings are the
-union of the bindings in the environments @var{local} and
-@var{imported}, with bindings from @var{local} taking
-precedence. Definitions made in eval are placed in @var{local}.
-Applying @code{environment-define} or
-@code{environment-undefine} to eval has the same effect as
-applying the procedure to @var{local}.
-Note that eval incorporates @var{local} and @var{imported} by
-reference:
-If, after creating eval, the program changes the bindings of
-@var{local} or @var{imported}, those changes will be visible
-in eval.
-Since most Scheme evaluation takes place in eval environments,
-they transparently cache the bindings received from @var{local}
-and @var{imported}. Thus, the first time the program looks up
-a symbol in eval, eval may make calls to @var{local} or
-@var{imported} to find their bindings, but subsequent
-references to that symbol will be as fast as references to
-bindings in finite environments.
-In typical use, @var{local} will be a finite environment, and
-@var{imported} will be an import environment
-@end deffn
-
-eval-environment?
-@c snarfed from environments.c:1442
-@deffn {Scheme Procedure} eval-environment? object
-@deffnx {C Function} scm_eval_environment_p (object)
-Return @code{#t} if object is an eval environment, or @code{#f}
-otherwise.
-@end deffn
-
-eval-environment-local
-@c snarfed from environments.c:1452
-@deffn {Scheme Procedure} eval-environment-local env
-@deffnx {C Function} scm_eval_environment_local (env)
-Return the local environment of eval environment @var{env}.
-@end deffn
-
-eval-environment-set-local!
-@c snarfed from environments.c:1464
-@deffn {Scheme Procedure} eval-environment-set-local! env local
-@deffnx {C Function} scm_eval_environment_set_local_x (env, local)
-Change @var{env}'s local environment to @var{local}.
-@end deffn
-
-eval-environment-imported
-@c snarfed from environments.c:1490
-@deffn {Scheme Procedure} eval-environment-imported env
-@deffnx {C Function} scm_eval_environment_imported (env)
-Return the imported environment of eval environment @var{env}.
-@end deffn
-
-eval-environment-set-imported!
-@c snarfed from environments.c:1502
-@deffn {Scheme Procedure} eval-environment-set-imported! env imported
-@deffnx {C Function} scm_eval_environment_set_imported_x (env, imported)
-Change @var{env}'s imported environment to @var{imported}.
-@end deffn
-
-make-import-environment
-@c snarfed from environments.c:1825
-@deffn {Scheme Procedure} make-import-environment imports conflict_proc
-@deffnx {C Function} scm_make_import_environment (imports, conflict_proc)
-Return a new environment @var{imp} whose bindings are the union
-of the bindings from the environments in @var{imports};
-@var{imports} must be a list of environments. That is,
-@var{imp} binds a symbol to a location when some element of
-@var{imports} does.
-If two different elements of @var{imports} have a binding for
-the same symbol, the @var{conflict-proc} is called with the
-following parameters: the import environment, the symbol and
-the list of the imported environments that bind the symbol.
-If the @var{conflict-proc} returns an environment @var{env},
-the conflict is considered as resolved and the binding from
-@var{env} is used. If the @var{conflict-proc} returns some
-non-environment object, the conflict is considered unresolved
-and the symbol is treated as unspecified in the import
-environment.
-The checking for conflicts may be performed lazily, i. e. at
-the moment when a value or binding for a certain symbol is
-requested instead of the moment when the environment is
-created or the bindings of the imports change.
-All bindings in @var{imp} are immutable. If you apply
-@code{environment-define} or @code{environment-undefine} to
-@var{imp}, Guile will signal an
- @code{environment:immutable-binding} error. However,
-notice that the set of bindings in @var{imp} may still change,
-if one of its imported environments changes.
-@end deffn
-
-import-environment?
-@c snarfed from environments.c:1854
-@deffn {Scheme Procedure} import-environment? object
-@deffnx {C Function} scm_import_environment_p (object)
-Return @code{#t} if object is an import environment, or
-@code{#f} otherwise.
-@end deffn
-
-import-environment-imports
-@c snarfed from environments.c:1865
-@deffn {Scheme Procedure} import-environment-imports env
-@deffnx {C Function} scm_import_environment_imports (env)
-Return the list of environments imported by the import
-environment @var{env}.
-@end deffn
-
-import-environment-set-imports!
-@c snarfed from environments.c:1878
-@deffn {Scheme Procedure} import-environment-set-imports! env imports
-@deffnx {C Function} scm_import_environment_set_imports_x (env, imports)
-Change @var{env}'s list of imported environments to
-@var{imports}, and check for conflicts.
-@end deffn
-
-make-export-environment
-@c snarfed from environments.c:2145
-@deffn {Scheme Procedure} make-export-environment private signature
-@deffnx {C Function} scm_make_export_environment (private, signature)
-Return a new environment @var{exp} containing only those
-bindings in private whose symbols are present in
-@var{signature}. The @var{private} argument must be an
-environment.
-
-The environment @var{exp} binds symbol to location when
-@var{env} does, and symbol is exported by @var{signature}.
-
-@var{signature} is a list specifying which of the bindings in
-@var{private} should be visible in @var{exp}. Each element of
-@var{signature} should be a list of the form:
- (symbol attribute ...)
-where each attribute is one of the following:
-@table @asis
-@item the symbol @code{mutable-location}
- @var{exp} should treat the
- location bound to symbol as mutable. That is, @var{exp}
- will pass calls to @code{environment-set!} or
- @code{environment-cell} directly through to private.
-@item the symbol @code{immutable-location}
- @var{exp} should treat
- the location bound to symbol as immutable. If the program
- applies @code{environment-set!} to @var{exp} and symbol, or
- calls @code{environment-cell} to obtain a writable value
- cell, @code{environment-set!} will signal an
- @code{environment:immutable-location} error. Note that, even
- if an export environment treats a location as immutable, the
- underlying environment may treat it as mutable, so its
- value may change.
-@end table
-It is an error for an element of signature to specify both
-@code{mutable-location} and @code{immutable-location}. If
-neither is specified, @code{immutable-location} is assumed.
-
-As a special case, if an element of signature is a lone
-symbol @var{sym}, it is equivalent to an element of the form
-@code{(sym)}.
-
-All bindings in @var{exp} are immutable. If you apply
-@code{environment-define} or @code{environment-undefine} to
-@var{exp}, Guile will signal an
-@code{environment:immutable-binding} error. However,
-notice that the set of bindings in @var{exp} may still change,
-if the bindings in private change.
-@end deffn
-
-export-environment?
-@c snarfed from environments.c:2180
-@deffn {Scheme Procedure} export-environment? object
-@deffnx {C Function} scm_export_environment_p (object)
-Return @code{#t} if object is an export environment, or
-@code{#f} otherwise.
-@end deffn
-
-export-environment-private
-@c snarfed from environments.c:2190
-@deffn {Scheme Procedure} export-environment-private env
-@deffnx {C Function} scm_export_environment_private (env)
-Return the private environment of export environment @var{env}.
-@end deffn
-
-export-environment-set-private!
-@c snarfed from environments.c:2202
-@deffn {Scheme Procedure} export-environment-set-private! env private
-@deffnx {C Function} scm_export_environment_set_private_x (env, private)
-Change the private environment of export environment @var{env}.
-@end deffn
-
-export-environment-signature
-@c snarfed from environments.c:2224
-@deffn {Scheme Procedure} export-environment-signature env
-@deffnx {C Function} scm_export_environment_signature (env)
-Return the signature of export environment @var{env}.
-@end deffn
-
-export-environment-set-signature!
-@c snarfed from environments.c:2298
-@deffn {Scheme Procedure} export-environment-set-signature! env signature
-@deffnx {C Function} scm_export_environment_set_signature_x (env, signature)
-Change the signature of export environment @var{env}.
-@end deffn
-
-eq?
-@c snarfed from eq.c:81
-@deffn {Scheme Procedure} eq? x y
-Return @code{#t} if @var{x} and @var{y} are the same object,
-except for numbers and characters. For example,
-
-@example
-(define x (vector 1 2 3))
-(define y (vector 1 2 3))
-
-(eq? x x) @result{} #t
-(eq? x y) @result{} #f
-@end example
-
-Numbers and characters are not equal to any other object, but
-the problem is they're not necessarily @code{eq?} to themselves
-either. This is even so when the number comes directly from a
-variable,
-
-@example
-(let ((n (+ 2 3)))
- (eq? n n)) @result{} *unspecified*
-@end example
-
-Generally @code{eqv?} should be used when comparing numbers or
-characters. @code{=} or @code{char=?} can be used too.
-
-It's worth noting that end-of-list @code{()}, @code{#t},
-@code{#f}, a symbol of a given name, and a keyword of a given
-name, are unique objects. There's just one of each, so for
-instance no matter how @code{()} arises in a program, it's the
-same object and can be compared with @code{eq?},
-
-@example
-(define x (cdr '(123)))
-(define y (cdr '(456)))
-(eq? x y) @result{} #t
-
-(define x (string->symbol "foo"))
-(eq? x 'foo) @result{} #t
-@end example
-@end deffn
-
-eqv?
-@c snarfed from eq.c:116
-@deffn {Scheme Procedure} eqv? x y
-Return @code{#t} if @var{x} and @var{y} are the same object, or
-for characters and numbers the same value.
-
-On objects except characters and numbers, @code{eqv?} is the
-same as @code{eq?}, it's true if @var{x} and @var{y} are the
-same object.
-
-If @var{x} and @var{y} are numbers or characters, @code{eqv?}
-compares their type and value. An exact number is not
-@code{eqv?} to an inexact number (even if their value is the
-same).
-
-@example
-(eqv? 3 (+ 1 2)) @result{} #t
-(eqv? 1 1.0) @result{} #f
-@end example
-@end deffn
-
-equal?
-@c snarfed from eq.c:212
-@deffn {Scheme Procedure} equal? x y
-Return @code{#t} if @var{x} and @var{y} are the same type, and
-their contents or value are equal.
-
-For a pair, string, vector or array, @code{equal?} compares the
-contents, and does so using using the same @code{equal?}
-recursively, so a deep structure can be traversed.
-
-@example
-(equal? (list 1 2 3) (list 1 2 3)) @result{} #t
-(equal? (list 1 2 3) (vector 1 2 3)) @result{} #f
-@end example
-
-For other objects, @code{equal?} compares as per @code{eqv?},
-which means characters and numbers are compared by type and
-value (and like @code{eqv?}, exact and inexact numbers are not
-@code{equal?}, even if their value is the same).
-
-@example
-(equal? 3 (+ 1 2)) @result{} #t
-(equal? 1 1.0) @result{} #f
-@end example
-
-Hash tables are currently only compared as per @code{eq?}, so
-two different tables are not @code{equal?}, even if their
-contents are the same.
-
-@code{equal?} does not support circular data structures, it may
-go into an infinite loop if asked to compare two circular lists
-or similar.
-
-New application-defined object types (Smobs) have an
-@code{equalp} handler which is called by @code{equal?}. This
-lets an application traverse the contents or control what is
-considered @code{equal?} for two such objects. If there's no
-handler, the default is to just compare as per @code{eq?}.
-@end deffn
-
-scm-error
-@c snarfed from error.c:82
-@deffn {Scheme Procedure} scm-error key subr message args data
-@deffnx {C Function} scm_error_scm (key, subr, message, args, data)
-Raise an error with key @var{key}. @var{subr} can be a string
-naming the procedure associated with the error, or @code{#f}.
-@var{message} is the error message string, possibly containing
-@code{~S} and @code{~A} escapes. When an error is reported,
-these are replaced by formatting the corresponding members of
-@var{args}: @code{~A} (was @code{%s} in older versions of
-Guile) formats using @code{display} and @code{~S} (was
-@code{%S}) formats using @code{write}. @var{data} is a list or
-@code{#f} depending on @var{key}: if @var{key} is
-@code{system-error} then it should be a list containing the
-Unix @code{errno} value; If @var{key} is @code{signal} then it
-should be a list containing the Unix signal number; If
-@var{key} is @code{out-of-range} or @code{wrong-type-arg},
-it is a list containing the bad value; otherwise
-it will usually be @code{#f}.
-@end deffn
-
-strerror
-@c snarfed from error.c:129
-@deffn {Scheme Procedure} strerror err
-@deffnx {C Function} scm_strerror (err)
-Return the Unix error message corresponding to @var{err}, which
-must be an integer value.
-@end deffn
-
-apply:nconc2last
-@c snarfed from eval.c:4686
-@deffn {Scheme Procedure} apply:nconc2last lst
-@deffnx {C Function} scm_nconc2last (lst)
-Given a list (@var{arg1} @dots{} @var{args}), this function
-conses the @var{arg1} @dots{} arguments onto the front of
-@var{args}, and returns the resulting list. Note that
-@var{args} is a list; thus, the argument to this function is
-a list whose last element is a list.
-Note: Rather than do new consing, @code{apply:nconc2last}
-destroys its argument, so use with care.
-@end deffn
-
-force
-@c snarfed from eval.c:5598
-@deffn {Scheme Procedure} force promise
-@deffnx {C Function} scm_force (promise)
-If the promise @var{x} has not been computed yet, compute and
-return @var{x}, otherwise just return the previously computed
-value.
-@end deffn
-
-promise?
-@c snarfed from eval.c:5621
-@deffn {Scheme Procedure} promise? obj
-@deffnx {C Function} scm_promise_p (obj)
-Return true if @var{obj} is a promise, i.e. a delayed computation
-(@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}).
-@end deffn
-
-cons-source
-@c snarfed from eval.c:5633
-@deffn {Scheme Procedure} cons-source xorig x y
-@deffnx {C Function} scm_cons_source (xorig, x, y)
-Create and return a new pair whose car and cdr are @var{x} and @var{y}.
-Any source properties associated with @var{xorig} are also associated
-with the new pair.
-@end deffn
-
-copy-tree
-@c snarfed from eval.c:5790
-@deffn {Scheme Procedure} copy-tree obj
-@deffnx {C Function} scm_copy_tree (obj)
-Recursively copy the data tree that is bound to @var{obj}, and return a
-the new data structure. @code{copy-tree} recurses down the
-contents of both pairs and vectors (since both cons cells and vector
-cells may point to arbitrary objects), and stops recursing when it hits
-any other object.
-@end deffn
-
-primitive-eval
-@c snarfed from eval.c:5878
-@deffn {Scheme Procedure} primitive-eval exp
-@deffnx {C Function} scm_primitive_eval (exp)
-Evaluate @var{exp} in the top-level environment specified by
-the current module.
-@end deffn
-
-eval
-@c snarfed from eval.c:5922
-@deffn {Scheme Procedure} eval exp module_or_state
-@deffnx {C Function} scm_eval (exp, module_or_state)
-Evaluate @var{exp}, a list representing a Scheme expression,
-in the top-level environment specified by
-@var{module_or_state}.
-While @var{exp} is evaluated (using @code{primitive-eval}),
-@var{module_or_state} is made the current module when
-it is a module, or the current dynamic state when it is
-a dynamic state.Example: (eval '(+ 1 2) (interaction-environment))
-@end deffn
-
-eval-options-interface
-@c snarfed from eval.c:3086
-@deffn {Scheme Procedure} eval-options-interface [setting]
-@deffnx {C Function} scm_eval_options_interface (setting)
-Option interface for the evaluation options. Instead of using
-this procedure directly, use the procedures @code{eval-enable},
-@code{eval-disable}, @code{eval-set!} and @code{eval-options}.
-@end deffn
-
-evaluator-traps-interface
-@c snarfed from eval.c:3104
-@deffn {Scheme Procedure} evaluator-traps-interface [setting]
-@deffnx {C Function} scm_evaluator_traps (setting)
-Option interface for the evaluator trap options.
-@end deffn
-
-defined?
-@c snarfed from evalext.c:34
-@deffn {Scheme Procedure} defined? sym [env]
-@deffnx {C Function} scm_defined_p (sym, env)
-Return @code{#t} if @var{sym} is defined in the lexical environment @var{env}. When @var{env} is not specified, look in the top-level environment as defined by the current module.
-@end deffn
-
-map-in-order
-@c snarfed from evalext.c:80
-@deffn {Scheme Procedure} map-in-order
-implemented by the C function "scm_map"
-@end deffn
-
-self-evaluating?
-@c snarfed from evalext.c:85
-@deffn {Scheme Procedure} self-evaluating? obj
-@deffnx {C Function} scm_self_evaluating_p (obj)
-Return #t for objects which Guile considers self-evaluating
-@end deffn
-
-load-extension
-@c snarfed from extensions.c:143
-@deffn {Scheme Procedure} load-extension lib init
-@deffnx {C Function} scm_load_extension (lib, init)
-Load and initialize the extension designated by LIB and INIT.
-When there is no pre-registered function for LIB/INIT, this is
-equivalent to
-
-@lisp
-(dynamic-call INIT (dynamic-link LIB))
-@end lisp
-
-When there is a pre-registered function, that function is called
-instead.
-
-Normally, there is no pre-registered function. This option exists
-only for situations where dynamic linking is unavailable or unwanted.
-In that case, you would statically link your program with the desired
-library, and register its init function right after Guile has been
-initialized.
-
-LIB should be a string denoting a shared library without any file type
-suffix such as ".so". The suffix is provided automatically. It
-should also not contain any directory components. Libraries that
-implement Guile Extensions should be put into the normal locations for
-shared libraries. We recommend to use the naming convention
-libguile-bla-blum for a extension related to a module `(bla blum)'.
-
-The normal way for a extension to be used is to write a small Scheme
-file that defines a module, and to load the extension into this
-module. When the module is auto-loaded, the extension is loaded as
-well. For example,
-
-@lisp
-(define-module (bla blum))
-
-(load-extension "libguile-bla-blum" "bla_init_blum")
-@end lisp
-@end deffn
-
-program-arguments
-@c snarfed from feature.c:57
-@deffn {Scheme Procedure} program-arguments
-@deffnx {Scheme Procedure} command-line
-@deffnx {C Function} scm_program_arguments ()
-Return the list of command line arguments passed to Guile, as a list of
-strings. The list includes the invoked program name, which is usually
-@code{"guile"}, but excludes switches and parameters for command line
-options like @code{-e} and @code{-l}.
-@end deffn
-
-make-fluid
-@c snarfed from fluids.c:260
-@deffn {Scheme Procedure} make-fluid
-@deffnx {C Function} scm_make_fluid ()
-Return a newly created fluid.
-Fluids are objects that can hold one
-value per dynamic state. That is, modifications to this value are
-only visible to code that executes with the same dynamic state as
-the modifying code. When a new dynamic state is constructed, it
-inherits the values from its parent. Because each thread normally executes
-with its own dynamic state, you can use fluids for thread local storage.
-@end deffn
-
-fluid?
-@c snarfed from fluids.c:283
-@deffn {Scheme Procedure} fluid? obj
-@deffnx {C Function} scm_fluid_p (obj)
-Return @code{#t} iff @var{obj} is a fluid; otherwise, return
-@code{#f}.
-@end deffn
-
-fluid-ref
-@c snarfed from fluids.c:306
-@deffn {Scheme Procedure} fluid-ref fluid
-@deffnx {C Function} scm_fluid_ref (fluid)
-Return the value associated with @var{fluid} in the current
-dynamic root. If @var{fluid} has not been set, then return
-@code{#f}.
-@end deffn
-
-fluid-set!
-@c snarfed from fluids.c:325
-@deffn {Scheme Procedure} fluid-set! fluid value
-@deffnx {C Function} scm_fluid_set_x (fluid, value)
-Set the value associated with @var{fluid} in the current dynamic root.
-@end deffn
-
-with-fluids*
-@c snarfed from fluids.c:395
-@deffn {Scheme Procedure} with-fluids* fluids values thunk
-@deffnx {C Function} scm_with_fluids (fluids, values, thunk)
-Set @var{fluids} to @var{values} temporary, and call @var{thunk}.
-@var{fluids} must be a list of fluids and @var{values} must be the same
-number of their values to be applied. Each substitution is done
-one after another. @var{thunk} must be a procedure with no argument.
-@end deffn
-
-with-fluid*
-@c snarfed from fluids.c:434
-@deffn {Scheme Procedure} with-fluid* fluid value thunk
-@deffnx {C Function} scm_with_fluid (fluid, value, thunk)
-Set @var{fluid} to @var{value} temporarily, and call @var{thunk}.
-@var{thunk} must be a procedure with no argument.
-@end deffn
-
-make-dynamic-state
-@c snarfed from fluids.c:487
-@deffn {Scheme Procedure} make-dynamic-state [parent]
-@deffnx {C Function} scm_make_dynamic_state (parent)
-Return a copy of the dynamic state object @var{parent}
-or of the current dynamic state when @var{parent} is omitted.
-@end deffn
-
-dynamic-state?
-@c snarfed from fluids.c:515
-@deffn {Scheme Procedure} dynamic-state? obj
-@deffnx {C Function} scm_dynamic_state_p (obj)
-Return @code{#t} if @var{obj} is a dynamic state object;
-return @code{#f} otherwise
-@end deffn
-
-current-dynamic-state
-@c snarfed from fluids.c:530
-@deffn {Scheme Procedure} current-dynamic-state
-@deffnx {C Function} scm_current_dynamic_state ()
-Return the current dynamic state object.
-@end deffn
-
-set-current-dynamic-state
-@c snarfed from fluids.c:540
-@deffn {Scheme Procedure} set-current-dynamic-state state
-@deffnx {C Function} scm_set_current_dynamic_state (state)
-Set the current dynamic state object to @var{state}
-and return the previous current dynamic state object.
-@end deffn
-
-with-dynamic-state
-@c snarfed from fluids.c:582
-@deffn {Scheme Procedure} with-dynamic-state state proc
-@deffnx {C Function} scm_with_dynamic_state (state, proc)
-Call @var{proc} while @var{state} is the current dynamic
-state object.
-@end deffn
-
-setvbuf
-@c snarfed from fports.c:137
-@deffn {Scheme Procedure} setvbuf port mode [size]
-@deffnx {C Function} scm_setvbuf (port, mode, size)
-Set the buffering mode for @var{port}. @var{mode} can be:
-@table @code
-@item _IONBF
-non-buffered
-@item _IOLBF
-line buffered
-@item _IOFBF
-block buffered, using a newly allocated buffer of @var{size} bytes.
-If @var{size} is omitted, a default size will be used.
-@end table
-@end deffn
-
-file-port?
-@c snarfed from fports.c:230
-@deffn {Scheme Procedure} file-port? obj
-@deffnx {C Function} scm_file_port_p (obj)
-Determine whether @var{obj} is a port that is related to a file.
-@end deffn
-
-open-file
-@c snarfed from fports.c:284
-@deffn {Scheme Procedure} open-file filename mode
-@deffnx {C Function} scm_open_file (filename, mode)
-Open the file whose name is @var{filename}, and return a port
-representing that file. The attributes of the port are
-determined by the @var{mode} string. The way in which this is
-interpreted is similar to C stdio. The first character must be
-one of the following:
-@table @samp
-@item r
-Open an existing file for input.
-@item w
-Open a file for output, creating it if it doesn't already exist
-or removing its contents if it does.
-@item a
-Open a file for output, creating it if it doesn't already
-exist. All writes to the port will go to the end of the file.
-The "append mode" can be turned off while the port is in use
-@pxref{Ports and File Descriptors, fcntl}
-@end table
-The following additional characters can be appended:
-@table @samp
-@item +
-Open the port for both input and output. E.g., @code{r+}: open
-an existing file for both input and output.
-@item 0
-Create an "unbuffered" port. In this case input and output
-operations are passed directly to the underlying port
-implementation without additional buffering. This is likely to
-slow down I/O operations. The buffering mode can be changed
-while a port is in use @pxref{Ports and File Descriptors,
-setvbuf}
-@item l
-Add line-buffering to the port. The port output buffer will be
-automatically flushed whenever a newline character is written.
-@end table
-In theory we could create read/write ports which were buffered
-in one direction only. However this isn't included in the
-current interfaces. If a file cannot be opened with the access
-requested, @code{open-file} throws an exception.
-@end deffn
-
-gc-live-object-stats
-@c snarfed from gc.c:276
-@deffn {Scheme Procedure} gc-live-object-stats
-@deffnx {C Function} scm_gc_live_object_stats ()
-Return an alist of statistics of the current live objects.
-@end deffn
-
-gc-stats
-@c snarfed from gc.c:293
-@deffn {Scheme Procedure} gc-stats
-@deffnx {C Function} scm_gc_stats ()
-Return an association list of statistics about Guile's current
-use of storage.
-
-@end deffn
-
-object-address
-@c snarfed from gc.c:429
-@deffn {Scheme Procedure} object-address obj
-@deffnx {C Function} scm_object_address (obj)
-Return an integer that for the lifetime of @var{obj} is uniquely
-returned by this function for @var{obj}
-@end deffn
-
-gc
-@c snarfed from gc.c:440
-@deffn {Scheme Procedure} gc
-@deffnx {C Function} scm_gc ()
-Scans all of SCM objects and reclaims for further use those that are
-no longer accessible.
-@end deffn
-
-class-of
-@c snarfed from goops.c:166
-@deffn {Scheme Procedure} class-of x
-@deffnx {C Function} scm_class_of (x)
-Return the class of @var{x}.
-@end deffn
-
-%compute-slots
-@c snarfed from goops.c:407
-@deffn {Scheme Procedure} %compute-slots class
-@deffnx {C Function} scm_sys_compute_slots (class)
-Return a list consisting of the names of all slots belonging to
-class @var{class}, i. e. the slots of @var{class} and of all of
-its superclasses.
-@end deffn
-
-get-keyword
-@c snarfed from goops.c:498
-@deffn {Scheme Procedure} get-keyword key l default_value
-@deffnx {C Function} scm_get_keyword (key, l, default_value)
-Determine an associated value for the keyword @var{key} from
-the list @var{l}. The list @var{l} has to consist of an even
-number of elements, where, starting with the first, every
-second element is a keyword, followed by its associated value.
-If @var{l} does not hold a value for @var{key}, the value
-@var{default_value} is returned.
-@end deffn
-
-%initialize-object
-@c snarfed from goops.c:521
-@deffn {Scheme Procedure} %initialize-object obj initargs
-@deffnx {C Function} scm_sys_initialize_object (obj, initargs)
-Initialize the object @var{obj} with the given arguments
-@var{initargs}.
-@end deffn
-
-%prep-layout!
-@c snarfed from goops.c:619
-@deffn {Scheme Procedure} %prep-layout! class
-@deffnx {C Function} scm_sys_prep_layout_x (class)
-
-@end deffn
-
-%inherit-magic!
-@c snarfed from goops.c:718
-@deffn {Scheme Procedure} %inherit-magic! class dsupers
-@deffnx {C Function} scm_sys_inherit_magic_x (class, dsupers)
-
-@end deffn
-
-instance?
-@c snarfed from goops.c:958
-@deffn {Scheme Procedure} instance? obj
-@deffnx {C Function} scm_instance_p (obj)
-Return @code{#t} if @var{obj} is an instance.
-@end deffn
-
-class-name
-@c snarfed from goops.c:973
-@deffn {Scheme Procedure} class-name obj
-@deffnx {C Function} scm_class_name (obj)
-Return the class name of @var{obj}.
-@end deffn
-
-class-direct-supers
-@c snarfed from goops.c:983
-@deffn {Scheme Procedure} class-direct-supers obj
-@deffnx {C Function} scm_class_direct_supers (obj)
-Return the direct superclasses of the class @var{obj}.
-@end deffn
-
-class-direct-slots
-@c snarfed from goops.c:993
-@deffn {Scheme Procedure} class-direct-slots obj
-@deffnx {C Function} scm_class_direct_slots (obj)
-Return the direct slots of the class @var{obj}.
-@end deffn
-
-class-direct-subclasses
-@c snarfed from goops.c:1003
-@deffn {Scheme Procedure} class-direct-subclasses obj
-@deffnx {C Function} scm_class_direct_subclasses (obj)
-Return the direct subclasses of the class @var{obj}.
-@end deffn
-
-class-direct-methods
-@c snarfed from goops.c:1013
-@deffn {Scheme Procedure} class-direct-methods obj
-@deffnx {C Function} scm_class_direct_methods (obj)
-Return the direct methods of the class @var{obj}
-@end deffn
-
-class-precedence-list
-@c snarfed from goops.c:1023
-@deffn {Scheme Procedure} class-precedence-list obj
-@deffnx {C Function} scm_class_precedence_list (obj)
-Return the class precedence list of the class @var{obj}.
-@end deffn
-
-class-slots
-@c snarfed from goops.c:1033
-@deffn {Scheme Procedure} class-slots obj
-@deffnx {C Function} scm_class_slots (obj)
-Return the slot list of the class @var{obj}.
-@end deffn
-
-class-environment
-@c snarfed from goops.c:1043
-@deffn {Scheme Procedure} class-environment obj
-@deffnx {C Function} scm_class_environment (obj)
-Return the environment of the class @var{obj}.
-@end deffn
-
-generic-function-name
-@c snarfed from goops.c:1054
-@deffn {Scheme Procedure} generic-function-name obj
-@deffnx {C Function} scm_generic_function_name (obj)
-Return the name of the generic function @var{obj}.
-@end deffn
-
-generic-function-methods
-@c snarfed from goops.c:1099
-@deffn {Scheme Procedure} generic-function-methods obj
-@deffnx {C Function} scm_generic_function_methods (obj)
-Return the methods of the generic function @var{obj}.
-@end deffn
-
-method-generic-function
-@c snarfed from goops.c:1112
-@deffn {Scheme Procedure} method-generic-function obj
-@deffnx {C Function} scm_method_generic_function (obj)
-Return the generic function for the method @var{obj}.
-@end deffn
-
-method-specializers
-@c snarfed from goops.c:1122
-@deffn {Scheme Procedure} method-specializers obj
-@deffnx {C Function} scm_method_specializers (obj)
-Return specializers of the method @var{obj}.
-@end deffn
-
-method-procedure
-@c snarfed from goops.c:1132
-@deffn {Scheme Procedure} method-procedure obj
-@deffnx {C Function} scm_method_procedure (obj)
-Return the procedure of the method @var{obj}.
-@end deffn
-
-accessor-method-slot-definition
-@c snarfed from goops.c:1142
-@deffn {Scheme Procedure} accessor-method-slot-definition obj
-@deffnx {C Function} scm_accessor_method_slot_definition (obj)
-Return the slot definition of the accessor @var{obj}.
-@end deffn
-
-%tag-body
-@c snarfed from goops.c:1152
-@deffn {Scheme Procedure} %tag-body body
-@deffnx {C Function} scm_sys_tag_body (body)
-Internal GOOPS magic---don't use this function!
-@end deffn
-
-make-unbound
-@c snarfed from goops.c:1167
-@deffn {Scheme Procedure} make-unbound
-@deffnx {C Function} scm_make_unbound ()
-Return the unbound value.
-@end deffn
-
-unbound?
-@c snarfed from goops.c:1176
-@deffn {Scheme Procedure} unbound? obj
-@deffnx {C Function} scm_unbound_p (obj)
-Return @code{#t} if @var{obj} is unbound.
-@end deffn
-
-assert-bound
-@c snarfed from goops.c:1186
-@deffn {Scheme Procedure} assert-bound value obj
-@deffnx {C Function} scm_assert_bound (value, obj)
-Return @var{value} if it is bound, and invoke the
-@var{slot-unbound} method of @var{obj} if it is not.
-@end deffn
-
-@@assert-bound-ref
-@c snarfed from goops.c:1198
-@deffn {Scheme Procedure} @@assert-bound-ref obj index
-@deffnx {C Function} scm_at_assert_bound_ref (obj, index)
-Like @code{assert-bound}, but use @var{index} for accessing
-the value from @var{obj}.
-@end deffn
-
-%fast-slot-ref
-@c snarfed from goops.c:1210
-@deffn {Scheme Procedure} %fast-slot-ref obj index
-@deffnx {C Function} scm_sys_fast_slot_ref (obj, index)
-Return the slot value with index @var{index} from @var{obj}.
-@end deffn
-
-%fast-slot-set!
-@c snarfed from goops.c:1224
-@deffn {Scheme Procedure} %fast-slot-set! obj index value
-@deffnx {C Function} scm_sys_fast_slot_set_x (obj, index, value)
-Set the slot with index @var{index} in @var{obj} to
-@var{value}.
-@end deffn
-
-slot-ref-using-class
-@c snarfed from goops.c:1361
-@deffn {Scheme Procedure} slot-ref-using-class class obj slot_name
-@deffnx {C Function} scm_slot_ref_using_class (class, obj, slot_name)
-
-@end deffn
-
-slot-set-using-class!
-@c snarfed from goops.c:1380
-@deffn {Scheme Procedure} slot-set-using-class! class obj slot_name value
-@deffnx {C Function} scm_slot_set_using_class_x (class, obj, slot_name, value)
-
-@end deffn
-
-slot-bound-using-class?
-@c snarfed from goops.c:1394
-@deffn {Scheme Procedure} slot-bound-using-class? class obj slot_name
-@deffnx {C Function} scm_slot_bound_using_class_p (class, obj, slot_name)
-
-@end deffn
-
-slot-exists-using-class?
-@c snarfed from goops.c:1409
-@deffn {Scheme Procedure} slot-exists-using-class? class obj slot_name
-@deffnx {C Function} scm_slot_exists_using_class_p (class, obj, slot_name)
-
-@end deffn
-
-slot-ref
-@c snarfed from goops.c:1425
-@deffn {Scheme Procedure} slot-ref obj slot_name
-@deffnx {C Function} scm_slot_ref (obj, slot_name)
-Return the value from @var{obj}'s slot with the name
-@var{slot_name}.
-@end deffn
-
-slot-set!
-@c snarfed from goops.c:1442
-@deffn {Scheme Procedure} slot-set! obj slot_name value
-@deffnx {C Function} scm_slot_set_x (obj, slot_name, value)
-Set the slot named @var{slot_name} of @var{obj} to @var{value}.
-@end deffn
-
-slot-bound?
-@c snarfed from goops.c:1459
-@deffn {Scheme Procedure} slot-bound? obj slot_name
-@deffnx {C Function} scm_slot_bound_p (obj, slot_name)
-Return @code{#t} if the slot named @var{slot_name} of @var{obj}
-is bound.
-@end deffn
-
-slot-exists?
-@c snarfed from goops.c:1477
-@deffn {Scheme Procedure} slot-exists? obj slot_name
-@deffnx {C Function} scm_slot_exists_p (obj, slot_name)
-Return @code{#t} if @var{obj} has a slot named @var{slot_name}.
-@end deffn
-
-%allocate-instance
-@c snarfed from goops.c:1516
-@deffn {Scheme Procedure} %allocate-instance class initargs
-@deffnx {C Function} scm_sys_allocate_instance (class, initargs)
-Create a new instance of class @var{class} and initialize it
-from the arguments @var{initargs}.
-@end deffn
-
-%set-object-setter!
-@c snarfed from goops.c:1586
-@deffn {Scheme Procedure} %set-object-setter! obj setter
-@deffnx {C Function} scm_sys_set_object_setter_x (obj, setter)
-
-@end deffn
-
-%modify-instance
-@c snarfed from goops.c:1611
-@deffn {Scheme Procedure} %modify-instance old new
-@deffnx {C Function} scm_sys_modify_instance (old, new)
-
-@end deffn
-
-%modify-class
-@c snarfed from goops.c:1637
-@deffn {Scheme Procedure} %modify-class old new
-@deffnx {C Function} scm_sys_modify_class (old, new)
-
-@end deffn
-
-%invalidate-class
-@c snarfed from goops.c:1661
-@deffn {Scheme Procedure} %invalidate-class class
-@deffnx {C Function} scm_sys_invalidate_class (class)
-
-@end deffn
-
-%invalidate-method-cache!
-@c snarfed from goops.c:1783
-@deffn {Scheme Procedure} %invalidate-method-cache! gf
-@deffnx {C Function} scm_sys_invalidate_method_cache_x (gf)
-
-@end deffn
-
-generic-capability?
-@c snarfed from goops.c:1809
-@deffn {Scheme Procedure} generic-capability? proc
-@deffnx {C Function} scm_generic_capability_p (proc)
-
-@end deffn
-
-enable-primitive-generic!
-@c snarfed from goops.c:1822
-@deffn {Scheme Procedure} enable-primitive-generic! . subrs
-@deffnx {C Function} scm_enable_primitive_generic_x (subrs)
-
-@end deffn
-
-primitive-generic-generic
-@c snarfed from goops.c:1843
-@deffn {Scheme Procedure} primitive-generic-generic subr
-@deffnx {C Function} scm_primitive_generic_generic (subr)
-
-@end deffn
-
-make
-@c snarfed from goops.c:2209
-@deffn {Scheme Procedure} make . args
-@deffnx {C Function} scm_make (args)
-Make a new object. @var{args} must contain the class and
-all necessary initialization information.
-@end deffn
-
-find-method
-@c snarfed from goops.c:2298
-@deffn {Scheme Procedure} find-method . l
-@deffnx {C Function} scm_find_method (l)
-
-@end deffn
-
-%method-more-specific?
-@c snarfed from goops.c:2318
-@deffn {Scheme Procedure} %method-more-specific? m1 m2 targs
-@deffnx {C Function} scm_sys_method_more_specific_p (m1, m2, targs)
-Return true if method @var{m1} is more specific than @var{m2} given the argument types (classes) listed in @var{targs}.
-@end deffn
-
-%goops-loaded
-@c snarfed from goops.c:2944
-@deffn {Scheme Procedure} %goops-loaded
-@deffnx {C Function} scm_sys_goops_loaded ()
-Announce that GOOPS is loaded and perform initialization
-on the C level which depends on the loaded GOOPS modules.
-@end deffn
-
-make-guardian
-@c snarfed from guardians.c:307
-@deffn {Scheme Procedure} make-guardian [greedy_p]
-@deffnx {C Function} scm_make_guardian (greedy_p)
-Create a new guardian.
-A guardian protects a set of objects from garbage collection,
-allowing a program to apply cleanup or other actions.
-
-@code{make-guardian} returns a procedure representing the guardian.
-Calling the guardian procedure with an argument adds the
-argument to the guardian's set of protected objects.
-Calling the guardian procedure without an argument returns
-one of the protected objects which are ready for garbage
-collection, or @code{#f} if no such object is available.
-Objects which are returned in this way are removed from
-the guardian.
-
-@code{make-guardian} takes one optional argument that says whether the
-new guardian should be greedy or sharing. If there is any chance
-that any object protected by the guardian may be resurrected,
-then you should make the guardian greedy (this is the default).
-
-See R. Kent Dybvig, Carl Bruggeman, and David Eby (1993)
-"Guardians in a Generation-Based Garbage Collector".
-ACM SIGPLAN Conference on Programming Language Design
-and Implementation, June 1993.
-
-(the semantics are slightly different at this point, but the
-paper still (mostly) accurately describes the interface).
-@end deffn
-
-guardian-destroyed?
-@c snarfed from guardians.c:335
-@deffn {Scheme Procedure} guardian-destroyed? guardian
-@deffnx {C Function} scm_guardian_destroyed_p (guardian)
-Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}.
-@end deffn
-
-guardian-greedy?
-@c snarfed from guardians.c:353
-@deffn {Scheme Procedure} guardian-greedy? guardian
-@deffnx {C Function} scm_guardian_greedy_p (guardian)
-Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.
-@end deffn
-
-destroy-guardian!
-@c snarfed from guardians.c:364
-@deffn {Scheme Procedure} destroy-guardian! guardian
-@deffnx {C Function} scm_destroy_guardian_x (guardian)
-Destroys @var{guardian}, by making it impossible to put any more
-objects in it or get any objects from it. It also unguards any
-objects guarded by @var{guardian}.
-@end deffn
-
-hashq
-@c snarfed from hash.c:183
-@deffn {Scheme Procedure} hashq key size
-@deffnx {C Function} scm_hashq (key, size)
-Determine a hash value for @var{key} that is suitable for
-lookups in a hashtable of size @var{size}, where @code{eq?} is
-used as the equality predicate. The function returns an
-integer in the range 0 to @var{size} - 1. Note that
-@code{hashq} may use internal addresses. Thus two calls to
-hashq where the keys are @code{eq?} are not guaranteed to
-deliver the same value if the key object gets garbage collected
-in between. This can happen, for example with symbols:
-@code{(hashq 'foo n) (gc) (hashq 'foo n)} may produce two
-different values, since @code{foo} will be garbage collected.
-@end deffn
-
-hashv
-@c snarfed from hash.c:219
-@deffn {Scheme Procedure} hashv key size
-@deffnx {C Function} scm_hashv (key, size)
-Determine a hash value for @var{key} that is suitable for
-lookups in a hashtable of size @var{size}, where @code{eqv?} is
-used as the equality predicate. The function returns an
-integer in the range 0 to @var{size} - 1. Note that
-@code{(hashv key)} may use internal addresses. Thus two calls
-to hashv where the keys are @code{eqv?} are not guaranteed to
-deliver the same value if the key object gets garbage collected
-in between. This can happen, for example with symbols:
-@code{(hashv 'foo n) (gc) (hashv 'foo n)} may produce two
-different values, since @code{foo} will be garbage collected.
-@end deffn
-
-hash
-@c snarfed from hash.c:242
-@deffn {Scheme Procedure} hash key size
-@deffnx {C Function} scm_hash (key, size)
-Determine a hash value for @var{key} that is suitable for
-lookups in a hashtable of size @var{size}, where @code{equal?}
-is used as the equality predicate. The function returns an
-integer in the range 0 to @var{size} - 1.
-@end deffn
-
-make-hash-table
-@c snarfed from hashtab.c:332
-@deffn {Scheme Procedure} make-hash-table [n]
-@deffnx {C Function} scm_make_hash_table (n)
-Make a new abstract hash table object with minimum number of buckets @var{n}
-
-@end deffn
-
-make-weak-key-hash-table
-@c snarfed from hashtab.c:349
-@deffn {Scheme Procedure} make-weak-key-hash-table [n]
-@deffnx {Scheme Procedure} make-weak-value-hash-table size
-@deffnx {Scheme Procedure} make-doubly-weak-hash-table size
-@deffnx {C Function} scm_make_weak_key_hash_table (n)
-Return a weak hash table with @var{size} buckets.
-
-You can modify weak hash tables in exactly the same way you
-would modify regular hash tables. (@pxref{Hash Tables})
-@end deffn
-
-make-weak-value-hash-table
-@c snarfed from hashtab.c:364
-@deffn {Scheme Procedure} make-weak-value-hash-table [n]
-@deffnx {C Function} scm_make_weak_value_hash_table (n)
-Return a hash table with weak values with @var{size} buckets.
-(@pxref{Hash Tables})
-@end deffn
-
-make-doubly-weak-hash-table
-@c snarfed from hashtab.c:381
-@deffn {Scheme Procedure} make-doubly-weak-hash-table n
-@deffnx {C Function} scm_make_doubly_weak_hash_table (n)
-Return a hash table with weak keys and values with @var{size}
-buckets. (@pxref{Hash Tables})
-@end deffn
-
-hash-table?
-@c snarfed from hashtab.c:400
-@deffn {Scheme Procedure} hash-table? obj
-@deffnx {C Function} scm_hash_table_p (obj)
-Return @code{#t} if @var{obj} is an abstract hash table object.
-@end deffn
-
-weak-key-hash-table?
-@c snarfed from hashtab.c:414
-@deffn {Scheme Procedure} weak-key-hash-table? obj
-@deffnx {Scheme Procedure} weak-value-hash-table? obj
-@deffnx {Scheme Procedure} doubly-weak-hash-table? obj
-@deffnx {C Function} scm_weak_key_hash_table_p (obj)
-Return @code{#t} if @var{obj} is the specified weak hash
-table. Note that a doubly weak hash table is neither a weak key
-nor a weak value hash table.
-@end deffn
-
-weak-value-hash-table?
-@c snarfed from hashtab.c:424
-@deffn {Scheme Procedure} weak-value-hash-table? obj
-@deffnx {C Function} scm_weak_value_hash_table_p (obj)
-Return @code{#t} if @var{obj} is a weak value hash table.
-@end deffn
-
-doubly-weak-hash-table?
-@c snarfed from hashtab.c:434
-@deffn {Scheme Procedure} doubly-weak-hash-table? obj
-@deffnx {C Function} scm_doubly_weak_hash_table_p (obj)
-Return @code{#t} if @var{obj} is a doubly weak hash table.
-@end deffn
-
-hash-clear!
-@c snarfed from hashtab.c:586
-@deffn {Scheme Procedure} hash-clear! table
-@deffnx {C Function} scm_hash_clear_x (table)
-Remove all items from @var{table} (without triggering a resize).
-@end deffn
-
-hashq-get-handle
-@c snarfed from hashtab.c:607
-@deffn {Scheme Procedure} hashq-get-handle table key
-@deffnx {C Function} scm_hashq_get_handle (table, key)
-This procedure returns the @code{(key . value)} pair from the
-hash table @var{table}. If @var{table} does not hold an
-associated value for @var{key}, @code{#f} is returned.
-Uses @code{eq?} for equality testing.
-@end deffn
-
-hashq-create-handle!
-@c snarfed from hashtab.c:619
-@deffn {Scheme Procedure} hashq-create-handle! table key init
-@deffnx {C Function} scm_hashq_create_handle_x (table, key, init)
-This function looks up @var{key} in @var{table} and returns its handle.
-If @var{key} is not already present, a new handle is created which
-associates @var{key} with @var{init}.
-@end deffn
-
-hashq-ref
-@c snarfed from hashtab.c:632
-@deffn {Scheme Procedure} hashq-ref table key [dflt]
-@deffnx {C Function} scm_hashq_ref (table, key, dflt)
-Look up @var{key} in the hash table @var{table}, and return the
-value (if any) associated with it. If @var{key} is not found,
-return @var{default} (or @code{#f} if no @var{default} argument
-is supplied). Uses @code{eq?} for equality testing.
-@end deffn
-
-hashq-set!
-@c snarfed from hashtab.c:646
-@deffn {Scheme Procedure} hashq-set! table key val
-@deffnx {C Function} scm_hashq_set_x (table, key, val)
-Find the entry in @var{table} associated with @var{key}, and
-store @var{value} there. Uses @code{eq?} for equality testing.
-@end deffn
-
-hashq-remove!
-@c snarfed from hashtab.c:658
-@deffn {Scheme Procedure} hashq-remove! table key
-@deffnx {C Function} scm_hashq_remove_x (table, key)
-Remove @var{key} (and any value associated with it) from
-@var{table}. Uses @code{eq?} for equality tests.
-@end deffn
-
-hashv-get-handle
-@c snarfed from hashtab.c:673
-@deffn {Scheme Procedure} hashv-get-handle table key
-@deffnx {C Function} scm_hashv_get_handle (table, key)
-This procedure returns the @code{(key . value)} pair from the
-hash table @var{table}. If @var{table} does not hold an
-associated value for @var{key}, @code{#f} is returned.
-Uses @code{eqv?} for equality testing.
-@end deffn
-
-hashv-create-handle!
-@c snarfed from hashtab.c:685
-@deffn {Scheme Procedure} hashv-create-handle! table key init
-@deffnx {C Function} scm_hashv_create_handle_x (table, key, init)
-This function looks up @var{key} in @var{table} and returns its handle.
-If @var{key} is not already present, a new handle is created which
-associates @var{key} with @var{init}.
-@end deffn
-
-hashv-ref
-@c snarfed from hashtab.c:699
-@deffn {Scheme Procedure} hashv-ref table key [dflt]
-@deffnx {C Function} scm_hashv_ref (table, key, dflt)
-Look up @var{key} in the hash table @var{table}, and return the
-value (if any) associated with it. If @var{key} is not found,
-return @var{default} (or @code{#f} if no @var{default} argument
-is supplied). Uses @code{eqv?} for equality testing.
-@end deffn
-
-hashv-set!
-@c snarfed from hashtab.c:713
-@deffn {Scheme Procedure} hashv-set! table key val
-@deffnx {C Function} scm_hashv_set_x (table, key, val)
-Find the entry in @var{table} associated with @var{key}, and
-store @var{value} there. Uses @code{eqv?} for equality testing.
-@end deffn
-
-hashv-remove!
-@c snarfed from hashtab.c:724
-@deffn {Scheme Procedure} hashv-remove! table key
-@deffnx {C Function} scm_hashv_remove_x (table, key)
-Remove @var{key} (and any value associated with it) from
-@var{table}. Uses @code{eqv?} for equality tests.
-@end deffn
-
-hash-get-handle
-@c snarfed from hashtab.c:738
-@deffn {Scheme Procedure} hash-get-handle table key
-@deffnx {C Function} scm_hash_get_handle (table, key)
-This procedure returns the @code{(key . value)} pair from the
-hash table @var{table}. If @var{table} does not hold an
-associated value for @var{key}, @code{#f} is returned.
-Uses @code{equal?} for equality testing.
-@end deffn
-
-hash-create-handle!
-@c snarfed from hashtab.c:750
-@deffn {Scheme Procedure} hash-create-handle! table key init
-@deffnx {C Function} scm_hash_create_handle_x (table, key, init)
-This function looks up @var{key} in @var{table} and returns its handle.
-If @var{key} is not already present, a new handle is created which
-associates @var{key} with @var{init}.
-@end deffn
-
-hash-ref
-@c snarfed from hashtab.c:763
-@deffn {Scheme Procedure} hash-ref table key [dflt]
-@deffnx {C Function} scm_hash_ref (table, key, dflt)
-Look up @var{key} in the hash table @var{table}, and return the
-value (if any) associated with it. If @var{key} is not found,
-return @var{default} (or @code{#f} if no @var{default} argument
-is supplied). Uses @code{equal?} for equality testing.
-@end deffn
-
-hash-set!
-@c snarfed from hashtab.c:778
-@deffn {Scheme Procedure} hash-set! table key val
-@deffnx {C Function} scm_hash_set_x (table, key, val)
-Find the entry in @var{table} associated with @var{key}, and
-store @var{value} there. Uses @code{equal?} for equality
-testing.
-@end deffn
-
-hash-remove!
-@c snarfed from hashtab.c:790
-@deffn {Scheme Procedure} hash-remove! table key
-@deffnx {C Function} scm_hash_remove_x (table, key)
-Remove @var{key} (and any value associated with it) from
-@var{table}. Uses @code{equal?} for equality tests.
-@end deffn
-
-hashx-get-handle
-@c snarfed from hashtab.c:831
-@deffn {Scheme Procedure} hashx-get-handle hash assoc table key
-@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key)
-This behaves the same way as the corresponding
-@code{-get-handle} function, but uses @var{hash} as a hash
-function and @var{assoc} to compare keys. @code{hash} must be
-a function that takes two arguments, a key to be hashed and a
-table size. @code{assoc} must be an associator function, like
-@code{assoc}, @code{assq} or @code{assv}.
-@end deffn
-
-hashx-create-handle!
-@c snarfed from hashtab.c:850
-@deffn {Scheme Procedure} hashx-create-handle! hash assoc table key init
-@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init)
-This behaves the same way as the corresponding
-@code{-create-handle} function, but uses @var{hash} as a hash
-function and @var{assoc} to compare keys. @code{hash} must be
-a function that takes two arguments, a key to be hashed and a
-table size. @code{assoc} must be an associator function, like
-@code{assoc}, @code{assq} or @code{assv}.
-@end deffn
-
-hashx-ref
-@c snarfed from hashtab.c:873
-@deffn {Scheme Procedure} hashx-ref hash assoc table key [dflt]
-@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt)
-This behaves the same way as the corresponding @code{ref}
-function, but uses @var{hash} as a hash function and
-@var{assoc} to compare keys. @code{hash} must be a function
-that takes two arguments, a key to be hashed and a table size.
-@code{assoc} must be an associator function, like @code{assoc},
-@code{assq} or @code{assv}.
-
-By way of illustration, @code{hashq-ref table key} is
-equivalent to @code{hashx-ref hashq assq table key}.
-@end deffn
-
-hashx-set!
-@c snarfed from hashtab.c:899
-@deffn {Scheme Procedure} hashx-set! hash assoc table key val
-@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val)
-This behaves the same way as the corresponding @code{set!}
-function, but uses @var{hash} as a hash function and
-@var{assoc} to compare keys. @code{hash} must be a function
-that takes two arguments, a key to be hashed and a table size.
-@code{assoc} must be an associator function, like @code{assoc},
-@code{assq} or @code{assv}.
-
- By way of illustration, @code{hashq-set! table key} is
-equivalent to @code{hashx-set! hashq assq table key}.
-@end deffn
-
-hashx-remove!
-@c snarfed from hashtab.c:920
-@deffn {Scheme Procedure} hashx-remove! hash assoc table obj
-@deffnx {C Function} scm_hashx_remove_x (hash, assoc, table, obj)
-This behaves the same way as the corresponding @code{remove!}
-function, but uses @var{hash} as a hash function and
-@var{assoc} to compare keys. @code{hash} must be a function
-that takes two arguments, a key to be hashed and a table size.
-@code{assoc} must be an associator function, like @code{assoc},
-@code{assq} or @code{assv}.
-
- By way of illustration, @code{hashq-remove! table key} is
-equivalent to @code{hashx-remove! hashq assq #f table key}.
-@end deffn
-
-hash-fold
-@c snarfed from hashtab.c:1009
-@deffn {Scheme Procedure} hash-fold proc init table
-@deffnx {C Function} scm_hash_fold (proc, init, table)
-An iterator over hash-table elements.
-Accumulates and returns a result by applying PROC successively.
-The arguments to PROC are "(key value prior-result)" where key
-and value are successive pairs from the hash table TABLE, and
-prior-result is either INIT (for the first application of PROC)
-or the return value of the previous application of PROC.
-For example, @code{(hash-fold acons '() tab)} will convert a hash
-table into an a-list of key-value pairs.
-@end deffn
-
-hash-for-each
-@c snarfed from hashtab.c:1030
-@deffn {Scheme Procedure} hash-for-each proc table
-@deffnx {C Function} scm_hash_for_each (proc, table)
-An iterator over hash-table elements.
-Applies PROC successively on all hash table items.
-The arguments to PROC are "(key value)" where key
-and value are successive pairs from the hash table TABLE.
-@end deffn
-
-hash-for-each-handle
-@c snarfed from hashtab.c:1047
-@deffn {Scheme Procedure} hash-for-each-handle proc table
-@deffnx {C Function} scm_hash_for_each_handle (proc, table)
-An iterator over hash-table elements.
-Applies PROC successively on all hash table handles.
-@end deffn
-
-hash-map->list
-@c snarfed from hashtab.c:1073
-@deffn {Scheme Procedure} hash-map->list proc table
-@deffnx {C Function} scm_hash_map_to_list (proc, table)
-An iterator over hash-table elements.
-Accumulates and returns as a list the results of applying PROC successively.
-The arguments to PROC are "(key value)" where key
-and value are successive pairs from the hash table TABLE.
-@end deffn
-
-make-hook
-@c snarfed from hooks.c:154
-@deffn {Scheme Procedure} make-hook [n_args]
-@deffnx {C Function} scm_make_hook (n_args)
-Create a hook for storing procedure of arity @var{n_args}.
-@var{n_args} defaults to zero. The returned value is a hook
-object to be used with the other hook procedures.
-@end deffn
-
-hook?
-@c snarfed from hooks.c:171
-@deffn {Scheme Procedure} hook? x
-@deffnx {C Function} scm_hook_p (x)
-Return @code{#t} if @var{x} is a hook, @code{#f} otherwise.
-@end deffn
-
-hook-empty?
-@c snarfed from hooks.c:182
-@deffn {Scheme Procedure} hook-empty? hook
-@deffnx {C Function} scm_hook_empty_p (hook)
-Return @code{#t} if @var{hook} is an empty hook, @code{#f}
-otherwise.
-@end deffn
-
-add-hook!
-@c snarfed from hooks.c:196
-@deffn {Scheme Procedure} add-hook! hook proc [append_p]
-@deffnx {C Function} scm_add_hook_x (hook, proc, append_p)
-Add the procedure @var{proc} to the hook @var{hook}. The
-procedure is added to the end if @var{append_p} is true,
-otherwise it is added to the front. The return value of this
-procedure is not specified.
-@end deffn
-
-remove-hook!
-@c snarfed from hooks.c:223
-@deffn {Scheme Procedure} remove-hook! hook proc
-@deffnx {C Function} scm_remove_hook_x (hook, proc)
-Remove the procedure @var{proc} from the hook @var{hook}. The
-return value of this procedure is not specified.
-@end deffn
-
-reset-hook!
-@c snarfed from hooks.c:237
-@deffn {Scheme Procedure} reset-hook! hook
-@deffnx {C Function} scm_reset_hook_x (hook)
-Remove all procedures from the hook @var{hook}. The return
-value of this procedure is not specified.
-@end deffn
-
-run-hook
-@c snarfed from hooks.c:251
-@deffn {Scheme Procedure} run-hook hook . args
-@deffnx {C Function} scm_run_hook (hook, args)
-Apply all procedures from the hook @var{hook} to the arguments
-@var{args}. The order of the procedure application is first to
-last. The return value of this procedure is not specified.
-@end deffn
-
-hook->list
-@c snarfed from hooks.c:278
-@deffn {Scheme Procedure} hook->list hook
-@deffnx {C Function} scm_hook_to_list (hook)
-Convert the procedure list of @var{hook} to a list.
-@end deffn
-
-gettext
-@c snarfed from i18n.c:90
-@deffn {Scheme Procedure} gettext msgid [domain [category]]
-@deffnx {C Function} scm_gettext (msgid, domain, category)
-Return the translation of @var{msgid} in the message domain @var{domain}. @var{domain} is optional and defaults to the domain set through (textdomain). @var{category} is optional and defaults to LC_MESSAGES.
-@end deffn
-
-ngettext
-@c snarfed from i18n.c:146
-@deffn {Scheme Procedure} ngettext msgid msgid_plural n [domain [category]]
-@deffnx {C Function} scm_ngettext (msgid, msgid_plural, n, domain, category)
-Return the translation of @var{msgid}/@var{msgid_plural} in the message domain @var{domain}, with the plural form being chosen appropriately for the number @var{n}. @var{domain} is optional and defaults to the domain set through (textdomain). @var{category} is optional and defaults to LC_MESSAGES.
-@end deffn
-
-textdomain
-@c snarfed from i18n.c:209
-@deffn {Scheme Procedure} textdomain [domainname]
-@deffnx {C Function} scm_textdomain (domainname)
-If optional parameter @var{domainname} is supplied, set the textdomain. Return the textdomain.
-@end deffn
-
-bindtextdomain
-@c snarfed from i18n.c:241
-@deffn {Scheme Procedure} bindtextdomain domainname [directory]
-@deffnx {C Function} scm_bindtextdomain (domainname, directory)
-If optional parameter @var{directory} is supplied, set message catalogs to directory @var{directory}. Return the directory bound to @var{domainname}.
-@end deffn
-
-bind-textdomain-codeset
-@c snarfed from i18n.c:280
-@deffn {Scheme Procedure} bind-textdomain-codeset domainname [encoding]
-@deffnx {C Function} scm_bind_textdomain_codeset (domainname, encoding)
-If optional parameter @var{encoding} is supplied, set encoding for message catalogs of @var{domainname}. Return the encoding of @var{domainname}.
-@end deffn
-
-ftell
-@c snarfed from ioext.c:54
-@deffn {Scheme Procedure} ftell fd_port
-@deffnx {C Function} scm_ftell (fd_port)
-Return an integer representing the current position of
-@var{fd/port}, measured from the beginning. Equivalent to:
-
-@lisp
-(seek port 0 SEEK_CUR)
-@end lisp
-@end deffn
-
-redirect-port
-@c snarfed from ioext.c:72
-@deffn {Scheme Procedure} redirect-port old new
-@deffnx {C Function} scm_redirect_port (old, new)
-This procedure takes two ports and duplicates the underlying file
-descriptor from @var{old-port} into @var{new-port}. The
-current file descriptor in @var{new-port} will be closed.
-After the redirection the two ports will share a file position
-and file status flags.
-
-The return value is unspecified.
-
-Unexpected behaviour can result if both ports are subsequently used
-and the original and/or duplicate ports are buffered.
-
-This procedure does not have any side effects on other ports or
-revealed counts.
-@end deffn
-
-dup->fdes
-@c snarfed from ioext.c:111
-@deffn {Scheme Procedure} dup->fdes fd_or_port [fd]
-@deffnx {C Function} scm_dup_to_fdes (fd_or_port, fd)
-Return a new integer file descriptor referring to the open file
-designated by @var{fd_or_port}, which must be either an open
-file port or a file descriptor.
-@end deffn
-
-dup2
-@c snarfed from ioext.c:158
-@deffn {Scheme Procedure} dup2 oldfd newfd
-@deffnx {C Function} scm_dup2 (oldfd, newfd)
-A simple wrapper for the @code{dup2} system call.
-Copies the file descriptor @var{oldfd} to descriptor
-number @var{newfd}, replacing the previous meaning
-of @var{newfd}. Both @var{oldfd} and @var{newfd} must
-be integers.
-Unlike for dup->fdes or primitive-move->fdes, no attempt
-is made to move away ports which are using @var{newfd}.
-The return value is unspecified.
-@end deffn
-
-fileno
-@c snarfed from ioext.c:177
-@deffn {Scheme Procedure} fileno port
-@deffnx {C Function} scm_fileno (port)
-Return the integer file descriptor underlying @var{port}. Does
-not change its revealed count.
-@end deffn
-
-isatty?
-@c snarfed from ioext.c:197
-@deffn {Scheme Procedure} isatty? port
-@deffnx {C Function} scm_isatty_p (port)
-Return @code{#t} if @var{port} is using a serial non--file
-device, otherwise @code{#f}.
-@end deffn
-
-fdopen
-@c snarfed from ioext.c:219
-@deffn {Scheme Procedure} fdopen fdes modes
-@deffnx {C Function} scm_fdopen (fdes, modes)
-Return a new port based on the file descriptor @var{fdes}.
-Modes are given by the string @var{modes}. The revealed count
-of the port is initialized to zero. The modes string is the
-same as that accepted by @ref{File Ports, open-file}.
-@end deffn
-
-primitive-move->fdes
-@c snarfed from ioext.c:241
-@deffn {Scheme Procedure} primitive-move->fdes port fd
-@deffnx {C Function} scm_primitive_move_to_fdes (port, fd)
-Moves the underlying file descriptor for @var{port} to the integer
-value @var{fdes} without changing the revealed count of @var{port}.
-Any other ports already using this descriptor will be automatically
-shifted to new descriptors and their revealed counts reset to zero.
-The return value is @code{#f} if the file descriptor already had the
-required value or @code{#t} if it was moved.
-@end deffn
-
-fdes->ports
-@c snarfed from ioext.c:274
-@deffn {Scheme Procedure} fdes->ports fd
-@deffnx {C Function} scm_fdes_to_ports (fd)
-Return a list of existing ports which have @var{fdes} as an
-underlying file descriptor, without changing their revealed
-counts.
-@end deffn
-
-keyword?
-@c snarfed from keywords.c:52
-@deffn {Scheme Procedure} keyword? obj
-@deffnx {C Function} scm_keyword_p (obj)
-Return @code{#t} if the argument @var{obj} is a keyword, else
-@code{#f}.
-@end deffn
-
-symbol->keyword
-@c snarfed from keywords.c:61
-@deffn {Scheme Procedure} symbol->keyword symbol
-@deffnx {C Function} scm_symbol_to_keyword (symbol)
-Return the keyword with the same name as @var{symbol}.
-@end deffn
-
-keyword->symbol
-@c snarfed from keywords.c:82
-@deffn {Scheme Procedure} keyword->symbol keyword
-@deffnx {C Function} scm_keyword_to_symbol (keyword)
-Return the symbol with the same name as @var{keyword}.
-@end deffn
-
-list
-@c snarfed from list.c:104
-@deffn {Scheme Procedure} list . objs
-@deffnx {C Function} scm_list (objs)
-Return a list containing @var{objs}, the arguments to
-@code{list}.
-@end deffn
-
-cons*
-@c snarfed from list.c:119
-@deffn {Scheme Procedure} cons* arg . rest
-@deffnx {C Function} scm_cons_star (arg, rest)
-Like @code{list}, but the last arg provides the tail of the
-constructed list, returning @code{(cons @var{arg1} (cons
-@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one
-argument. If given one argument, that argument is returned as
-result. This function is called @code{list*} in some other
-Schemes and in Common LISP.
-@end deffn
-
-null?
-@c snarfed from list.c:143
-@deffn {Scheme Procedure} null? x
-@deffnx {C Function} scm_null_p (x)
-Return @code{#t} iff @var{x} is the empty list, else @code{#f}.
-@end deffn
-
-list?
-@c snarfed from list.c:153
-@deffn {Scheme Procedure} list? x
-@deffnx {C Function} scm_list_p (x)
-Return @code{#t} iff @var{x} is a proper list, else @code{#f}.
-@end deffn
-
-length
-@c snarfed from list.c:194
-@deffn {Scheme Procedure} length lst
-@deffnx {C Function} scm_length (lst)
-Return the number of elements in list @var{lst}.
-@end deffn
-
-append
-@c snarfed from list.c:223
-@deffn {Scheme Procedure} append . args
-@deffnx {C Function} scm_append (args)
-Return a list consisting of the elements the lists passed as
-arguments.
-@lisp
-(append '(x) '(y)) @result{} (x y)
-(append '(a) '(b c d)) @result{} (a b c d)
-(append '(a (b)) '((c))) @result{} (a (b) (c))
-@end lisp
-The resulting list is always newly allocated, except that it
-shares structure with the last list argument. The last
-argument may actually be any object; an improper list results
-if the last argument is not a proper list.
-@lisp
-(append '(a b) '(c . d)) @result{} (a b c . d)
-(append '() 'a) @result{} a
-@end lisp
-@end deffn
-
-append!
-@c snarfed from list.c:259
-@deffn {Scheme Procedure} append! . lists
-@deffnx {C Function} scm_append_x (lists)
-A destructive version of @code{append} (@pxref{Pairs and
-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
-the next list, so no consing is performed. Return
-the mutated list.
-@end deffn
-
-last-pair
-@c snarfed from list.c:291
-@deffn {Scheme Procedure} last-pair lst
-@deffnx {C Function} scm_last_pair (lst)
-Return the last pair in @var{lst}, signalling an error if
-@var{lst} is circular.
-@end deffn
-
-reverse
-@c snarfed from list.c:321
-@deffn {Scheme Procedure} reverse lst
-@deffnx {C Function} scm_reverse (lst)
-Return a new list that contains the elements of @var{lst} but
-in reverse order.
-@end deffn
-
-reverse!
-@c snarfed from list.c:355
-@deffn {Scheme Procedure} reverse! lst [new_tail]
-@deffnx {C Function} scm_reverse_x (lst, new_tail)
-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
-modified to point to the previous list element. Return the
-reversed list.
-
-Caveat: because the list is modified in place, the tail of the original
-list now becomes its head, and the head of the original list now becomes
-the tail. Therefore, the @var{lst} symbol to which the head of the
-original list was bound now points to the tail. To ensure that the head
-of the modified list is not lost, it is wise to save the return value of
-@code{reverse!}
-@end deffn
-
-list-ref
-@c snarfed from list.c:381
-@deffn {Scheme Procedure} list-ref list k
-@deffnx {C Function} scm_list_ref (list, k)
-Return the @var{k}th element from @var{list}.
-@end deffn
-
-list-set!
-@c snarfed from list.c:405
-@deffn {Scheme Procedure} list-set! list k val
-@deffnx {C Function} scm_list_set_x (list, k, val)
-Set the @var{k}th element of @var{list} to @var{val}.
-@end deffn
-
-list-cdr-ref
-@c snarfed from list.c:427
-@deffn {Scheme Procedure} list-cdr-ref
-implemented by the C function "scm_list_tail"
-@end deffn
-
-list-tail
-@c snarfed from list.c:436
-@deffn {Scheme Procedure} list-tail lst k
-@deffnx {Scheme Procedure} list-cdr-ref lst k
-@deffnx {C Function} scm_list_tail (lst, k)
-Return the "tail" of @var{lst} beginning with its @var{k}th element.
-The first element of the list is considered to be element 0.
-
-@code{list-tail} and @code{list-cdr-ref} are identical. It may help to
-think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list,
-or returning the results of cdring @var{k} times down @var{lst}.
-@end deffn
-
-list-cdr-set!
-@c snarfed from list.c:451
-@deffn {Scheme Procedure} list-cdr-set! list k val
-@deffnx {C Function} scm_list_cdr_set_x (list, k, val)
-Set the @var{k}th cdr of @var{list} to @var{val}.
-@end deffn
-
-list-head
-@c snarfed from list.c:479
-@deffn {Scheme Procedure} list-head lst k
-@deffnx {C Function} scm_list_head (lst, k)
-Copy the first @var{k} elements from @var{lst} into a new list, and
-return it.
-@end deffn
-
-list-copy
-@c snarfed from list.c:530
-@deffn {Scheme Procedure} list-copy lst
-@deffnx {C Function} scm_list_copy (lst)
-Return a (newly-created) copy of @var{lst}.
-@end deffn
-
-memq
-@c snarfed from list.c:584
-@deffn {Scheme Procedure} memq x lst
-@deffnx {C Function} scm_memq (x, lst)
-Return the first sublist of @var{lst} whose car is @code{eq?}
-to @var{x} where the sublists of @var{lst} are the non-empty
-lists returned by @code{(list-tail @var{lst} @var{k})} for
-@var{k} less than the length of @var{lst}. If @var{x} does not
-occur in @var{lst}, then @code{#f} (not the empty list) is
-returned.
-@end deffn
-
-memv
-@c snarfed from list.c:600
-@deffn {Scheme Procedure} memv x lst
-@deffnx {C Function} scm_memv (x, lst)
-Return the first sublist of @var{lst} whose car is @code{eqv?}
-to @var{x} where the sublists of @var{lst} are the non-empty
-lists returned by @code{(list-tail @var{lst} @var{k})} for
-@var{k} less than the length of @var{lst}. If @var{x} does not
-occur in @var{lst}, then @code{#f} (not the empty list) is
-returned.
-@end deffn
-
-member
-@c snarfed from list.c:621
-@deffn {Scheme Procedure} member x lst
-@deffnx {C Function} scm_member (x, lst)
-Return the first sublist of @var{lst} whose car is
-@code{equal?} to @var{x} where the sublists of @var{lst} are
-the non-empty lists returned by @code{(list-tail @var{lst}
-@var{k})} for @var{k} less than the length of @var{lst}. If
-@var{x} does not occur in @var{lst}, then @code{#f} (not the
-empty list) is returned.
-@end deffn
-
-delq!
-@c snarfed from list.c:646
-@deffn {Scheme Procedure} delq! item lst
-@deffnx {Scheme Procedure} delv! item lst
-@deffnx {Scheme Procedure} delete! item lst
-@deffnx {C Function} scm_delq_x (item, lst)
-These procedures are destructive versions of @code{delq}, @code{delv}
-and @code{delete}: they modify the existing @var{lst}
-rather than creating a new list. Caveat evaluator: Like other
-destructive list functions, these functions cannot modify the binding of
-@var{lst}, and so cannot be used to delete the first element of
-@var{lst} destructively.
-@end deffn
-
-delv!
-@c snarfed from list.c:670
-@deffn {Scheme Procedure} delv! item lst
-@deffnx {C Function} scm_delv_x (item, lst)
-Destructively remove all elements from @var{lst} that are
-@code{eqv?} to @var{item}.
-@end deffn
-
-delete!
-@c snarfed from list.c:695
-@deffn {Scheme Procedure} delete! item lst
-@deffnx {C Function} scm_delete_x (item, lst)
-Destructively remove all elements from @var{lst} that are
-@code{equal?} to @var{item}.
-@end deffn
-
-delq
-@c snarfed from list.c:724
-@deffn {Scheme Procedure} delq item lst
-@deffnx {C Function} scm_delq (item, lst)
-Return a newly-created copy of @var{lst} with elements
-@code{eq?} to @var{item} removed. This procedure mirrors
-@code{memq}: @code{delq} compares elements of @var{lst} against
-@var{item} with @code{eq?}.
-@end deffn
-
-delv
-@c snarfed from list.c:737
-@deffn {Scheme Procedure} delv item lst
-@deffnx {C Function} scm_delv (item, lst)
-Return a newly-created copy of @var{lst} with elements
-@code{eqv?} to @var{item} removed. This procedure mirrors
-@code{memv}: @code{delv} compares elements of @var{lst} against
-@var{item} with @code{eqv?}.
-@end deffn
-
-delete
-@c snarfed from list.c:750
-@deffn {Scheme Procedure} delete item lst
-@deffnx {C Function} scm_delete (item, lst)
-Return a newly-created copy of @var{lst} with elements
-@code{equal?} to @var{item} removed. This procedure mirrors
-@code{member}: @code{delete} compares elements of @var{lst}
-against @var{item} with @code{equal?}.
-@end deffn
-
-delq1!
-@c snarfed from list.c:763
-@deffn {Scheme Procedure} delq1! item lst
-@deffnx {C Function} scm_delq1_x (item, lst)
-Like @code{delq!}, but only deletes the first occurrence of
-@var{item} from @var{lst}. Tests for equality using
-@code{eq?}. See also @code{delv1!} and @code{delete1!}.
-@end deffn
-
-delv1!
-@c snarfed from list.c:791
-@deffn {Scheme Procedure} delv1! item lst
-@deffnx {C Function} scm_delv1_x (item, lst)
-Like @code{delv!}, but only deletes the first occurrence of
-@var{item} from @var{lst}. Tests for equality using
-@code{eqv?}. See also @code{delq1!} and @code{delete1!}.
-@end deffn
-
-delete1!
-@c snarfed from list.c:819
-@deffn {Scheme Procedure} delete1! item lst
-@deffnx {C Function} scm_delete1_x (item, lst)
-Like @code{delete!}, but only deletes the first occurrence of
-@var{item} from @var{lst}. Tests for equality using
-@code{equal?}. See also @code{delq1!} and @code{delv1!}.
-@end deffn
-
-filter
-@c snarfed from list.c:851
-@deffn {Scheme Procedure} filter pred list
-@deffnx {C Function} scm_filter (pred, list)
-Return all the elements of 2nd arg @var{list} that satisfy predicate @var{pred}.
-The list is not disordered -- elements that appear in the result list occur
-in the same order as they occur in the argument list. The returned list may
-share a common tail with the argument list. The dynamic order in which the
-various applications of pred are made is not specified.
-
-@lisp
-(filter even? '(0 7 8 8 43 -4)) => (0 8 8 -4)
-@end lisp
-@end deffn
-
-filter!
-@c snarfed from list.c:878
-@deffn {Scheme Procedure} filter! pred list
-@deffnx {C Function} scm_filter_x (pred, list)
-Linear-update variant of @code{filter}.
-@end deffn
-
-primitive-load
-@c snarfed from load.c:72
-@deffn {Scheme Procedure} primitive-load filename
-@deffnx {C Function} scm_primitive_load (filename)
-Load the file named @var{filename} and evaluate its contents in
-the top-level environment. The load paths are not searched;
-@var{filename} must either be a full pathname or be a pathname
-relative to the current directory. If the variable
-@code{%load-hook} is defined, it should be bound to a procedure
-that will be called before any code is loaded. See the
-documentation for @code{%load-hook} later in this section.
-@end deffn
-
-%package-data-dir
-@c snarfed from load.c:117
-@deffn {Scheme Procedure} %package-data-dir
-@deffnx {C Function} scm_sys_package_data_dir ()
-Return the name of the directory where Scheme packages, modules and
-libraries are kept. On most Unix systems, this will be
-@samp{/usr/local/share/guile}.
-@end deffn
-
-%library-dir
-@c snarfed from load.c:129
-@deffn {Scheme Procedure} %library-dir
-@deffnx {C Function} scm_sys_library_dir ()
-Return the directory where the Guile Scheme library files are installed.
-E.g., may return "/usr/share/guile/1.3.5".
-@end deffn
-
-%site-dir
-@c snarfed from load.c:141
-@deffn {Scheme Procedure} %site-dir
-@deffnx {C Function} scm_sys_site_dir ()
-Return the directory where the Guile site files are installed.
-E.g., may return "/usr/share/guile/site".
-@end deffn
-
-parse-path
-@c snarfed from load.c:166
-@deffn {Scheme Procedure} parse-path path [tail]
-@deffnx {C Function} scm_parse_path (path, tail)
-Parse @var{path}, which is expected to be a colon-separated
-string, into a list and return the resulting list with
-@var{tail} appended. If @var{path} is @code{#f}, @var{tail}
-is returned.
-@end deffn
-
-search-path
-@c snarfed from load.c:293
-@deffn {Scheme Procedure} search-path path filename [extensions]
-@deffnx {C Function} scm_search_path (path, filename, extensions)
-Search @var{path} for a directory containing a file named
-@var{filename}. The file must be readable, and not a directory.
-If we find one, return its full filename; otherwise, return
-@code{#f}. If @var{filename} is absolute, return it unchanged.
-If given, @var{extensions} is a list of strings; for each
-directory in @var{path}, we search for @var{filename}
-concatenated with each @var{extension}.
-@end deffn
-
-%search-load-path
-@c snarfed from load.c:430
-@deffn {Scheme Procedure} %search-load-path filename
-@deffnx {C Function} scm_sys_search_load_path (filename)
-Search @var{%load-path} for the file named @var{filename},
-which must be readable by the current user. If @var{filename}
-is found in the list of paths to search or is an absolute
-pathname, return its full pathname. Otherwise, return
-@code{#f}. Filenames may have any of the optional extensions
-in the @code{%load-extensions} list; @code{%search-load-path}
-will try each extension automatically.
-@end deffn
-
-primitive-load-path
-@c snarfed from load.c:451
-@deffn {Scheme Procedure} primitive-load-path filename
-@deffnx {C Function} scm_primitive_load_path (filename)
-Search @var{%load-path} for the file named @var{filename} and
-load it into the top-level environment. If @var{filename} is a
-relative pathname and is not found in the list of search paths,
-an error is signalled.
-@end deffn
-
-procedure->memoizing-macro
-@c snarfed from macros.c:109
-@deffn {Scheme Procedure} procedure->memoizing-macro code
-@deffnx {C Function} scm_makmmacro (code)
-Return a @dfn{macro} which, when a symbol defined to this value
-appears as the first symbol in an expression, evaluates the
-result of applying @var{code} to the expression and the
-environment.
-
-@code{procedure->memoizing-macro} is the same as
-@code{procedure->macro}, except that the expression returned by
-@var{code} replaces the original macro expression in the memoized
-form of the containing code.
-@end deffn
-
-procedure->syntax
-@c snarfed from macros.c:123
-@deffn {Scheme Procedure} procedure->syntax code
-@deffnx {C Function} scm_makacro (code)
-Return a @dfn{macro} which, when a symbol defined to this value
-appears as the first symbol in an expression, returns the
-result of applying @var{code} to the expression and the
-environment.
-@end deffn
-
-procedure->macro
-@c snarfed from macros.c:146
-@deffn {Scheme Procedure} procedure->macro code
-@deffnx {C Function} scm_makmacro (code)
-Return a @dfn{macro} which, when a symbol defined to this value
-appears as the first symbol in an expression, evaluates the
-result of applying @var{code} to the expression and the
-environment. For example:
-
-@lisp
-(define trace
- (procedure->macro
- (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x))))))
-
-(trace @i{foo}) @equiv{} (set! @i{foo} (tracef @i{foo} '@i{foo})).
-@end lisp
-@end deffn
-
-macro?
-@c snarfed from macros.c:165
-@deffn {Scheme Procedure} macro? obj
-@deffnx {C Function} scm_macro_p (obj)
-Return @code{#t} if @var{obj} is a regular macro, a memoizing macro, a
-syntax transformer, or a syntax-case macro.
-@end deffn
-
-macro-type
-@c snarfed from macros.c:186
-@deffn {Scheme Procedure} macro-type m
-@deffnx {C Function} scm_macro_type (m)
-Return one of the symbols @code{syntax}, @code{macro},
-@code{macro!}, or @code{syntax-case}, depending on whether
-@var{m} is a syntax transformer, a regular macro, a memoizing
-macro, or a syntax-case macro, respectively. If @var{m} is
-not a macro, @code{#f} is returned.
-@end deffn
-
-macro-name
-@c snarfed from macros.c:207
-@deffn {Scheme Procedure} macro-name m
-@deffnx {C Function} scm_macro_name (m)
-Return the name of the macro @var{m}.
-@end deffn
-
-macro-transformer
-@c snarfed from macros.c:218
-@deffn {Scheme Procedure} macro-transformer m
-@deffnx {C Function} scm_macro_transformer (m)
-Return the transformer of the macro @var{m}.
-@end deffn
-
-current-module
-@c snarfed from modules.c:45
-@deffn {Scheme Procedure} current-module
-@deffnx {C Function} scm_current_module ()
-Return the current module.
-@end deffn
-
-set-current-module
-@c snarfed from modules.c:57
-@deffn {Scheme Procedure} set-current-module module
-@deffnx {C Function} scm_set_current_module (module)
-Set the current module to @var{module} and return
-the previous current module.
-@end deffn
-
-interaction-environment
-@c snarfed from modules.c:80
-@deffn {Scheme Procedure} interaction-environment
-@deffnx {C Function} scm_interaction_environment ()
-Return a specifier for the environment that contains
-implementation--defined bindings, typically a superset of those
-listed in the report. The intent is that this procedure will
-return the environment in which the implementation would
-evaluate expressions dynamically typed by the user.
-@end deffn
-
-env-module
-@c snarfed from modules.c:266
-@deffn {Scheme Procedure} env-module env
-@deffnx {C Function} scm_env_module (env)
-Return the module of @var{ENV}, a lexical environment.
-@end deffn
-
-standard-eval-closure
-@c snarfed from modules.c:342
-@deffn {Scheme Procedure} standard-eval-closure module
-@deffnx {C Function} scm_standard_eval_closure (module)
-Return an eval closure for the module @var{module}.
-@end deffn
-
-standard-interface-eval-closure
-@c snarfed from modules.c:353
-@deffn {Scheme Procedure} standard-interface-eval-closure module
-@deffnx {C Function} scm_standard_interface_eval_closure (module)
-Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added.
-@end deffn
-
-module-import-interface
-@c snarfed from modules.c:399
-@deffn {Scheme Procedure} module-import-interface module sym
-@deffnx {C Function} scm_module_import_interface (module, sym)
-Return the module or interface from which @var{sym} is imported in @var{module}. If @var{sym} is not imported (i.e., it is not defined in @var{module} or it is a module-local binding instead of an imported one), then @code{#f} is returned.
-@end deffn
-
-%get-pre-modules-obarray
-@c snarfed from modules.c:616
-@deffn {Scheme Procedure} %get-pre-modules-obarray
-@deffnx {C Function} scm_get_pre_modules_obarray ()
-Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system.
-@end deffn
-
-exact?
-@c snarfed from numbers.c:460
-@deffn {Scheme Procedure} exact? x
-@deffnx {C Function} scm_exact_p (x)
-Return @code{#t} if @var{x} is an exact number, @code{#f}
-otherwise.
-@end deffn
-
-odd?
-@c snarfed from numbers.c:479
-@deffn {Scheme Procedure} odd? n
-@deffnx {C Function} scm_odd_p (n)
-Return @code{#t} if @var{n} is an odd number, @code{#f}
-otherwise.
-@end deffn
-
-even?
-@c snarfed from numbers.c:514
-@deffn {Scheme Procedure} even? n
-@deffnx {C Function} scm_even_p (n)
-Return @code{#t} if @var{n} is an even number, @code{#f}
-otherwise.
-@end deffn
-
-inf?
-@c snarfed from numbers.c:548
-@deffn {Scheme Procedure} inf? x
-@deffnx {C Function} scm_inf_p (x)
-Return @code{#t} if @var{x} is either @samp{+inf.0}
-or @samp{-inf.0}, @code{#f} otherwise.
-@end deffn
-
-nan?
-@c snarfed from numbers.c:564
-@deffn {Scheme Procedure} nan? n
-@deffnx {C Function} scm_nan_p (n)
-Return @code{#t} if @var{n} is a NaN, @code{#f}
-otherwise.
-@end deffn
-
-inf
-@c snarfed from numbers.c:634
-@deffn {Scheme Procedure} inf
-@deffnx {C Function} scm_inf ()
-Return Inf.
-@end deffn
-
-nan
-@c snarfed from numbers.c:649
-@deffn {Scheme Procedure} nan
-@deffnx {C Function} scm_nan ()
-Return NaN.
-@end deffn
-
-abs
-@c snarfed from numbers.c:665
-@deffn {Scheme Procedure} abs x
-@deffnx {C Function} scm_abs (x)
-Return the absolute value of @var{x}.
-@end deffn
-
-logand
-@c snarfed from numbers.c:1201
-@deffn {Scheme Procedure} logand n1 n2
-Return the bitwise AND of the integer arguments.
-
-@lisp
-(logand) @result{} -1
-(logand 7) @result{} 7
-(logand #b111 #b011 #b001) @result{} 1
-@end lisp
-@end deffn
-
-logior
-@c snarfed from numbers.c:1277
-@deffn {Scheme Procedure} logior n1 n2
-Return the bitwise OR of the integer arguments.
-
-@lisp
-(logior) @result{} 0
-(logior 7) @result{} 7
-(logior #b000 #b001 #b011) @result{} 3
-@end lisp
-@end deffn
-
-logxor
-@c snarfed from numbers.c:1353
-@deffn {Scheme Procedure} logxor n1 n2
-Return the bitwise XOR of the integer arguments. A bit is
-set in the result if it is set in an odd number of arguments.
-@lisp
-(logxor) @result{} 0
-(logxor 7) @result{} 7
-(logxor #b000 #b001 #b011) @result{} 2
-(logxor #b000 #b001 #b011 #b011) @result{} 1
-@end lisp
-@end deffn
-
-logtest
-@c snarfed from numbers.c:1428
-@deffn {Scheme Procedure} logtest j k
-@deffnx {C Function} scm_logtest (j, k)
-Test whether @var{j} and @var{k} have any 1 bits in common.
-This is equivalent to @code{(not (zero? (logand j k)))}, but
-without actually calculating the @code{logand}, just testing
-for non-zero.
-
-@lisp
-(logtest #b0100 #b1011) @result{} #f
-(logtest #b0100 #b0111) @result{} #t
-@end lisp
-@end deffn
-
-logbit?
-@c snarfed from numbers.c:1501
-@deffn {Scheme Procedure} logbit? index j
-@deffnx {C Function} scm_logbit_p (index, j)
-Test whether bit number @var{index} in @var{j} is set.
-@var{index} starts from 0 for the least significant bit.
-
-@lisp
-(logbit? 0 #b1101) @result{} #t
-(logbit? 1 #b1101) @result{} #f
-(logbit? 2 #b1101) @result{} #t
-(logbit? 3 #b1101) @result{} #t
-(logbit? 4 #b1101) @result{} #f
-@end lisp
-@end deffn
-
-lognot
-@c snarfed from numbers.c:1535
-@deffn {Scheme Procedure} lognot n
-@deffnx {C Function} scm_lognot (n)
-Return the integer which is the ones-complement of the integer
-argument.
-
-@lisp
-(number->string (lognot #b10000000) 2)
- @result{} "-10000001"
-(number->string (lognot #b0) 2)
- @result{} "-1"
-@end lisp
-@end deffn
-
-modulo-expt
-@c snarfed from numbers.c:1580
-@deffn {Scheme Procedure} modulo-expt n k m
-@deffnx {C Function} scm_modulo_expt (n, k, m)
-Return @var{n} raised to the integer exponent
-@var{k}, modulo @var{m}.
-
-@lisp
-(modulo-expt 2 3 5)
- @result{} 3
-@end lisp
-@end deffn
-
-integer-expt
-@c snarfed from numbers.c:1689
-@deffn {Scheme Procedure} integer-expt n k
-@deffnx {C Function} scm_integer_expt (n, k)
-Return @var{n} raised to the power @var{k}. @var{k} must be an
-exact integer, @var{n} can be any number.
-
-Negative @var{k} is supported, and results in @math{1/n^abs(k)}
-in the usual way. @math{@var{n}^0} is 1, as usual, and that
-includes @math{0^0} is 1.
-
-@lisp
-(integer-expt 2 5) @result{} 32
-(integer-expt -3 3) @result{} -27
-(integer-expt 5 -3) @result{} 1/125
-(integer-expt 0 0) @result{} 1
-@end lisp
-@end deffn
-
-ash
-@c snarfed from numbers.c:1779
-@deffn {Scheme Procedure} ash n cnt
-@deffnx {C Function} scm_ash (n, cnt)
-Return @var{n} shifted left by @var{cnt} bits, or shifted right
-if @var{cnt} is negative. This is an ``arithmetic'' shift.
-
-This is effectively a multiplication by 2^@var{cnt}, and when
-@var{cnt} is negative it's a division, rounded towards negative
-infinity. (Note that this is not the same rounding as
-@code{quotient} does.)
-
-With @var{n} viewed as an infinite precision twos complement,
-@code{ash} means a left shift introducing zero bits, or a right
-shift dropping bits.
-
-@lisp
-(number->string (ash #b1 3) 2) @result{} "1000"
-(number->string (ash #b1010 -1) 2) @result{} "101"
-
-;; -23 is bits ...11101001, -6 is bits ...111010
-(ash -23 -2) @result{} -6
-@end lisp
-@end deffn
-
-bit-extract
-@c snarfed from numbers.c:1870
-@deffn {Scheme Procedure} bit-extract n start end
-@deffnx {C Function} scm_bit_extract (n, start, end)
-Return the integer composed of the @var{start} (inclusive)
-through @var{end} (exclusive) bits of @var{n}. The
-@var{start}th bit becomes the 0-th bit in the result.
-
-@lisp
-(number->string (bit-extract #b1101101010 0 4) 2)
- @result{} "1010"
-(number->string (bit-extract #b1101101010 4 9) 2)
- @result{} "10110"
-@end lisp
-@end deffn
-
-logcount
-@c snarfed from numbers.c:1949
-@deffn {Scheme Procedure} logcount n
-@deffnx {C Function} scm_logcount (n)
-Return the number of bits in integer @var{n}. If integer is
-positive, the 1-bits in its binary representation are counted.
-If negative, the 0-bits in its two's-complement binary
-representation are counted. If 0, 0 is returned.
-
-@lisp
-(logcount #b10101010)
- @result{} 4
-(logcount 0)
- @result{} 0
-(logcount -2)
- @result{} 1
-@end lisp
-@end deffn
-
-integer-length
-@c snarfed from numbers.c:1997
-@deffn {Scheme Procedure} integer-length n
-@deffnx {C Function} scm_integer_length (n)
-Return the number of bits necessary to represent @var{n}.
-
-@lisp
-(integer-length #b10101010)
- @result{} 8
-(integer-length 0)
- @result{} 0
-(integer-length #b1111)
- @result{} 4
-@end lisp
-@end deffn
-
-number->string
-@c snarfed from numbers.c:2337
-@deffn {Scheme Procedure} number->string n [radix]
-@deffnx {C Function} scm_number_to_string (n, radix)
-Return a string holding the external representation of the
-number @var{n} in the given @var{radix}. If @var{n} is
-inexact, a radix of 10 will be used.
-@end deffn
-
-string->number
-@c snarfed from numbers.c:3034
-@deffn {Scheme Procedure} string->number string [radix]
-@deffnx {C Function} scm_string_to_number (string, radix)
-Return a number of the maximally precise representation
-expressed by the given @var{string}. @var{radix} must be an
-exact integer, either 2, 8, 10, or 16. If supplied, @var{radix}
-is a default radix that may be overridden by an explicit radix
-prefix in @var{string} (e.g. "#o177"). If @var{radix} is not
-supplied, then the default radix is 10. If string is not a
-syntactically valid notation for a number, then
-@code{string->number} returns @code{#f}.
-@end deffn
-
-number?
-@c snarfed from numbers.c:3097
-@deffn {Scheme Procedure} number? x
-@deffnx {C Function} scm_number_p (x)
-Return @code{#t} if @var{x} is a number, @code{#f}
-otherwise.
-@end deffn
-
-complex?
-@c snarfed from numbers.c:3110
-@deffn {Scheme Procedure} complex? x
-@deffnx {C Function} scm_complex_p (x)
-Return @code{#t} if @var{x} is a complex number, @code{#f}
-otherwise. Note that the sets of real, rational and integer
-values form subsets of the set of complex numbers, i. e. the
-predicate will also be fulfilled if @var{x} is a real,
-rational or integer number.
-@end deffn
-
-real?
-@c snarfed from numbers.c:3123
-@deffn {Scheme Procedure} real? x
-@deffnx {C Function} scm_real_p (x)
-Return @code{#t} if @var{x} is a real number, @code{#f}
-otherwise. Note that the set of integer values forms a subset of
-the set of real numbers, i. e. the predicate will also be
-fulfilled if @var{x} is an integer number.
-@end deffn
-
-rational?
-@c snarfed from numbers.c:3136
-@deffn {Scheme Procedure} rational? x
-@deffnx {C Function} scm_rational_p (x)
-Return @code{#t} if @var{x} is a rational number, @code{#f}
-otherwise. Note that the set of integer values forms a subset of
-the set of rational numbers, i. e. the predicate will also be
-fulfilled if @var{x} is an integer number.
-@end deffn
-
-integer?
-@c snarfed from numbers.c:3159
-@deffn {Scheme Procedure} integer? x
-@deffnx {C Function} scm_integer_p (x)
-Return @code{#t} if @var{x} is an integer number, @code{#f}
-else.
-@end deffn
-
-inexact?
-@c snarfed from numbers.c:3185
-@deffn {Scheme Procedure} inexact? x
-@deffnx {C Function} scm_inexact_p (x)
-Return @code{#t} if @var{x} is an inexact number, @code{#f}
-else.
-@end deffn
-
-truncate
-@c snarfed from numbers.c:5060
-@deffn {Scheme Procedure} truncate x
-@deffnx {C Function} scm_truncate_number (x)
-Round the number @var{x} towards zero.
-@end deffn
-
-round
-@c snarfed from numbers.c:5076
-@deffn {Scheme Procedure} round x
-@deffnx {C Function} scm_round_number (x)
-Round the number @var{x} towards the nearest integer. When it is exactly halfway between two integers, round towards the even one.
-@end deffn
-
-floor
-@c snarfed from numbers.c:5102
-@deffn {Scheme Procedure} floor x
-@deffnx {C Function} scm_floor (x)
-Round the number @var{x} towards minus infinity.
-@end deffn
-
-ceiling
-@c snarfed from numbers.c:5133
-@deffn {Scheme Procedure} ceiling x
-@deffnx {C Function} scm_ceiling (x)
-Round the number @var{x} towards infinity.
-@end deffn
-
-$expt
-@c snarfed from numbers.c:5242
-@deffn {Scheme Procedure} $expt x y
-@deffnx {C Function} scm_sys_expt (x, y)
-Return @var{x} raised to the power of @var{y}. This
-procedure does not accept complex arguments.
-@end deffn
-
-$atan2
-@c snarfed from numbers.c:5258
-@deffn {Scheme Procedure} $atan2 x y
-@deffnx {C Function} scm_sys_atan2 (x, y)
-Return the arc tangent of the two arguments @var{x} and
-@var{y}. This is similar to calculating the arc tangent of
-@var{x} / @var{y}, except that the signs of both arguments
-are used to determine the quadrant of the result. This
-procedure does not accept complex arguments.
-@end deffn
-
-make-rectangular
-@c snarfed from numbers.c:5286
-@deffn {Scheme Procedure} make-rectangular real_part imaginary_part
-@deffnx {C Function} scm_make_rectangular (real_part, imaginary_part)
-Return a complex number constructed of the given @var{real-part} and @var{imaginary-part} parts.
-@end deffn
-
-make-polar
-@c snarfed from numbers.c:5310
-@deffn {Scheme Procedure} make-polar x y
-@deffnx {C Function} scm_make_polar (x, y)
-Return the complex number @var{x} * e^(i * @var{y}).
-@end deffn
-
-inexact->exact
-@c snarfed from numbers.c:5513
-@deffn {Scheme Procedure} inexact->exact z
-@deffnx {C Function} scm_inexact_to_exact (z)
-Return an exact number that is numerically closest to @var{z}.
-@end deffn
-
-rationalize
-@c snarfed from numbers.c:5550
-@deffn {Scheme Procedure} rationalize x err
-@deffnx {C Function} scm_rationalize (x, err)
-Return an exact number that is within @var{err} of @var{x}.
-@end deffn
-
-entity?
-@c snarfed from objects.c:192
-@deffn {Scheme Procedure} entity? obj
-@deffnx {C Function} scm_entity_p (obj)
-Return @code{#t} if @var{obj} is an entity.
-@end deffn
-
-operator?
-@c snarfed from objects.c:201
-@deffn {Scheme Procedure} operator? obj
-@deffnx {C Function} scm_operator_p (obj)
-Return @code{#t} if @var{obj} is an operator.
-@end deffn
-
-valid-object-procedure?
-@c snarfed from objects.c:217
-@deffn {Scheme Procedure} valid-object-procedure? proc
-@deffnx {C Function} scm_valid_object_procedure_p (proc)
-Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}.
-@end deffn
-
-set-object-procedure!
-@c snarfed from objects.c:239
-@deffn {Scheme Procedure} set-object-procedure! obj proc
-@deffnx {C Function} scm_set_object_procedure_x (obj, proc)
-Set the object procedure of @var{obj} to @var{proc}.
-@var{obj} must be either an entity or an operator.
-@end deffn
-
-make-class-object
-@c snarfed from objects.c:299
-@deffn {Scheme Procedure} make-class-object metaclass layout
-@deffnx {C Function} scm_make_class_object (metaclass, layout)
-Create a new class object of class @var{metaclass}, with the
-slot layout specified by @var{layout}.
-@end deffn
-
-make-subclass-object
-@c snarfed from objects.c:314
-@deffn {Scheme Procedure} make-subclass-object class layout
-@deffnx {C Function} scm_make_subclass_object (class, layout)
-Create a subclass object of @var{class}, with the slot layout
-specified by @var{layout}.
-@end deffn
-
-object-properties
-@c snarfed from objprop.c:36
-@deffn {Scheme Procedure} object-properties obj
-@deffnx {C Function} scm_object_properties (obj)
-Return @var{obj}'s property list.
-@end deffn
-
-set-object-properties!
-@c snarfed from objprop.c:46
-@deffn {Scheme Procedure} set-object-properties! obj alist
-@deffnx {C Function} scm_set_object_properties_x (obj, alist)
-Set @var{obj}'s property list to @var{alist}.
-@end deffn
-
-object-property
-@c snarfed from objprop.c:57
-@deffn {Scheme Procedure} object-property obj key
-@deffnx {C Function} scm_object_property (obj, key)
-Return the property of @var{obj} with name @var{key}.
-@end deffn
-
-set-object-property!
-@c snarfed from objprop.c:69
-@deffn {Scheme Procedure} set-object-property! obj key value
-@deffnx {C Function} scm_set_object_property_x (obj, key, value)
-In @var{obj}'s property list, set the property named @var{key}
-to @var{value}.
-@end deffn
-
-cons
-@c snarfed from pairs.c:56
-@deffn {Scheme Procedure} cons x y
-@deffnx {C Function} scm_cons (x, y)
-Return a newly allocated pair whose car is @var{x} and whose
-cdr is @var{y}. The pair is guaranteed to be different (in the
-sense of @code{eq?}) from every previously existing object.
-@end deffn
-
-pair?
-@c snarfed from pairs.c:74
-@deffn {Scheme Procedure} pair? x
-@deffnx {C Function} scm_pair_p (x)
-Return @code{#t} if @var{x} is a pair; otherwise return
-@code{#f}.
-@end deffn
-
-set-car!
-@c snarfed from pairs.c:120
-@deffn {Scheme Procedure} set-car! pair value
-@deffnx {C Function} scm_set_car_x (pair, value)
-Stores @var{value} in the car field of @var{pair}. The value returned
-by @code{set-car!} is unspecified.
-@end deffn
-
-set-cdr!
-@c snarfed from pairs.c:133
-@deffn {Scheme Procedure} set-cdr! pair value
-@deffnx {C Function} scm_set_cdr_x (pair, value)
-Stores @var{value} in the cdr field of @var{pair}. The value returned
-by @code{set-cdr!} is unspecified.
-@end deffn
-
-char-ready?
-@c snarfed from ports.c:245
-@deffn {Scheme Procedure} char-ready? [port]
-@deffnx {C Function} scm_char_ready_p (port)
-Return @code{#t} if a character is ready on input @var{port}
-and return @code{#f} otherwise. If @code{char-ready?} returns
-@code{#t} then the next @code{read-char} operation on
-@var{port} is guaranteed not to hang. If @var{port} is a file
-port at end of file then @code{char-ready?} returns @code{#t}.
-
-@code{char-ready?} exists to make it possible for a
-program to accept characters from interactive ports without
-getting stuck waiting for input. Any input editors associated
-with such ports must make sure that characters whose existence
-has been asserted by @code{char-ready?} cannot be rubbed out.
-If @code{char-ready?} were to return @code{#f} at end of file,
-a port at end of file would be indistinguishable from an
-interactive port that has no ready characters.
-@end deffn
-
-drain-input
-@c snarfed from ports.c:322
-@deffn {Scheme Procedure} drain-input port
-@deffnx {C Function} scm_drain_input (port)
-This procedure clears a port's input buffers, similar
-to the way that force-output clears the output buffer. The
-contents of the buffers are returned as a single string, e.g.,
-
-@lisp
-(define p (open-input-file ...))
-(drain-input p) => empty string, nothing buffered yet.
-(unread-char (read-char p) p)
-(drain-input p) => initial chars from p, up to the buffer size.
-@end lisp
-
-Draining the buffers may be useful for cleanly finishing
-buffered I/O so that the file descriptor can be used directly
-for further input.
-@end deffn
-
-current-input-port
-@c snarfed from ports.c:355
-@deffn {Scheme Procedure} current-input-port
-@deffnx {C Function} scm_current_input_port ()
-Return the current input port. This is the default port used
-by many input procedures. Initially, @code{current-input-port}
-returns the @dfn{standard input} in Unix and C terminology.
-@end deffn
-
-current-output-port
-@c snarfed from ports.c:367
-@deffn {Scheme Procedure} current-output-port
-@deffnx {C Function} scm_current_output_port ()
-Return the current output port. This is the default port used
-by many output procedures. Initially,
-@code{current-output-port} returns the @dfn{standard output} in
-Unix and C terminology.
-@end deffn
-
-current-error-port
-@c snarfed from ports.c:377
-@deffn {Scheme Procedure} current-error-port
-@deffnx {C Function} scm_current_error_port ()
-Return the port to which errors and warnings should be sent (the
-@dfn{standard error} in Unix and C terminology).
-@end deffn
-
-current-load-port
-@c snarfed from ports.c:387
-@deffn {Scheme Procedure} current-load-port
-@deffnx {C Function} scm_current_load_port ()
-Return the current-load-port.
-The load port is used internally by @code{primitive-load}.
-@end deffn
-
-set-current-input-port
-@c snarfed from ports.c:400
-@deffn {Scheme Procedure} set-current-input-port port
-@deffnx {Scheme Procedure} set-current-output-port port
-@deffnx {Scheme Procedure} set-current-error-port port
-@deffnx {C Function} scm_set_current_input_port (port)
-Change the ports returned by @code{current-input-port},
-@code{current-output-port} and @code{current-error-port}, respectively,
-so that they use the supplied @var{port} for input or output.
-@end deffn
-
-set-current-output-port
-@c snarfed from ports.c:413
-@deffn {Scheme Procedure} set-current-output-port port
-@deffnx {C Function} scm_set_current_output_port (port)
-Set the current default output port to @var{port}.
-@end deffn
-
-set-current-error-port
-@c snarfed from ports.c:427
-@deffn {Scheme Procedure} set-current-error-port port
-@deffnx {C Function} scm_set_current_error_port (port)
-Set the current default error port to @var{port}.
-@end deffn
-
-port-revealed
-@c snarfed from ports.c:625
-@deffn {Scheme Procedure} port-revealed port
-@deffnx {C Function} scm_port_revealed (port)
-Return the revealed count for @var{port}.
-@end deffn
-
-set-port-revealed!
-@c snarfed from ports.c:638
-@deffn {Scheme Procedure} set-port-revealed! port rcount
-@deffnx {C Function} scm_set_port_revealed_x (port, rcount)
-Sets the revealed count for a port to a given value.
-The return value is unspecified.
-@end deffn
-
-port-mode
-@c snarfed from ports.c:699
-@deffn {Scheme Procedure} port-mode port
-@deffnx {C Function} scm_port_mode (port)
-Return the port modes associated with the open port @var{port}.
-These will not necessarily be identical to the modes used when
-the port was opened, since modes such as "append" which are
-used only during port creation are not retained.
-@end deffn
-
-close-port
-@c snarfed from ports.c:736
-@deffn {Scheme Procedure} close-port port
-@deffnx {C Function} scm_close_port (port)
-Close the specified port object. Return @code{#t} if it
-successfully closes a port or @code{#f} if it was already
-closed. An exception may be raised if an error occurs, for
-example when flushing buffered output. See also @ref{Ports and
-File Descriptors, close}, for a procedure which can close file
-descriptors.
-@end deffn
-
-close-input-port
-@c snarfed from ports.c:766
-@deffn {Scheme Procedure} close-input-port port
-@deffnx {C Function} scm_close_input_port (port)
-Close the specified input port object. The routine has no effect if
-the file has already been closed. An exception may be raised if an
-error occurs. The value returned is unspecified.
-
-See also @ref{Ports and File Descriptors, close}, for a procedure
-which can close file descriptors.
-@end deffn
-
-close-output-port
-@c snarfed from ports.c:781
-@deffn {Scheme Procedure} close-output-port port
-@deffnx {C Function} scm_close_output_port (port)
-Close the specified output port object. The routine has no effect if
-the file has already been closed. An exception may be raised if an
-error occurs. The value returned is unspecified.
-
-See also @ref{Ports and File Descriptors, close}, for a procedure
-which can close file descriptors.
-@end deffn
-
-port-for-each
-@c snarfed from ports.c:827
-@deffn {Scheme Procedure} port-for-each proc
-@deffnx {C Function} scm_port_for_each (proc)
-Apply @var{proc} to each port in the Guile port table
-in turn. The return value is unspecified. More specifically,
-@var{proc} is applied exactly once to every port that exists
-in the system at the time @var{port-for-each} is invoked.
-Changes to the port table while @var{port-for-each} is running
-have no effect as far as @var{port-for-each} is concerned.
-@end deffn
-
-input-port?
-@c snarfed from ports.c:845
-@deffn {Scheme Procedure} input-port? x
-@deffnx {C Function} scm_input_port_p (x)
-Return @code{#t} if @var{x} is an input port, otherwise return
-@code{#f}. Any object satisfying this predicate also satisfies
-@code{port?}.
-@end deffn
-
-output-port?
-@c snarfed from ports.c:856
-@deffn {Scheme Procedure} output-port? x
-@deffnx {C Function} scm_output_port_p (x)
-Return @code{#t} if @var{x} is an output port, otherwise return
-@code{#f}. Any object satisfying this predicate also satisfies
-@code{port?}.
-@end deffn
-
-port?
-@c snarfed from ports.c:868
-@deffn {Scheme Procedure} port? x
-@deffnx {C Function} scm_port_p (x)
-Return a boolean indicating whether @var{x} is a port.
-Equivalent to @code{(or (input-port? @var{x}) (output-port?
-@var{x}))}.
-@end deffn
-
-port-closed?
-@c snarfed from ports.c:878
-@deffn {Scheme Procedure} port-closed? port
-@deffnx {C Function} scm_port_closed_p (port)
-Return @code{#t} if @var{port} is closed or @code{#f} if it is
-open.
-@end deffn
-
-eof-object?
-@c snarfed from ports.c:889
-@deffn {Scheme Procedure} eof-object? x
-@deffnx {C Function} scm_eof_object_p (x)
-Return @code{#t} if @var{x} is an end-of-file object; otherwise
-return @code{#f}.
-@end deffn
-
-force-output
-@c snarfed from ports.c:903
-@deffn {Scheme Procedure} force-output [port]
-@deffnx {C Function} scm_force_output (port)
-Flush the specified output port, or the current output port if @var{port}
-is omitted. The current output buffer contents are passed to the
-underlying port implementation (e.g., in the case of fports, the
-data will be written to the file and the output buffer will be cleared.)
-It has no effect on an unbuffered port.
-
-The return value is unspecified.
-@end deffn
-
-flush-all-ports
-@c snarfed from ports.c:921
-@deffn {Scheme Procedure} flush-all-ports
-@deffnx {C Function} scm_flush_all_ports ()
-Equivalent to calling @code{force-output} on
-all open output ports. The return value is unspecified.
-@end deffn
-
-read-char
-@c snarfed from ports.c:941
-@deffn {Scheme Procedure} read-char [port]
-@deffnx {C Function} scm_read_char (port)
-Return the next character available from @var{port}, updating
-@var{port} to point to the following character. If no more
-characters are available, the end-of-file object is returned.
-@end deffn
-
-peek-char
-@c snarfed from ports.c:1283
-@deffn {Scheme Procedure} peek-char [port]
-@deffnx {C Function} scm_peek_char (port)
-Return the next character available from @var{port},
-@emph{without} updating @var{port} to point to the following
-character. If no more characters are available, the
-end-of-file object is returned.
-
-The value returned by
-a call to @code{peek-char} is the same as the value that would
-have been returned by a call to @code{read-char} on the same
-port. The only difference is that the very next call to
-@code{read-char} or @code{peek-char} on that @var{port} will
-return the value returned by the preceding call to
-@code{peek-char}. In particular, a call to @code{peek-char} on
-an interactive port will hang waiting for input whenever a call
-to @code{read-char} would have hung.
-@end deffn
-
-unread-char
-@c snarfed from ports.c:1306
-@deffn {Scheme Procedure} unread-char cobj [port]
-@deffnx {C Function} scm_unread_char (cobj, port)
-Place @var{char} in @var{port} so that it will be read by the
-next read operation. If called multiple times, the unread characters
-will be read again in last-in first-out order. If @var{port} is
-not supplied, the current input port is used.
-@end deffn
-
-unread-string
-@c snarfed from ports.c:1329
-@deffn {Scheme Procedure} unread-string str port
-@deffnx {C Function} scm_unread_string (str, port)
-Place the string @var{str} in @var{port} so that its characters will be
-read in subsequent read operations. If called multiple times, the
-unread characters will be read again in last-in first-out order. If
-@var{port} is not supplied, the current-input-port is used.
-@end deffn
-
-seek
-@c snarfed from ports.c:1368
-@deffn {Scheme Procedure} seek fd_port offset whence
-@deffnx {C Function} scm_seek (fd_port, offset, whence)
-Sets the current position of @var{fd/port} to the integer
-@var{offset}, which is interpreted according to the value of
-@var{whence}.
-
-One of the following variables should be supplied for
-@var{whence}:
-@defvar SEEK_SET
-Seek from the beginning of the file.
-@end defvar
-@defvar SEEK_CUR
-Seek from the current position.
-@end defvar
-@defvar SEEK_END
-Seek from the end of the file.
-@end defvar
-If @var{fd/port} is a file descriptor, the underlying system
-call is @code{lseek}. @var{port} may be a string port.
-
-The value returned is the new position in the file. This means
-that the current position of a port can be obtained using:
-@lisp
-(seek port 0 SEEK_CUR)
-@end lisp
-@end deffn
-
-truncate-file
-@c snarfed from ports.c:1426
-@deffn {Scheme Procedure} truncate-file object [length]
-@deffnx {C Function} scm_truncate_file (object, length)
-Truncates the object referred to by @var{object} to at most
-@var{length} bytes. @var{object} can be a string containing a
-file name or an integer file descriptor or a port.
-@var{length} may be omitted if @var{object} is not a file name,
-in which case the truncation occurs at the current port
-position. The return value is unspecified.
-@end deffn
-
-port-line
-@c snarfed from ports.c:1486
-@deffn {Scheme Procedure} port-line port
-@deffnx {C Function} scm_port_line (port)
-Return the current line number for @var{port}.
-
-The first line of a file is 0. But you might want to add 1
-when printing line numbers, since starting from 1 is
-traditional in error messages, and likely to be more natural to
-non-programmers.
-@end deffn
-
-set-port-line!
-@c snarfed from ports.c:1498
-@deffn {Scheme Procedure} set-port-line! port line
-@deffnx {C Function} scm_set_port_line_x (port, line)
-Set the current line number for @var{port} to @var{line}. The
-first line of a file is 0.
-@end deffn
-
-port-column
-@c snarfed from ports.c:1517
-@deffn {Scheme Procedure} port-column port
-@deffnx {C Function} scm_port_column (port)
-Return the current column number of @var{port}.
-If the number is
-unknown, the result is #f. Otherwise, the result is a 0-origin integer
-- i.e. the first character of the first line is line 0, column 0.
-(However, when you display a file position, for example in an error
-message, we recommend you add 1 to get 1-origin integers. This is
-because lines and column numbers traditionally start with 1, and that is
-what non-programmers will find most natural.)
-@end deffn
-
-set-port-column!
-@c snarfed from ports.c:1529
-@deffn {Scheme Procedure} set-port-column! port column
-@deffnx {C Function} scm_set_port_column_x (port, column)
-Set the current column of @var{port}. Before reading the first
-character on a line the column should be 0.
-@end deffn
-
-port-filename
-@c snarfed from ports.c:1543
-@deffn {Scheme Procedure} port-filename port
-@deffnx {C Function} scm_port_filename (port)
-Return the filename associated with @var{port}. This function returns
-the strings "standard input", "standard output" and "standard error"
-when called on the current input, output and error ports respectively.
-@end deffn
-
-set-port-filename!
-@c snarfed from ports.c:1557
-@deffn {Scheme Procedure} set-port-filename! port filename
-@deffnx {C Function} scm_set_port_filename_x (port, filename)
-Change the filename associated with @var{port}, using the current input
-port if none is specified. Note that this does not change the port's
-source of data, but only the value that is returned by
-@code{port-filename} and reported in diagnostic output.
-@end deffn
-
-%make-void-port
-@c snarfed from ports.c:1651
-@deffn {Scheme Procedure} %make-void-port mode
-@deffnx {C Function} scm_sys_make_void_port (mode)
-Create and return a new void port. A void port acts like
-@file{/dev/null}. The @var{mode} argument
-specifies the input/output modes for this port: see the
-documentation for @code{open-file} in @ref{File Ports}.
-@end deffn
-
-print-options-interface
-@c snarfed from print.c:87
-@deffn {Scheme Procedure} print-options-interface [setting]
-@deffnx {C Function} scm_print_options (setting)
-Option interface for the print options. Instead of using
-this procedure directly, use the procedures
-@code{print-enable}, @code{print-disable}, @code{print-set!}
-and @code{print-options}.
-@end deffn
-
-simple-format
-@c snarfed from print.c:929
-@deffn {Scheme Procedure} simple-format destination message . args
-@deffnx {C Function} scm_simple_format (destination, message, args)
-Write @var{message} to @var{destination}, defaulting to
-the current output port.
-@var{message} can contain @code{~A} (was @code{%s}) and
-@code{~S} (was @code{%S}) escapes. When printed,
-the escapes are replaced with corresponding members of
-@var{ARGS}:
-@code{~A} formats using @code{display} and @code{~S} formats
-using @code{write}.
-If @var{destination} is @code{#t}, then use the current output
-port, if @var{destination} is @code{#f}, then return a string
-containing the formatted text. Does not add a trailing newline.
-@end deffn
-
-newline
-@c snarfed from print.c:1019
-@deffn {Scheme Procedure} newline [port]
-@deffnx {C Function} scm_newline (port)
-Send a newline to @var{port}.
-If @var{port} is omitted, send to the current output port.
-@end deffn
-
-write-char
-@c snarfed from print.c:1034
-@deffn {Scheme Procedure} write-char chr [port]
-@deffnx {C Function} scm_write_char (chr, port)
-Send character @var{chr} to @var{port}.
-@end deffn
-
-port-with-print-state
-@c snarfed from print.c:1088
-@deffn {Scheme Procedure} port-with-print-state port [pstate]
-@deffnx {C Function} scm_port_with_print_state (port, pstate)
-Create a new port which behaves like @var{port}, but with an
-included print state @var{pstate}. @var{pstate} is optional.
-If @var{pstate} isn't supplied and @var{port} already has
-a print state, the old print state is reused.
-@end deffn
-
-get-print-state
-@c snarfed from print.c:1101
-@deffn {Scheme Procedure} get-print-state port
-@deffnx {C Function} scm_get_print_state (port)
-Return the print state of the port @var{port}. If @var{port}
-has no associated print state, @code{#f} is returned.
-@end deffn
-
-procedure-properties
-@c snarfed from procprop.c:160
-@deffn {Scheme Procedure} procedure-properties proc
-@deffnx {C Function} scm_procedure_properties (proc)
-Return @var{obj}'s property list.
-@end deffn
-
-set-procedure-properties!
-@c snarfed from procprop.c:173
-@deffn {Scheme Procedure} set-procedure-properties! proc new_val
-@deffnx {C Function} scm_set_procedure_properties_x (proc, new_val)
-Set @var{obj}'s property list to @var{alist}.
-@end deffn
-
-procedure-property
-@c snarfed from procprop.c:186
-@deffn {Scheme Procedure} procedure-property p k
-@deffnx {C Function} scm_procedure_property (p, k)
-Return the property of @var{obj} with name @var{key}.
-@end deffn
-
-set-procedure-property!
-@c snarfed from procprop.c:209
-@deffn {Scheme Procedure} set-procedure-property! p k v
-@deffnx {C Function} scm_set_procedure_property_x (p, k, v)
-In @var{obj}'s property list, set the property named @var{key} to
-@var{value}.
-@end deffn
-
-procedure?
-@c snarfed from procs.c:162
-@deffn {Scheme Procedure} procedure? obj
-@deffnx {C Function} scm_procedure_p (obj)
-Return @code{#t} if @var{obj} is a procedure.
-@end deffn
-
-closure?
-@c snarfed from procs.c:189
-@deffn {Scheme Procedure} closure? obj
-@deffnx {C Function} scm_closure_p (obj)
-Return @code{#t} if @var{obj} is a closure.
-@end deffn
-
-thunk?
-@c snarfed from procs.c:198
-@deffn {Scheme Procedure} thunk? obj
-@deffnx {C Function} scm_thunk_p (obj)
-Return @code{#t} if @var{obj} is a thunk.
-@end deffn
-
-procedure-documentation
-@c snarfed from procs.c:248
-@deffn {Scheme Procedure} procedure-documentation proc
-@deffnx {C Function} scm_procedure_documentation (proc)
-Return the documentation string associated with @code{proc}. By
-convention, if a procedure contains more than one expression and the
-first expression is a string constant, that string is assumed to contain
-documentation for that procedure.
-@end deffn
-
-procedure-with-setter?
-@c snarfed from procs.c:284
-@deffn {Scheme Procedure} procedure-with-setter? obj
-@deffnx {C Function} scm_procedure_with_setter_p (obj)
-Return @code{#t} if @var{obj} is a procedure with an
-associated setter procedure.
-@end deffn
-
-make-procedure-with-setter
-@c snarfed from procs.c:294
-@deffn {Scheme Procedure} make-procedure-with-setter procedure setter
-@deffnx {C Function} scm_make_procedure_with_setter (procedure, setter)
-Create a new procedure which behaves like @var{procedure}, but
-with the associated setter @var{setter}.
-@end deffn
-
-procedure
-@c snarfed from procs.c:308
-@deffn {Scheme Procedure} procedure proc
-@deffnx {C Function} scm_procedure (proc)
-Return the procedure of @var{proc}, which must be an
-applicable struct.
-@end deffn
-
-primitive-make-property
-@c snarfed from properties.c:40
-@deffn {Scheme Procedure} primitive-make-property not_found_proc
-@deffnx {C Function} scm_primitive_make_property (not_found_proc)
-Create a @dfn{property token} that can be used with
-@code{primitive-property-ref} and @code{primitive-property-set!}.
-See @code{primitive-property-ref} for the significance of
-@var{not_found_proc}.
-@end deffn
-
-primitive-property-ref
-@c snarfed from properties.c:59
-@deffn {Scheme Procedure} primitive-property-ref prop obj
-@deffnx {C Function} scm_primitive_property_ref (prop, obj)
-Return the property @var{prop} of @var{obj}.
-
-When no value has yet been associated with @var{prop} and
-@var{obj}, the @var{not-found-proc} from @var{prop} is used. A
-call @code{(@var{not-found-proc} @var{prop} @var{obj})} is made
-and the result set as the property value. If
-@var{not-found-proc} is @code{#f} then @code{#f} is the
-property value.
-@end deffn
-
-primitive-property-set!
-@c snarfed from properties.c:90
-@deffn {Scheme Procedure} primitive-property-set! prop obj val
-@deffnx {C Function} scm_primitive_property_set_x (prop, obj, val)
-Set the property @var{prop} of @var{obj} to @var{val}.
-@end deffn
-
-primitive-property-del!
-@c snarfed from properties.c:111
-@deffn {Scheme Procedure} primitive-property-del! prop obj
-@deffnx {C Function} scm_primitive_property_del_x (prop, obj)
-Remove any value associated with @var{prop} and @var{obj}.
-@end deffn
-
-random
-@c snarfed from random.c:347
-@deffn {Scheme Procedure} random n [state]
-@deffnx {C Function} scm_random (n, state)
-Return a number in [0, N).
-
-Accepts a positive integer or real n and returns a
-number of the same type between zero (inclusive) and
-N (exclusive). The values returned have a uniform
-distribution.
-
-The optional argument @var{state} must be of the type produced
-by @code{seed->random-state}. It defaults to the value of the
-variable @var{*random-state*}. This object is used to maintain
-the state of the pseudo-random-number generator and is altered
-as a side effect of the random operation.
-@end deffn
-
-copy-random-state
-@c snarfed from random.c:372
-@deffn {Scheme Procedure} copy-random-state [state]
-@deffnx {C Function} scm_copy_random_state (state)
-Return a copy of the random state @var{state}.
-@end deffn
-
-seed->random-state
-@c snarfed from random.c:384
-@deffn {Scheme Procedure} seed->random-state seed
-@deffnx {C Function} scm_seed_to_random_state (seed)
-Return a new random state using @var{seed}.
-@end deffn
-
-random:uniform
-@c snarfed from random.c:402
-@deffn {Scheme Procedure} random:uniform [state]
-@deffnx {C Function} scm_random_uniform (state)
-Return a uniformly distributed inexact real random number in
-[0,1).
-@end deffn
-
-random:normal
-@c snarfed from random.c:417
-@deffn {Scheme Procedure} random:normal [state]
-@deffnx {C Function} scm_random_normal (state)
-Return an inexact real in a normal distribution. The
-distribution used has mean 0 and standard deviation 1. For a
-normal distribution with mean m and standard deviation d use
-@code{(+ m (* d (random:normal)))}.
-@end deffn
-
-random:solid-sphere!
-@c snarfed from random.c:500
-@deffn {Scheme Procedure} random:solid-sphere! v [state]
-@deffnx {C Function} scm_random_solid_sphere_x (v, state)
-Fills @var{vect} with inexact real random numbers the sum of
-whose squares is less than 1.0. Thinking of @var{vect} as
-coordinates in space of dimension @var{n} @math{=}
-@code{(vector-length @var{vect})}, the coordinates are
-uniformly distributed within the unit @var{n}-sphere.
-@end deffn
-
-random:hollow-sphere!
-@c snarfed from random.c:522
-@deffn {Scheme Procedure} random:hollow-sphere! v [state]
-@deffnx {C Function} scm_random_hollow_sphere_x (v, state)
-Fills vect with inexact real random numbers
-the sum of whose squares is equal to 1.0.
-Thinking of vect as coordinates in space of
-dimension n = (vector-length vect), the coordinates
-are uniformly distributed over the surface of the
-unit n-sphere.
-@end deffn
-
-random:normal-vector!
-@c snarfed from random.c:539
-@deffn {Scheme Procedure} random:normal-vector! v [state]
-@deffnx {C Function} scm_random_normal_vector_x (v, state)
-Fills vect with inexact real random numbers that are
-independent and standard normally distributed
-(i.e., with mean 0 and variance 1).
-@end deffn
-
-random:exp
-@c snarfed from random.c:577
-@deffn {Scheme Procedure} random:exp [state]
-@deffnx {C Function} scm_random_exp (state)
-Return an inexact real in an exponential distribution with mean
-1. For an exponential distribution with mean u use (* u
-(random:exp)).
-@end deffn
-
-%read-delimited!
-@c snarfed from rdelim.c:55
-@deffn {Scheme Procedure} %read-delimited! delims str gobble [port [start [end]]]
-@deffnx {C Function} scm_read_delimited_x (delims, str, gobble, port, start, end)
-Read characters from @var{port} into @var{str} until one of the
-characters in the @var{delims} string is encountered. If
-@var{gobble} is true, discard the delimiter character;
-otherwise, leave it in the input stream for the next read. If
-@var{port} is not specified, use the value of
-@code{(current-input-port)}. If @var{start} or @var{end} are
-specified, store data only into the substring of @var{str}
-bounded by @var{start} and @var{end} (which default to the
-beginning and end of the string, respectively).
-
- Return a pair consisting of the delimiter that terminated the
-string and the number of characters read. If reading stopped
-at the end of file, the delimiter returned is the
-@var{eof-object}; if the string was filled without encountering
-a delimiter, this value is @code{#f}.
-@end deffn
-
-%read-line
-@c snarfed from rdelim.c:202
-@deffn {Scheme Procedure} %read-line [port]
-@deffnx {C Function} scm_read_line (port)
-Read a newline-terminated line from @var{port}, allocating storage as
-necessary. The newline terminator (if any) is removed from the string,
-and a pair consisting of the line and its delimiter is returned. The
-delimiter may be either a newline or the @var{eof-object}; if
-@code{%read-line} is called at the end of file, it returns the pair
-@code{(# . #)}.
-@end deffn
-
-write-line
-@c snarfed from rdelim.c:255
-@deffn {Scheme Procedure} write-line obj [port]
-@deffnx {C Function} scm_write_line (obj, port)
-Display @var{obj} and a newline character to @var{port}. If
-@var{port} is not specified, @code{(current-output-port)} is
-used. This function is equivalent to:
-@lisp
-(display obj [port])
-(newline [port])
-@end lisp
-@end deffn
-
-read-options-interface
-@c snarfed from read.c:110
-@deffn {Scheme Procedure} read-options-interface [setting]
-@deffnx {C Function} scm_read_options (setting)
-Option interface for the read options. Instead of using
-this procedure directly, use the procedures @code{read-enable},
-@code{read-disable}, @code{read-set!} and @code{read-options}.
-@end deffn
-
-read
-@c snarfed from read.c:130
-@deffn {Scheme Procedure} read [port]
-@deffnx {C Function} scm_read (port)
-Read an s-expression from the input port @var{port}, or from
-the current input port if @var{port} is not specified.
-Any whitespace before the next token is discarded.
-@end deffn
-
-read-hash-extend
-@c snarfed from read.c:898
-@deffn {Scheme Procedure} read-hash-extend chr proc
-@deffnx {C Function} scm_read_hash_extend (chr, proc)
-Install the procedure @var{proc} for reading expressions
-starting with the character sequence @code{#} and @var{chr}.
-@var{proc} will be called with two arguments: the character
-@var{chr} and the port to read further data from. The object
-returned will be the return value of @code{read}.
-Passing @code{#f} for @var{proc} will remove a previous setting.
-
-@end deffn
-
-call-with-dynamic-root
-@c snarfed from root.c:160
-@deffn {Scheme Procedure} call-with-dynamic-root thunk handler
-@deffnx {C Function} scm_call_with_dynamic_root (thunk, handler)
-Call @var{thunk} with a new dynamic state and withina continuation barrier. The @var{handler} catches allotherwise uncaught throws and executes within the samedynamic context as @var{thunk}.
-@end deffn
-
-dynamic-root
-@c snarfed from root.c:171
-@deffn {Scheme Procedure} dynamic-root
-@deffnx {C Function} scm_dynamic_root ()
-Return an object representing the current dynamic root.
-
-These objects are only useful for comparison using @code{eq?}.
-
-@end deffn
-
-read-string!/partial
-@c snarfed from rw.c:101
-@deffn {Scheme Procedure} read-string!/partial str [port_or_fdes [start [end]]]
-@deffnx {C Function} scm_read_string_x_partial (str, port_or_fdes, start, end)
-Read characters from a port or file descriptor into a
-string @var{str}. A port must have an underlying file
-descriptor --- a so-called fport. This procedure is
-scsh-compatible and can efficiently read large strings.
-It will:
-
-@itemize
-@item
-attempt to fill the entire string, unless the @var{start}
-and/or @var{end} arguments are supplied. i.e., @var{start}
-defaults to 0 and @var{end} defaults to
-@code{(string-length str)}
-@item
-use the current input port if @var{port_or_fdes} is not
-supplied.
-@item
-return fewer than the requested number of characters in some
-cases, e.g., on end of file, if interrupted by a signal, or if
-not all the characters are immediately available.
-@item
-wait indefinitely for some input if no characters are
-currently available,
-unless the port is in non-blocking mode.
-@item
-read characters from the port's input buffers if available,
-instead from the underlying file descriptor.
-@item
-return @code{#f} if end-of-file is encountered before reading
-any characters, otherwise return the number of characters
-read.
-@item
-return 0 if the port is in non-blocking mode and no characters
-are immediately available.
-@item
-return 0 if the request is for 0 bytes, with no
-end-of-file check.
-@end itemize
-@end deffn
-
-write-string/partial
-@c snarfed from rw.c:205
-@deffn {Scheme Procedure} write-string/partial str [port_or_fdes [start [end]]]
-@deffnx {C Function} scm_write_string_partial (str, port_or_fdes, start, end)
-Write characters from a string @var{str} to a port or file
-descriptor. A port must have an underlying file descriptor
---- a so-called fport. This procedure is
-scsh-compatible and can efficiently write large strings.
-It will:
-
-@itemize
-@item
-attempt to write the entire string, unless the @var{start}
-and/or @var{end} arguments are supplied. i.e., @var{start}
-defaults to 0 and @var{end} defaults to
-@code{(string-length str)}
-@item
-use the current output port if @var{port_of_fdes} is not
-supplied.
-@item
-in the case of a buffered port, store the characters in the
-port's output buffer, if all will fit. If they will not fit
-then any existing buffered characters will be flushed
-before attempting
-to write the new characters directly to the underlying file
-descriptor. If the port is in non-blocking mode and
-buffered characters can not be flushed immediately, then an
-@code{EAGAIN} system-error exception will be raised (Note:
-scsh does not support the use of non-blocking buffered ports.)
-@item
-write fewer than the requested number of
-characters in some cases, e.g., if interrupted by a signal or
-if not all of the output can be accepted immediately.
-@item
-wait indefinitely for at least one character
-from @var{str} to be accepted by the port, unless the port is
-in non-blocking mode.
-@item
-return the number of characters accepted by the port.
-@item
-return 0 if the port is in non-blocking mode and can not accept
-at least one character from @var{str} immediately
-@item
-return 0 immediately if the request size is 0 bytes.
-@end itemize
-@end deffn
-
-sigaction
-@c snarfed from scmsigs.c:253
-@deffn {Scheme Procedure} sigaction signum [handler [flags [thread]]]
-@deffnx {C Function} scm_sigaction_for_thread (signum, handler, flags, thread)
-Install or report the signal handler for a specified signal.
-
-@var{signum} is the signal number, which can be specified using the value
-of variables such as @code{SIGINT}.
-
-If @var{handler} is omitted, @code{sigaction} returns a pair: the
-CAR is the current
-signal hander, which will be either an integer with the value @code{SIG_DFL}
-(default action) or @code{SIG_IGN} (ignore), or the Scheme procedure which
-handles the signal, or @code{#f} if a non-Scheme procedure handles the
-signal. The CDR contains the current @code{sigaction} flags for the handler.
-
-If @var{handler} is provided, it is installed as the new handler for
-@var{signum}. @var{handler} can be a Scheme procedure taking one
-argument, or the value of @code{SIG_DFL} (default action) or
-@code{SIG_IGN} (ignore), or @code{#f} to restore whatever signal handler
-was installed before @code{sigaction} was first used. When
-a scheme procedure has been specified, that procedure will run
-in the given @var{thread}. When no thread has been given, the
-thread that made this call to @code{sigaction} is used.
-Flags can optionally be specified for the new handler (@code{SA_RESTART} will
-always be added if it's available and the system is using restartable
-system calls.) The return value is a pair with information about the
-old handler as described above.
-
-This interface does not provide access to the "signal blocking"
-facility. Maybe this is not needed, since the thread support may
-provide solutions to the problem of consistent access to data
-structures.
-@end deffn
-
-restore-signals
-@c snarfed from scmsigs.c:427
-@deffn {Scheme Procedure} restore-signals
-@deffnx {C Function} scm_restore_signals ()
-Return all signal handlers to the values they had before any call to
-@code{sigaction} was made. The return value is unspecified.
-@end deffn
-
-alarm
-@c snarfed from scmsigs.c:464
-@deffn {Scheme Procedure} alarm i
-@deffnx {C Function} scm_alarm (i)
-Set a timer to raise a @code{SIGALRM} signal after the specified
-number of seconds (an integer). It's advisable to install a signal
-handler for
-@code{SIGALRM} beforehand, since the default action is to terminate
-the process.
-
-The return value indicates the time remaining for the previous alarm,
-if any. The new value replaces the previous alarm. If there was
-no previous alarm, the return value is zero.
-@end deffn
-
-setitimer
-@c snarfed from scmsigs.c:491
-@deffn {Scheme Procedure} setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds
-@deffnx {C Function} scm_setitimer (which_timer, interval_seconds, interval_microseconds, value_seconds, value_microseconds)
-Set the timer specified by @var{which_timer} according to the given
-@var{interval_seconds}, @var{interval_microseconds},
-@var{value_seconds}, and @var{value_microseconds} values.
-
-Return information about the timer's previous setting.
-Errors are handled as described in the guile info pages under ``POSIX
-Interface Conventions''.
-
-The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL},
-and @code{ITIMER_PROF}.
-
-The return value will be a list of two cons pairs representing the
-current state of the given timer. The first pair is the seconds and
-microseconds of the timer @code{it_interval}, and the second pair is
-the seconds and microseconds of the timer @code{it_value}.
-@end deffn
-
-getitimer
-@c snarfed from scmsigs.c:532
-@deffn {Scheme Procedure} getitimer which_timer
-@deffnx {C Function} scm_getitimer (which_timer)
-Return information about the timer specified by @var{which_timer}
-Errors are handled as described in the guile info pages under ``POSIX
-Interface Conventions''.
-
-The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL},
-and @code{ITIMER_PROF}.
-
-The return value will be a list of two cons pairs representing the
-current state of the given timer. The first pair is the seconds and
-microseconds of the timer @code{it_interval}, and the second pair is
-the seconds and microseconds of the timer @code{it_value}.
-@end deffn
-
-pause
-@c snarfed from scmsigs.c:559
-@deffn {Scheme Procedure} pause
-@deffnx {C Function} scm_pause ()
-Pause the current process (thread?) until a signal arrives whose
-action is to either terminate the current process or invoke a
-handler procedure. The return value is unspecified.
-@end deffn
-
-sleep
-@c snarfed from scmsigs.c:572
-@deffn {Scheme Procedure} sleep i
-@deffnx {C Function} scm_sleep (i)
-Wait for the given number of seconds (an integer) or until a signal
-arrives. The return value is zero if the time elapses or the number
-of seconds remaining otherwise.
-@end deffn
-
-usleep
-@c snarfed from scmsigs.c:581
-@deffn {Scheme Procedure} usleep i
-@deffnx {C Function} scm_usleep (i)
-Sleep for @var{i} microseconds.
-@end deffn
-
-raise
-@c snarfed from scmsigs.c:591
-@deffn {Scheme Procedure} raise sig
-@deffnx {C Function} scm_raise (sig)
-Sends a specified signal @var{sig} to the current process, where
-@var{sig} is as described for the kill procedure.
-@end deffn
-
-system
-@c snarfed from simpos.c:64
-@deffn {Scheme Procedure} system [cmd]
-@deffnx {C Function} scm_system (cmd)
-Execute @var{cmd} using the operating system's "command
-processor". Under Unix this is usually the default shell
-@code{sh}. The value returned is @var{cmd}'s exit status as
-returned by @code{waitpid}, which can be interpreted using
-@code{status:exit-val} and friends.
-
-If @code{system} is called without arguments, return a boolean
-indicating whether the command processor is available.
-@end deffn
-
-system*
-@c snarfed from simpos.c:114
-@deffn {Scheme Procedure} system* . args
-@deffnx {C Function} scm_system_star (args)
-Execute the command indicated by @var{args}. The first element must
-be a string indicating the command to be executed, and the remaining
-items must be strings representing each of the arguments to that
-command.
-
-This function returns the exit status of the command as provided by
-@code{waitpid}. This value can be handled with @code{status:exit-val}
-and the related functions.
-
-@code{system*} is similar to @code{system}, but accepts only one
-string per-argument, and performs no shell interpretation. The
-command is executed using fork and execlp. Accordingly this function
-may be safer than @code{system} in situations where shell
-interpretation is not required.
-
-Example: (system* "echo" "foo" "bar")
-@end deffn
-
-getenv
-@c snarfed from simpos.c:184
-@deffn {Scheme Procedure} getenv nam
-@deffnx {C Function} scm_getenv (nam)
-Looks up the string @var{name} in the current environment. The return
-value is @code{#f} unless a string of the form @code{NAME=VALUE} is
-found, in which case the string @code{VALUE} is returned.
-@end deffn
-
-primitive-exit
-@c snarfed from simpos.c:200
-@deffn {Scheme Procedure} primitive-exit [status]
-@deffnx {C Function} scm_primitive_exit (status)
-Terminate the current process without unwinding the Scheme stack.
-This is would typically be useful after a fork. The exit status
-is @var{status} if supplied, otherwise zero.
-@end deffn
-
-restricted-vector-sort!
-@c snarfed from sort.c:78
-@deffn {Scheme Procedure} restricted-vector-sort! vec less startpos endpos
-@deffnx {C Function} scm_restricted_vector_sort_x (vec, less, startpos, endpos)
-Sort the vector @var{vec}, using @var{less} for comparing
-the vector elements. @var{startpos} (inclusively) and
-@var{endpos} (exclusively) delimit
-the range of the vector which gets sorted. The return value
-is not specified.
-@end deffn
-
-sorted?
-@c snarfed from sort.c:111
-@deffn {Scheme Procedure} sorted? items less
-@deffnx {C Function} scm_sorted_p (items, less)
-Return @code{#t} iff @var{items} is a list or a vector such that
-for all 1 <= i <= m, the predicate @var{less} returns true when
-applied to all elements i - 1 and i
-@end deffn
-
-merge
-@c snarfed from sort.c:186
-@deffn {Scheme Procedure} merge alist blist less
-@deffnx {C Function} scm_merge (alist, blist, less)
-Merge two already sorted lists into one.
-Given two lists @var{alist} and @var{blist}, such that
-@code{(sorted? alist less?)} and @code{(sorted? blist less?)},
-return a new list in which the elements of @var{alist} and
-@var{blist} have been stably interleaved so that
-@code{(sorted? (merge alist blist less?) less?)}.
-Note: this does _not_ accept vectors.
-@end deffn
-
-merge!
-@c snarfed from sort.c:303
-@deffn {Scheme Procedure} merge! alist blist less
-@deffnx {C Function} scm_merge_x (alist, blist, less)
-Takes two lists @var{alist} and @var{blist} such that
-@code{(sorted? alist less?)} and @code{(sorted? blist less?)} and
-returns a new list in which the elements of @var{alist} and
-@var{blist} have been stably interleaved so that
- @code{(sorted? (merge alist blist less?) less?)}.
-This is the destructive variant of @code{merge}
-Note: this does _not_ accept vectors.
-@end deffn
-
-sort!
-@c snarfed from sort.c:373
-@deffn {Scheme Procedure} sort! items less
-@deffnx {C Function} scm_sort_x (items, less)
-Sort the sequence @var{items}, which may be a list or a
-vector. @var{less} is used for comparing the sequence
-elements. The sorting is destructive, that means that the
-input sequence is modified to produce the sorted result.
-This is not a stable sort.
-@end deffn
-
-sort
-@c snarfed from sort.c:404
-@deffn {Scheme Procedure} sort items less
-@deffnx {C Function} scm_sort (items, less)
-Sort the sequence @var{items}, which may be a list or a
-vector. @var{less} is used for comparing the sequence
-elements. This is not a stable sort.
-@end deffn
-
-stable-sort!
-@c snarfed from sort.c:487
-@deffn {Scheme Procedure} stable-sort! items less
-@deffnx {C Function} scm_stable_sort_x (items, less)
-Sort the sequence @var{items}, which may be a list or a
-vector. @var{less} is used for comparing the sequence elements.
-The sorting is destructive, that means that the input sequence
-is modified to produce the sorted result.
-This is a stable sort.
-@end deffn
-
-stable-sort
-@c snarfed from sort.c:531
-@deffn {Scheme Procedure} stable-sort items less
-@deffnx {C Function} scm_stable_sort (items, less)
-Sort the sequence @var{items}, which may be a list or a
-vector. @var{less} is used for comparing the sequence elements.
-This is a stable sort.
-@end deffn
-
-sort-list!
-@c snarfed from sort.c:549
-@deffn {Scheme Procedure} sort-list! items less
-@deffnx {C Function} scm_sort_list_x (items, less)
-Sort the list @var{items}, using @var{less} for comparing the
-list elements. The sorting is destructive, that means that the
-input list is modified to produce the sorted result.
-This is a stable sort.
-@end deffn
-
-sort-list
-@c snarfed from sort.c:564
-@deffn {Scheme Procedure} sort-list items less
-@deffnx {C Function} scm_sort_list (items, less)
-Sort the list @var{items}, using @var{less} for comparing the
-list elements. This is a stable sort.
-@end deffn
-
-source-properties
-@c snarfed from srcprop.c:153
-@deffn {Scheme Procedure} source-properties obj
-@deffnx {C Function} scm_source_properties (obj)
-Return the source property association list of @var{obj}.
-@end deffn
-
-set-source-properties!
-@c snarfed from srcprop.c:176
-@deffn {Scheme Procedure} set-source-properties! obj plist
-@deffnx {C Function} scm_set_source_properties_x (obj, plist)
-Install the association list @var{plist} as the source property
-list for @var{obj}.
-@end deffn
-
-source-property
-@c snarfed from srcprop.c:194
-@deffn {Scheme Procedure} source-property obj key
-@deffnx {C Function} scm_source_property (obj, key)
-Return the source property specified by @var{key} from
-@var{obj}'s source property list.
-@end deffn
-
-set-source-property!
-@c snarfed from srcprop.c:225
-@deffn {Scheme Procedure} set-source-property! obj key datum
-@deffnx {C Function} scm_set_source_property_x (obj, key, datum)
-Set the source property of object @var{obj}, which is specified by
-@var{key} to @var{datum}. Normally, the key will be a symbol.
-@end deffn
-
-stack?
-@c snarfed from stacks.c:391
-@deffn {Scheme Procedure} stack? obj
-@deffnx {C Function} scm_stack_p (obj)
-Return @code{#t} if @var{obj} is a calling stack.
-@end deffn
-
-make-stack
-@c snarfed from stacks.c:422
-@deffn {Scheme Procedure} make-stack obj . args
-@deffnx {C Function} scm_make_stack (obj, args)
-Create a new stack. If @var{obj} is @code{#t}, the current
-evaluation stack is used for creating the stack frames,
-otherwise the frames are taken from @var{obj} (which must be
-either a debug object or a continuation).
-
-@var{args} should be a list containing any combination of
-integer, procedure and @code{#t} values.
-
-These values specify various ways of cutting away uninteresting
-stack frames from the top and bottom of the stack that
-@code{make-stack} returns. They come in pairs like this:
-@code{(@var{inner_cut_1} @var{outer_cut_1} @var{inner_cut_2}
-@var{outer_cut_2} @dots{})}.
-
-Each @var{inner_cut_N} can be @code{#t}, an integer, or a
-procedure. @code{#t} means to cut away all frames up to but
-excluding the first user module frame. An integer means to cut
-away exactly that number of frames. A procedure means to cut
-away all frames up to but excluding the application frame whose
-procedure matches the specified one.
-
-Each @var{outer_cut_N} can be an integer or a procedure. An
-integer means to cut away that number of frames. A procedure
-means to cut away frames down to but excluding the application
-frame whose procedure matches the specified one.
-
-If the @var{outer_cut_N} of the last pair is missing, it is
-taken as 0.
-@end deffn
-
-stack-id
-@c snarfed from stacks.c:511
-@deffn {Scheme Procedure} stack-id stack
-@deffnx {C Function} scm_stack_id (stack)
-Return the identifier given to @var{stack} by @code{start-stack}.
-@end deffn
-
-stack-ref
-@c snarfed from stacks.c:549
-@deffn {Scheme Procedure} stack-ref stack index
-@deffnx {C Function} scm_stack_ref (stack, index)
-Return the @var{index}'th frame from @var{stack}.
-@end deffn
-
-stack-length
-@c snarfed from stacks.c:562
-@deffn {Scheme Procedure} stack-length stack
-@deffnx {C Function} scm_stack_length (stack)
-Return the length of @var{stack}.
-@end deffn
-
-frame?
-@c snarfed from stacks.c:575
-@deffn {Scheme Procedure} frame? obj
-@deffnx {C Function} scm_frame_p (obj)
-Return @code{#t} if @var{obj} is a stack frame.
-@end deffn
-
-last-stack-frame
-@c snarfed from stacks.c:586
-@deffn {Scheme Procedure} last-stack-frame obj
-@deffnx {C Function} scm_last_stack_frame (obj)
-Return a stack which consists of a single frame, which is the
-last stack frame for @var{obj}. @var{obj} must be either a
-debug object or a continuation.
-@end deffn
-
-frame-number
-@c snarfed from stacks.c:625
-@deffn {Scheme Procedure} frame-number frame
-@deffnx {C Function} scm_frame_number (frame)
-Return the frame number of @var{frame}.
-@end deffn
-
-frame-source
-@c snarfed from stacks.c:635
-@deffn {Scheme Procedure} frame-source frame
-@deffnx {C Function} scm_frame_source (frame)
-Return the source of @var{frame}.
-@end deffn
-
-frame-procedure
-@c snarfed from stacks.c:646
-@deffn {Scheme Procedure} frame-procedure frame
-@deffnx {C Function} scm_frame_procedure (frame)
-Return the procedure for @var{frame}, or @code{#f} if no
-procedure is associated with @var{frame}.
-@end deffn
-
-frame-arguments
-@c snarfed from stacks.c:658
-@deffn {Scheme Procedure} frame-arguments frame
-@deffnx {C Function} scm_frame_arguments (frame)
-Return the arguments of @var{frame}.
-@end deffn
-
-frame-previous
-@c snarfed from stacks.c:669
-@deffn {Scheme Procedure} frame-previous frame
-@deffnx {C Function} scm_frame_previous (frame)
-Return the previous frame of @var{frame}, or @code{#f} if
-@var{frame} is the first frame in its stack.
-@end deffn
-
-frame-next
-@c snarfed from stacks.c:685
-@deffn {Scheme Procedure} frame-next frame
-@deffnx {C Function} scm_frame_next (frame)
-Return the next frame of @var{frame}, or @code{#f} if
-@var{frame} is the last frame in its stack.
-@end deffn
-
-frame-real?
-@c snarfed from stacks.c:700
-@deffn {Scheme Procedure} frame-real? frame
-@deffnx {C Function} scm_frame_real_p (frame)
-Return @code{#t} if @var{frame} is a real frame.
-@end deffn
-
-frame-procedure?
-@c snarfed from stacks.c:710
-@deffn {Scheme Procedure} frame-procedure? frame
-@deffnx {C Function} scm_frame_procedure_p (frame)
-Return @code{#t} if a procedure is associated with @var{frame}.
-@end deffn
-
-frame-evaluating-args?
-@c snarfed from stacks.c:720
-@deffn {Scheme Procedure} frame-evaluating-args? frame
-@deffnx {C Function} scm_frame_evaluating_args_p (frame)
-Return @code{#t} if @var{frame} contains evaluated arguments.
-@end deffn
-
-frame-overflow?
-@c snarfed from stacks.c:730
-@deffn {Scheme Procedure} frame-overflow? frame
-@deffnx {C Function} scm_frame_overflow_p (frame)
-Return @code{#t} if @var{frame} is an overflow frame.
-@end deffn
-
-get-internal-real-time
-@c snarfed from stime.c:133
-@deffn {Scheme Procedure} get-internal-real-time
-@deffnx {C Function} scm_get_internal_real_time ()
-Return the number of time units since the interpreter was
-started.
-@end deffn
-
-times
-@c snarfed from stime.c:180
-@deffn {Scheme Procedure} times
-@deffnx {C Function} scm_times ()
-Return an object with information about real and processor
-time. The following procedures accept such an object as an
-argument and return a selected component:
-
-@table @code
-@item tms:clock
-The current real time, expressed as time units relative to an
-arbitrary base.
-@item tms:utime
-The CPU time units used by the calling process.
-@item tms:stime
-The CPU time units used by the system on behalf of the calling
-process.
-@item tms:cutime
-The CPU time units used by terminated child processes of the
-calling process, whose status has been collected (e.g., using
-@code{waitpid}).
-@item tms:cstime
-Similarly, the CPU times units used by the system on behalf of
-terminated child processes.
-@end table
-@end deffn
-
-get-internal-run-time
-@c snarfed from stime.c:212
-@deffn {Scheme Procedure} get-internal-run-time
-@deffnx {C Function} scm_get_internal_run_time ()
-Return the number of time units of processor time used by the
-interpreter. Both @emph{system} and @emph{user} time are
-included but subprocesses are not.
-@end deffn
-
-current-time
-@c snarfed from stime.c:229
-@deffn {Scheme Procedure} current-time
-@deffnx {C Function} scm_current_time ()
-Return the number of seconds since 1970-01-01 00:00:00 UTC,
-excluding leap seconds.
-@end deffn
-
-gettimeofday
-@c snarfed from stime.c:248
-@deffn {Scheme Procedure} gettimeofday
-@deffnx {C Function} scm_gettimeofday ()
-Return a pair containing the number of seconds and microseconds
-since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note:
-whether true microsecond resolution is available depends on the
-operating system.
-@end deffn
-
-localtime
-@c snarfed from stime.c:364
-@deffn {Scheme Procedure} localtime time [zone]
-@deffnx {C Function} scm_localtime (time, zone)
-Return an object representing the broken down components of
-@var{time}, an integer like the one returned by
-@code{current-time}. The time zone for the calculation is
-optionally specified by @var{zone} (a string), otherwise the
-@code{TZ} environment variable or the system default is used.
-@end deffn
-
-gmtime
-@c snarfed from stime.c:449
-@deffn {Scheme Procedure} gmtime time
-@deffnx {C Function} scm_gmtime (time)
-Return an object representing the broken down components of
-@var{time}, an integer like the one returned by
-@code{current-time}. The values are calculated for UTC.
-@end deffn
-
-mktime
-@c snarfed from stime.c:517
-@deffn {Scheme Procedure} mktime sbd_time [zone]
-@deffnx {C Function} scm_mktime (sbd_time, zone)
-@var{bd-time} is an object representing broken down time and @code{zone}
-is an optional time zone specifier (otherwise the TZ environment variable
-or the system default is used).
-
-Returns a pair: the car is a corresponding
-integer time value like that returned
-by @code{current-time}; the cdr is a broken down time object, similar to
-as @var{bd-time} but with normalized values.
-@end deffn
-
-tzset
-@c snarfed from stime.c:603
-@deffn {Scheme Procedure} tzset
-@deffnx {C Function} scm_tzset ()
-Initialize the timezone from the TZ environment variable
-or the system default. It's not usually necessary to call this procedure
-since it's done automatically by other procedures that depend on the
-timezone.
-@end deffn
-
-strftime
-@c snarfed from stime.c:620
-@deffn {Scheme Procedure} strftime format stime
-@deffnx {C Function} scm_strftime (format, stime)
-Formats a time specification @var{time} using @var{template}. @var{time}
-is an object with time components in the form returned by @code{localtime}
-or @code{gmtime}. @var{template} is a string which can include formatting
-specifications introduced by a @code{%} character. The formatting of
-month and day names is dependent on the current locale. The value returned
-is the formatted string.
-@xref{Formatting Date and Time, , , libc, The GNU C Library Reference Manual}.)
-@end deffn
-
-strptime
-@c snarfed from stime.c:721
-@deffn {Scheme Procedure} strptime format string
-@deffnx {C Function} scm_strptime (format, string)
-Performs the reverse action to @code{strftime}, parsing
-@var{string} according to the specification supplied in
-@var{template}. The interpretation of month and day names is
-dependent on the current locale. The value returned is a pair.
-The car has an object with time components
-in the form returned by @code{localtime} or @code{gmtime},
-but the time zone components
-are not usefully set.
-The cdr reports the number of characters from @var{string}
-which were used for the conversion.
-@end deffn
-
-string?
-@c snarfed from strings.c:526
-@deffn {Scheme Procedure} string? obj
-@deffnx {C Function} scm_string_p (obj)
-Return @code{#t} if @var{obj} is a string, else @code{#f}.
-@end deffn
-
-list->string
-@c snarfed from strings.c:534
-@deffn {Scheme Procedure} list->string
-implemented by the C function "scm_string"
-@end deffn
-
-string
-@c snarfed from strings.c:540
-@deffn {Scheme Procedure} string . chrs
-@deffnx {Scheme Procedure} list->string chrs
-@deffnx {C Function} scm_string (chrs)
-Return a newly allocated string composed of the arguments,
-@var{chrs}.
-@end deffn
-
-make-string
-@c snarfed from strings.c:578
-@deffn {Scheme Procedure} make-string k [chr]
-@deffnx {C Function} scm_make_string (k, chr)
-Return a newly allocated string of
-length @var{k}. If @var{chr} is given, then all elements of
-the string are initialized to @var{chr}, otherwise the contents
-of the @var{string} are unspecified.
-@end deffn
-
-string-length
-@c snarfed from strings.c:604
-@deffn {Scheme Procedure} string-length string
-@deffnx {C Function} scm_string_length (string)
-Return the number of characters in @var{string}.
-@end deffn
-
-string-ref
-@c snarfed from strings.c:623
-@deffn {Scheme Procedure} string-ref str k
-@deffnx {C Function} scm_string_ref (str, k)
-Return character @var{k} of @var{str} using zero-origin
-indexing. @var{k} must be a valid index of @var{str}.
-@end deffn
-
-string-set!
-@c snarfed from strings.c:646
-@deffn {Scheme Procedure} string-set! str k chr
-@deffnx {C Function} scm_string_set_x (str, k, chr)
-Store @var{chr} in element @var{k} of @var{str} and return
-an unspecified value. @var{k} must be a valid index of
-@var{str}.
-@end deffn
-
-substring
-@c snarfed from strings.c:682
-@deffn {Scheme Procedure} substring str start [end]
-@deffnx {C Function} scm_substring (str, start, end)
-Return a newly allocated string formed from the characters
-of @var{str} beginning with index @var{start} (inclusive) and
-ending with index @var{end} (exclusive).
-@var{str} must be a string, @var{start} and @var{end} must be
-exact integers satisfying:
-
-0 <= @var{start} <= @var{end} <= (string-length @var{str}).
-@end deffn
-
-substring/read-only
-@c snarfed from strings.c:708
-@deffn {Scheme Procedure} substring/read-only str start [end]
-@deffnx {C Function} scm_substring_read_only (str, start, end)
-Return a newly allocated string formed from the characters
-of @var{str} beginning with index @var{start} (inclusive) and
-ending with index @var{end} (exclusive).
-@var{str} must be a string, @var{start} and @var{end} must be
-exact integers satisfying:
-
-0 <= @var{start} <= @var{end} <= (string-length @var{str}).
-
-The returned string is read-only.
-
-@end deffn
-
-substring/copy
-@c snarfed from strings.c:731
-@deffn {Scheme Procedure} substring/copy str start [end]
-@deffnx {C Function} scm_substring_copy (str, start, end)
-Return a newly allocated string formed from the characters
-of @var{str} beginning with index @var{start} (inclusive) and
-ending with index @var{end} (exclusive).
-@var{str} must be a string, @var{start} and @var{end} must be
-exact integers satisfying:
-
-0 <= @var{start} <= @var{end} <= (string-length @var{str}).
-@end deffn
-
-substring/shared
-@c snarfed from strings.c:755
-@deffn {Scheme Procedure} substring/shared str start [end]
-@deffnx {C Function} scm_substring_shared (str, start, end)
-Return string that indirectly refers to the characters
-of @var{str} beginning with index @var{start} (inclusive) and
-ending with index @var{end} (exclusive).
-@var{str} must be a string, @var{start} and @var{end} must be
-exact integers satisfying:
-
-0 <= @var{start} <= @var{end} <= (string-length @var{str}).
-@end deffn
-
-string-append
-@c snarfed from strings.c:774
-@deffn {Scheme Procedure} string-append . args
-@deffnx {C Function} scm_string_append (args)
-Return a newly allocated string whose characters form the
-concatenation of the given strings, @var{args}.
-@end deffn
-
-uniform-vector?
-@c snarfed from srfi-4.c:651
-@deffn {Scheme Procedure} uniform-vector? obj
-@deffnx {C Function} scm_uniform_vector_p (obj)
-Return @code{#t} if @var{obj} is a uniform vector.
-@end deffn
-
-uniform-vector-ref
-@c snarfed from srfi-4.c:677
-@deffn {Scheme Procedure} uniform-vector-ref v idx
-@deffnx {C Function} scm_uniform_vector_ref (v, idx)
-Return the element at index @var{idx} of the
-homogenous numeric vector @var{v}.
-@end deffn
-
-uniform-vector-set!
-@c snarfed from srfi-4.c:714
-@deffn {Scheme Procedure} uniform-vector-set! v idx val
-@deffnx {C Function} scm_uniform_vector_set_x (v, idx, val)
-Set the element at index @var{idx} of the
-homogenous numeric vector @var{v} to @var{val}.
-@end deffn
-
-uniform-vector->list
-@c snarfed from srfi-4.c:737
-@deffn {Scheme Procedure} uniform-vector->list uvec
-@deffnx {C Function} scm_uniform_vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-uniform-vector-length
-@c snarfed from srfi-4.c:820
-@deffn {Scheme Procedure} uniform-vector-length v
-@deffnx {C Function} scm_uniform_vector_length (v)
-Return the number of elements in the uniform vector @var{v}.
-@end deffn
-
-uniform-vector-read!
-@c snarfed from srfi-4.c:845
-@deffn {Scheme Procedure} uniform-array-read! ura [port_or_fd [start [end]]]
-@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end]
-@deffnx {C Function} scm_uniform_array_read_x (ura, port_or_fd, start, end)
-Attempt to read all elements of @var{ura}, in lexicographic order, as
-binary objects from @var{port-or-fdes}.
-If an end of file is encountered,
-the objects up to that point are put into @var{ura}
-(starting at the beginning) and the remainder of the array is
-unchanged.
-
-The optional arguments @var{start} and @var{end} allow
-a specified region of a vector (or linearized array) to be read,
-leaving the remainder of the vector unchanged.
-
-@code{uniform-array-read!} returns the number of objects read.
-@var{port-or-fdes} may be omitted, in which case it defaults to the value
-returned by @code{(current-input-port)}.
-@end deffn
-
-uniform-vector-write
-@c snarfed from srfi-4.c:958
-@deffn {Scheme Procedure} uniform-vector-write uvec [port_or_fd [start [end]]]
-@deffnx {C Function} scm_uniform_vector_write (uvec, port_or_fd, start, end)
-Write the elements of @var{uvec} as raw bytes to
-@var{port-or-fdes}, in the host byte order.
-
-The optional arguments @var{start} (inclusive)
-and @var{end} (exclusive) allow
-a specified region to be written.
-
-When @var{port-or-fdes} is a port, all specified elements
-of @var{uvec} are attempted to be written, potentially blocking
-while waiting for more room.
-When @var{port-or-fd} is an integer, a single call to
-write(2) is made.
-
-An error is signalled when the last element has only
-been partially written in the single call to write(2).
-
-The number of objects actually written is returned.
-@var{port-or-fdes} may be
-omitted, in which case it defaults to the value returned by
-@code{(current-output-port)}.
-@end deffn
-
-u8vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} u8vector? obj
-@deffnx {C Function} scm_u8vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type u8,
-@code{#f} otherwise.
-@end deffn
-
-make-u8vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-u8vector len [fill]
-@deffnx {C Function} scm_make_u8vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-u8vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} u8vector . l
-@deffnx {C Function} scm_u8vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-u8vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} u8vector-length uvec
-@deffnx {C Function} scm_u8vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-u8vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} u8vector-ref uvec index
-@deffnx {C Function} scm_u8vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-u8vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} u8vector-set! uvec index value
-@deffnx {C Function} scm_u8vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-u8vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} u8vector->list uvec
-@deffnx {C Function} scm_u8vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->u8vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->u8vector l
-@deffnx {C Function} scm_list_to_u8vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->u8vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->u8vector obj
-@deffnx {C Function} scm_any_to_u8vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type u8.
-@end deffn
-
-s8vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} s8vector? obj
-@deffnx {C Function} scm_s8vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type s8,
-@code{#f} otherwise.
-@end deffn
-
-make-s8vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-s8vector len [fill]
-@deffnx {C Function} scm_make_s8vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-s8vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} s8vector . l
-@deffnx {C Function} scm_s8vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-s8vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} s8vector-length uvec
-@deffnx {C Function} scm_s8vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-s8vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} s8vector-ref uvec index
-@deffnx {C Function} scm_s8vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-s8vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} s8vector-set! uvec index value
-@deffnx {C Function} scm_s8vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-s8vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} s8vector->list uvec
-@deffnx {C Function} scm_s8vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->s8vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->s8vector l
-@deffnx {C Function} scm_list_to_s8vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->s8vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->s8vector obj
-@deffnx {C Function} scm_any_to_s8vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type s8.
-@end deffn
-
-u16vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} u16vector? obj
-@deffnx {C Function} scm_u16vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type u16,
-@code{#f} otherwise.
-@end deffn
-
-make-u16vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-u16vector len [fill]
-@deffnx {C Function} scm_make_u16vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-u16vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} u16vector . l
-@deffnx {C Function} scm_u16vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-u16vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} u16vector-length uvec
-@deffnx {C Function} scm_u16vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-u16vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} u16vector-ref uvec index
-@deffnx {C Function} scm_u16vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-u16vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} u16vector-set! uvec index value
-@deffnx {C Function} scm_u16vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-u16vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} u16vector->list uvec
-@deffnx {C Function} scm_u16vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->u16vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->u16vector l
-@deffnx {C Function} scm_list_to_u16vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->u16vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->u16vector obj
-@deffnx {C Function} scm_any_to_u16vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type u16.
-@end deffn
-
-s16vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} s16vector? obj
-@deffnx {C Function} scm_s16vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type s16,
-@code{#f} otherwise.
-@end deffn
-
-make-s16vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-s16vector len [fill]
-@deffnx {C Function} scm_make_s16vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-s16vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} s16vector . l
-@deffnx {C Function} scm_s16vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-s16vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} s16vector-length uvec
-@deffnx {C Function} scm_s16vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-s16vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} s16vector-ref uvec index
-@deffnx {C Function} scm_s16vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-s16vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} s16vector-set! uvec index value
-@deffnx {C Function} scm_s16vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-s16vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} s16vector->list uvec
-@deffnx {C Function} scm_s16vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->s16vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->s16vector l
-@deffnx {C Function} scm_list_to_s16vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->s16vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->s16vector obj
-@deffnx {C Function} scm_any_to_s16vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type s16.
-@end deffn
-
-u32vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} u32vector? obj
-@deffnx {C Function} scm_u32vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type u32,
-@code{#f} otherwise.
-@end deffn
-
-make-u32vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-u32vector len [fill]
-@deffnx {C Function} scm_make_u32vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-u32vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} u32vector . l
-@deffnx {C Function} scm_u32vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-u32vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} u32vector-length uvec
-@deffnx {C Function} scm_u32vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-u32vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} u32vector-ref uvec index
-@deffnx {C Function} scm_u32vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-u32vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} u32vector-set! uvec index value
-@deffnx {C Function} scm_u32vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-u32vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} u32vector->list uvec
-@deffnx {C Function} scm_u32vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->u32vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->u32vector l
-@deffnx {C Function} scm_list_to_u32vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->u32vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->u32vector obj
-@deffnx {C Function} scm_any_to_u32vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type u32.
-@end deffn
-
-s32vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} s32vector? obj
-@deffnx {C Function} scm_s32vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type s32,
-@code{#f} otherwise.
-@end deffn
-
-make-s32vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-s32vector len [fill]
-@deffnx {C Function} scm_make_s32vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-s32vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} s32vector . l
-@deffnx {C Function} scm_s32vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-s32vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} s32vector-length uvec
-@deffnx {C Function} scm_s32vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-s32vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} s32vector-ref uvec index
-@deffnx {C Function} scm_s32vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-s32vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} s32vector-set! uvec index value
-@deffnx {C Function} scm_s32vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-s32vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} s32vector->list uvec
-@deffnx {C Function} scm_s32vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->s32vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->s32vector l
-@deffnx {C Function} scm_list_to_s32vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->s32vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->s32vector obj
-@deffnx {C Function} scm_any_to_s32vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type s32.
-@end deffn
-
-u64vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} u64vector? obj
-@deffnx {C Function} scm_u64vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type u64,
-@code{#f} otherwise.
-@end deffn
-
-make-u64vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-u64vector len [fill]
-@deffnx {C Function} scm_make_u64vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-u64vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} u64vector . l
-@deffnx {C Function} scm_u64vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-u64vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} u64vector-length uvec
-@deffnx {C Function} scm_u64vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-u64vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} u64vector-ref uvec index
-@deffnx {C Function} scm_u64vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-u64vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} u64vector-set! uvec index value
-@deffnx {C Function} scm_u64vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-u64vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} u64vector->list uvec
-@deffnx {C Function} scm_u64vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->u64vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->u64vector l
-@deffnx {C Function} scm_list_to_u64vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->u64vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->u64vector obj
-@deffnx {C Function} scm_any_to_u64vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type u64.
-@end deffn
-
-s64vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} s64vector? obj
-@deffnx {C Function} scm_s64vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type s64,
-@code{#f} otherwise.
-@end deffn
-
-make-s64vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-s64vector len [fill]
-@deffnx {C Function} scm_make_s64vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-s64vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} s64vector . l
-@deffnx {C Function} scm_s64vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-s64vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} s64vector-length uvec
-@deffnx {C Function} scm_s64vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-s64vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} s64vector-ref uvec index
-@deffnx {C Function} scm_s64vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-s64vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} s64vector-set! uvec index value
-@deffnx {C Function} scm_s64vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-s64vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} s64vector->list uvec
-@deffnx {C Function} scm_s64vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->s64vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->s64vector l
-@deffnx {C Function} scm_list_to_s64vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->s64vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->s64vector obj
-@deffnx {C Function} scm_any_to_s64vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type s64.
-@end deffn
-
-f32vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} f32vector? obj
-@deffnx {C Function} scm_f32vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type f32,
-@code{#f} otherwise.
-@end deffn
-
-make-f32vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-f32vector len [fill]
-@deffnx {C Function} scm_make_f32vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-f32vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} f32vector . l
-@deffnx {C Function} scm_f32vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-f32vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} f32vector-length uvec
-@deffnx {C Function} scm_f32vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-f32vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} f32vector-ref uvec index
-@deffnx {C Function} scm_f32vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-f32vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} f32vector-set! uvec index value
-@deffnx {C Function} scm_f32vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-f32vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} f32vector->list uvec
-@deffnx {C Function} scm_f32vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->f32vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->f32vector l
-@deffnx {C Function} scm_list_to_f32vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->f32vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->f32vector obj
-@deffnx {C Function} scm_any_to_f32vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type f32.
-@end deffn
-
-f64vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} f64vector? obj
-@deffnx {C Function} scm_f64vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type f64,
-@code{#f} otherwise.
-@end deffn
-
-make-f64vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-f64vector len [fill]
-@deffnx {C Function} scm_make_f64vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-f64vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} f64vector . l
-@deffnx {C Function} scm_f64vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-f64vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} f64vector-length uvec
-@deffnx {C Function} scm_f64vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-f64vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} f64vector-ref uvec index
-@deffnx {C Function} scm_f64vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-f64vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} f64vector-set! uvec index value
-@deffnx {C Function} scm_f64vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-f64vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} f64vector->list uvec
-@deffnx {C Function} scm_f64vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->f64vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->f64vector l
-@deffnx {C Function} scm_list_to_f64vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->f64vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->f64vector obj
-@deffnx {C Function} scm_any_to_f64vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type f64.
-@end deffn
-
-c32vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} c32vector? obj
-@deffnx {C Function} scm_c32vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type c32,
-@code{#f} otherwise.
-@end deffn
-
-make-c32vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-c32vector len [fill]
-@deffnx {C Function} scm_make_c32vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-c32vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} c32vector . l
-@deffnx {C Function} scm_c32vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-c32vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} c32vector-length uvec
-@deffnx {C Function} scm_c32vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-c32vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} c32vector-ref uvec index
-@deffnx {C Function} scm_c32vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-c32vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} c32vector-set! uvec index value
-@deffnx {C Function} scm_c32vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-c32vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} c32vector->list uvec
-@deffnx {C Function} scm_c32vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->c32vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->c32vector l
-@deffnx {C Function} scm_list_to_c32vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->c32vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->c32vector obj
-@deffnx {C Function} scm_any_to_c32vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type c32.
-@end deffn
-
-c64vector?
-@c snarfed from ../libguile/srfi-4.i.c:41
-@deffn {Scheme Procedure} c64vector? obj
-@deffnx {C Function} scm_c64vector_p (obj)
-Return @code{#t} if @var{obj} is a vector of type c64,
-@code{#f} otherwise.
-@end deffn
-
-make-c64vector
-@c snarfed from ../libguile/srfi-4.i.c:53
-@deffn {Scheme Procedure} make-c64vector len [fill]
-@deffnx {C Function} scm_make_c64vector (len, fill)
-Return a newly allocated uniform numeric vector which can
-hold @var{len} elements. If @var{fill} is given, it is used to
-initialize the elements, otherwise the contents of the vector
-is unspecified.
-@end deffn
-
-c64vector
-@c snarfed from ../libguile/srfi-4.i.c:63
-@deffn {Scheme Procedure} c64vector . l
-@deffnx {C Function} scm_c64vector (l)
-Return a newly allocated uniform numeric vector containing
-all argument values.
-@end deffn
-
-c64vector-length
-@c snarfed from ../libguile/srfi-4.i.c:74
-@deffn {Scheme Procedure} c64vector-length uvec
-@deffnx {C Function} scm_c64vector_length (uvec)
-Return the number of elements in the uniform numeric vector
-@var{uvec}.
-@end deffn
-
-c64vector-ref
-@c snarfed from ../libguile/srfi-4.i.c:85
-@deffn {Scheme Procedure} c64vector-ref uvec index
-@deffnx {C Function} scm_c64vector_ref (uvec, index)
-Return the element at @var{index} in the uniform numeric
-vector @var{uvec}.
-@end deffn
-
-c64vector-set!
-@c snarfed from ../libguile/srfi-4.i.c:97
-@deffn {Scheme Procedure} c64vector-set! uvec index value
-@deffnx {C Function} scm_c64vector_set_x (uvec, index, value)
-Set the element at @var{index} in the uniform numeric
-vector @var{uvec} to @var{value}. The return value is not
-specified.
-@end deffn
-
-c64vector->list
-@c snarfed from ../libguile/srfi-4.i.c:107
-@deffn {Scheme Procedure} c64vector->list uvec
-@deffnx {C Function} scm_c64vector_to_list (uvec)
-Convert the uniform numeric vector @var{uvec} to a list.
-@end deffn
-
-list->c64vector
-@c snarfed from ../libguile/srfi-4.i.c:117
-@deffn {Scheme Procedure} list->c64vector l
-@deffnx {C Function} scm_list_to_c64vector (l)
-Convert the list @var{l} to a numeric uniform vector.
-@end deffn
-
-any->c64vector
-@c snarfed from ../libguile/srfi-4.i.c:128
-@deffn {Scheme Procedure} any->c64vector obj
-@deffnx {C Function} scm_any_to_c64vector (obj)
-Convert @var{obj}, which can be a list, vector, or
-uniform vector, to a numeric uniform vector of
-type c64.
-@end deffn
-
-string-null?
-@c snarfed from srfi-13.c:62
-@deffn {Scheme Procedure} string-null? str
-@deffnx {C Function} scm_string_null_p (str)
-Return @code{#t} if @var{str}'s length is zero, and
-@code{#f} otherwise.
-@lisp
-(string-null? "") @result{} #t
-y @result{} "foo"
-(string-null? y) @result{} #f
-@end lisp
-@end deffn
-
-string-any-c-code
-@c snarfed from srfi-13.c:94
-@deffn {Scheme Procedure} string-any-c-code char_pred s [start [end]]
-@deffnx {C Function} scm_string_any (char_pred, s, start, end)
-Check if @var{char_pred} is true for any character in string @var{s}.
-
-@var{char_pred} can be a character to check for any equal to that, or
-a character set (@pxref{Character Sets}) to check for any in that set,
-or a predicate procedure to call.
-
-For a procedure, calls @code{(@var{char_pred} c)} are made
-successively on the characters from @var{start} to @var{end}. If
-@var{char_pred} returns true (ie.@: non-@code{#f}), @code{string-any}
-stops and that return value is the return from @code{string-any}. The
-call on the last character (ie.@: at @math{@var{end}-1}), if that
-point is reached, is a tail call.
-
-If there are no characters in @var{s} (ie.@: @var{start} equals
-@var{end}) then the return is @code{#f}.
-
-@end deffn
-
-string-every-c-code
-@c snarfed from srfi-13.c:158
-@deffn {Scheme Procedure} string-every-c-code char_pred s [start [end]]
-@deffnx {C Function} scm_string_every (char_pred, s, start, end)
-Check if @var{char_pred} is true for every character in string
-@var{s}.
-
-@var{char_pred} can be a character to check for every character equal
-to that, or a character set (@pxref{Character Sets}) to check for
-every character being in that set, or a predicate procedure to call.
-
-For a procedure, calls @code{(@var{char_pred} c)} are made
-successively on the characters from @var{start} to @var{end}. If
-@var{char_pred} returns @code{#f}, @code{string-every} stops and
-returns @code{#f}. The call on the last character (ie.@: at
-@math{@var{end}-1}), if that point is reached, is a tail call and the
-return from that call is the return from @code{string-every}.
-
-If there are no characters in @var{s} (ie.@: @var{start} equals
-@var{end}) then the return is @code{#t}.
-
-@end deffn
-
-string-tabulate
-@c snarfed from srfi-13.c:214
-@deffn {Scheme Procedure} string-tabulate proc len
-@deffnx {C Function} scm_string_tabulate (proc, len)
-@var{proc} is an integer->char procedure. Construct a string
-of size @var{len} by applying @var{proc} to each index to
-produce the corresponding string element. The order in which
-@var{proc} is applied to the indices is not specified.
-@end deffn
-
-string->list
-@c snarfed from srfi-13.c:246
-@deffn {Scheme Procedure} string->list str [start [end]]
-@deffnx {C Function} scm_substring_to_list (str, start, end)
-Convert the string @var{str} into a list of characters.
-@end deffn
-
-reverse-list->string
-@c snarfed from srfi-13.c:285
-@deffn {Scheme Procedure} reverse-list->string chrs
-@deffnx {C Function} scm_reverse_list_to_string (chrs)
-An efficient implementation of @code{(compose string->list
-reverse)}:
-
-@smalllisp
-(reverse-list->string '(#\a #\B #\c)) @result{} "cBa"
-@end smalllisp
-@end deffn
-
-string-join
-@c snarfed from srfi-13.c:352
-@deffn {Scheme Procedure} string-join ls [delimiter [grammar]]
-@deffnx {C Function} scm_string_join (ls, delimiter, grammar)
-Append the string in the string list @var{ls}, using the string
-@var{delim} as a delimiter between the elements of @var{ls}.
-@var{grammar} is a symbol which specifies how the delimiter is
-placed between the strings, and defaults to the symbol
-@code{infix}.
-
-@table @code
-@item infix
-Insert the separator between list elements. An empty string
-will produce an empty list.
-@item string-infix
-Like @code{infix}, but will raise an error if given the empty
-list.
-@item suffix
-Insert the separator after every list element.
-@item prefix
-Insert the separator before each list element.
-@end table
-@end deffn
-
-string-copy
-@c snarfed from srfi-13.c:486
-@deffn {Scheme Procedure} string-copy str [start [end]]
-@deffnx {C Function} scm_srfi13_substring_copy (str, start, end)
-Return a freshly allocated copy of the string @var{str}. If
-given, @var{start} and @var{end} delimit the portion of
-@var{str} which is copied.
-@end deffn
-
-string-copy!
-@c snarfed from srfi-13.c:513
-@deffn {Scheme Procedure} string-copy! target tstart s [start [end]]
-@deffnx {C Function} scm_string_copy_x (target, tstart, s, start, end)
-Copy the sequence of characters from index range [@var{start},
-@var{end}) in string @var{s} to string @var{target}, beginning
-at index @var{tstart}. The characters are copied left-to-right
-or right-to-left as needed -- the copy is guaranteed to work,
-even if @var{target} and @var{s} are the same string. It is an
-error if the copy operation runs off the end of the target
-string.
-@end deffn
-
-substring-move!
-@c snarfed from srfi-13.c:543
-@deffn {Scheme Procedure} substring-move! str1 start1 end1 str2 start2
-@deffnx {C Function} scm_substring_move_x (str1, start1, end1, str2, start2)
-Copy the substring of @var{str1} bounded by @var{start1} and @var{end1}
-into @var{str2} beginning at position @var{start2}.
-@var{str1} and @var{str2} can be the same string.
-@end deffn
-
-string-take
-@c snarfed from srfi-13.c:552
-@deffn {Scheme Procedure} string-take s n
-@deffnx {C Function} scm_string_take (s, n)
-Return the @var{n} first characters of @var{s}.
-@end deffn
-
-string-drop
-@c snarfed from srfi-13.c:562
-@deffn {Scheme Procedure} string-drop s n
-@deffnx {C Function} scm_string_drop (s, n)
-Return all but the first @var{n} characters of @var{s}.
-@end deffn
-
-string-take-right
-@c snarfed from srfi-13.c:572
-@deffn {Scheme Procedure} string-take-right s n
-@deffnx {C Function} scm_string_take_right (s, n)
-Return the @var{n} last characters of @var{s}.
-@end deffn
-
-string-drop-right
-@c snarfed from srfi-13.c:584
-@deffn {Scheme Procedure} string-drop-right s n
-@deffnx {C Function} scm_string_drop_right (s, n)
-Return all but the last @var{n} characters of @var{s}.
-@end deffn
-
-string-pad
-@c snarfed from srfi-13.c:599
-@deffn {Scheme Procedure} string-pad s len [chr [start [end]]]
-@deffnx {C Function} scm_string_pad (s, len, chr, start, end)
-Take that characters from @var{start} to @var{end} from the
-string @var{s} and return a new string, right-padded by the
-character @var{chr} to length @var{len}. If the resulting
-string is longer than @var{len}, it is truncated on the right.
-@end deffn
-
-string-pad-right
-@c snarfed from srfi-13.c:639
-@deffn {Scheme Procedure} string-pad-right s len [chr [start [end]]]
-@deffnx {C Function} scm_string_pad_right (s, len, chr, start, end)
-Take that characters from @var{start} to @var{end} from the
-string @var{s} and return a new string, left-padded by the
-character @var{chr} to length @var{len}. If the resulting
-string is longer than @var{len}, it is truncated on the left.
-@end deffn
-
-string-trim
-@c snarfed from srfi-13.c:692
-@deffn {Scheme Procedure} string-trim s [char_pred [start [end]]]
-@deffnx {C Function} scm_string_trim (s, char_pred, start, end)
-Trim @var{s} by skipping over all characters on the left
-that satisfy the parameter @var{char_pred}:
-
-@itemize @bullet
-@item
-if it is the character @var{ch}, characters equal to
-@var{ch} are trimmed,
-
-@item
-if it is a procedure @var{pred} characters that
-satisfy @var{pred} are trimmed,
-
-@item
-if it is a character set, characters in that set are trimmed.
-@end itemize
-
-If called without a @var{char_pred} argument, all whitespace is
-trimmed.
-@end deffn
-
-string-trim-right
-@c snarfed from srfi-13.c:768
-@deffn {Scheme Procedure} string-trim-right s [char_pred [start [end]]]
-@deffnx {C Function} scm_string_trim_right (s, char_pred, start, end)
-Trim @var{s} by skipping over all characters on the rightt
-that satisfy the parameter @var{char_pred}:
-
-@itemize @bullet
-@item
-if it is the character @var{ch}, characters equal to @var{ch}
-are trimmed,
-
-@item
-if it is a procedure @var{pred} characters that satisfy
-@var{pred} are trimmed,
-
-@item
-if it is a character sets, all characters in that set are
-trimmed.
-@end itemize
-
-If called without a @var{char_pred} argument, all whitespace is
-trimmed.
-@end deffn
-
-string-trim-both
-@c snarfed from srfi-13.c:844
-@deffn {Scheme Procedure} string-trim-both s [char_pred [start [end]]]
-@deffnx {C Function} scm_string_trim_both (s, char_pred, start, end)
-Trim @var{s} by skipping over all characters on both sides of
-the string that satisfy the parameter @var{char_pred}:
-
-@itemize @bullet
-@item
-if it is the character @var{ch}, characters equal to @var{ch}
-are trimmed,
-
-@item
-if it is a procedure @var{pred} characters that satisfy
-@var{pred} are trimmed,
-
-@item
-if it is a character set, the characters in the set are
-trimmed.
-@end itemize
-
-If called without a @var{char_pred} argument, all whitespace is
-trimmed.
-@end deffn
-
-string-fill!
-@c snarfed from srfi-13.c:931
-@deffn {Scheme Procedure} string-fill! str chr [start [end]]
-@deffnx {C Function} scm_substring_fill_x (str, chr, start, end)
-Stores @var{chr} in every element of the given @var{str} and
-returns an unspecified value.
-@end deffn
-
-string-compare
-@c snarfed from srfi-13.c:983
-@deffn {Scheme Procedure} string-compare s1 s2 proc_lt proc_eq proc_gt [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_compare (s1, s2, proc_lt, proc_eq, proc_gt, start1, end1, start2, end2)
-Apply @var{proc_lt}, @var{proc_eq}, @var{proc_gt} to the
-mismatch index, depending upon whether @var{s1} is less than,
-equal to, or greater than @var{s2}. The mismatch index is the
-largest index @var{i} such that for every 0 <= @var{j} <
-@var{i}, @var{s1}[@var{j}] = @var{s2}[@var{j}] -- that is,
-@var{i} is the first position that does not match.
-@end deffn
-
-string-compare-ci
-@c snarfed from srfi-13.c:1037
-@deffn {Scheme Procedure} string-compare-ci s1 s2 proc_lt proc_eq proc_gt [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_compare_ci (s1, s2, proc_lt, proc_eq, proc_gt, start1, end1, start2, end2)
-Apply @var{proc_lt}, @var{proc_eq}, @var{proc_gt} to the
-mismatch index, depending upon whether @var{s1} is less than,
-equal to, or greater than @var{s2}. The mismatch index is the
-largest index @var{i} such that for every 0 <= @var{j} <
-@var{i}, @var{s1}[@var{j}] = @var{s2}[@var{j}] -- that is,
-@var{i} is the first position where the lowercased letters
-do not match.
-
-@end deffn
-
-string=
-@c snarfed from srfi-13.c:1088
-@deffn {Scheme Procedure} string= s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_eq (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} and @var{s2} are not equal, a true
-value otherwise.
-@end deffn
-
-string<>
-@c snarfed from srfi-13.c:1127
-@deffn {Scheme Procedure} string<> s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_neq (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} and @var{s2} are equal, a true
-value otherwise.
-@end deffn
-
-string<
-@c snarfed from srfi-13.c:1170
-@deffn {Scheme Procedure} string< s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_lt (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is greater or equal to @var{s2}, a
-true value otherwise.
-@end deffn
-
-string>
-@c snarfed from srfi-13.c:1213
-@deffn {Scheme Procedure} string> s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_gt (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is less or equal to @var{s2}, a
-true value otherwise.
-@end deffn
-
-string<=
-@c snarfed from srfi-13.c:1256
-@deffn {Scheme Procedure} string<= s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_le (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is greater to @var{s2}, a true
-value otherwise.
-@end deffn
-
-string>=
-@c snarfed from srfi-13.c:1299
-@deffn {Scheme Procedure} string>= s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ge (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is less to @var{s2}, a true value
-otherwise.
-@end deffn
-
-string-ci=
-@c snarfed from srfi-13.c:1343
-@deffn {Scheme Procedure} string-ci= s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ci_eq (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} and @var{s2} are not equal, a true
-value otherwise. The character comparison is done
-case-insensitively.
-@end deffn
-
-string-ci<>
-@c snarfed from srfi-13.c:1387
-@deffn {Scheme Procedure} string-ci<> s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ci_neq (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} and @var{s2} are equal, a true
-value otherwise. The character comparison is done
-case-insensitively.
-@end deffn
-
-string-ci<
-@c snarfed from srfi-13.c:1431
-@deffn {Scheme Procedure} string-ci< s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ci_lt (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is greater or equal to @var{s2}, a
-true value otherwise. The character comparison is done
-case-insensitively.
-@end deffn
-
-string-ci>
-@c snarfed from srfi-13.c:1475
-@deffn {Scheme Procedure} string-ci> s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ci_gt (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is less or equal to @var{s2}, a
-true value otherwise. The character comparison is done
-case-insensitively.
-@end deffn
-
-string-ci<=
-@c snarfed from srfi-13.c:1519
-@deffn {Scheme Procedure} string-ci<= s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ci_le (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is greater to @var{s2}, a true
-value otherwise. The character comparison is done
-case-insensitively.
-@end deffn
-
-string-ci>=
-@c snarfed from srfi-13.c:1563
-@deffn {Scheme Procedure} string-ci>= s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_ci_ge (s1, s2, start1, end1, start2, end2)
-Return @code{#f} if @var{s1} is less to @var{s2}, a true value
-otherwise. The character comparison is done
-case-insensitively.
-@end deffn
-
-string-hash
-@c snarfed from srfi-13.c:1608
-@deffn {Scheme Procedure} string-hash s [bound [start [end]]]
-@deffnx {C Function} scm_substring_hash (s, bound, start, end)
-Compute a hash value for @var{S}. the optional argument @var{bound} is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound).
-@end deffn
-
-string-hash-ci
-@c snarfed from srfi-13.c:1625
-@deffn {Scheme Procedure} string-hash-ci s [bound [start [end]]]
-@deffnx {C Function} scm_substring_hash_ci (s, bound, start, end)
-Compute a hash value for @var{S}. the optional argument @var{bound} is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound).
-@end deffn
-
-string-prefix-length
-@c snarfed from srfi-13.c:1637
-@deffn {Scheme Procedure} string-prefix-length s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_prefix_length (s1, s2, start1, end1, start2, end2)
-Return the length of the longest common prefix of the two
-strings.
-@end deffn
-
-string-prefix-length-ci
-@c snarfed from srfi-13.c:1669
-@deffn {Scheme Procedure} string-prefix-length-ci s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_prefix_length_ci (s1, s2, start1, end1, start2, end2)
-Return the length of the longest common prefix of the two
-strings, ignoring character case.
-@end deffn
-
-string-suffix-length
-@c snarfed from srfi-13.c:1701
-@deffn {Scheme Procedure} string-suffix-length s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_suffix_length (s1, s2, start1, end1, start2, end2)
-Return the length of the longest common suffix of the two
-strings.
-@end deffn
-
-string-suffix-length-ci
-@c snarfed from srfi-13.c:1733
-@deffn {Scheme Procedure} string-suffix-length-ci s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_suffix_length_ci (s1, s2, start1, end1, start2, end2)
-Return the length of the longest common suffix of the two
-strings, ignoring character case.
-@end deffn
-
-string-prefix?
-@c snarfed from srfi-13.c:1764
-@deffn {Scheme Procedure} string-prefix? s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_prefix_p (s1, s2, start1, end1, start2, end2)
-Is @var{s1} a prefix of @var{s2}?
-@end deffn
-
-string-prefix-ci?
-@c snarfed from srfi-13.c:1796
-@deffn {Scheme Procedure} string-prefix-ci? s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_prefix_ci_p (s1, s2, start1, end1, start2, end2)
-Is @var{s1} a prefix of @var{s2}, ignoring character case?
-@end deffn
-
-string-suffix?
-@c snarfed from srfi-13.c:1828
-@deffn {Scheme Procedure} string-suffix? s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_suffix_p (s1, s2, start1, end1, start2, end2)
-Is @var{s1} a suffix of @var{s2}?
-@end deffn
-
-string-suffix-ci?
-@c snarfed from srfi-13.c:1860
-@deffn {Scheme Procedure} string-suffix-ci? s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_suffix_ci_p (s1, s2, start1, end1, start2, end2)
-Is @var{s1} a suffix of @var{s2}, ignoring character case?
-@end deffn
-
-string-index
-@c snarfed from srfi-13.c:1904
-@deffn {Scheme Procedure} string-index s char_pred [start [end]]
-@deffnx {C Function} scm_string_index (s, char_pred, start, end)
-Search through the string @var{s} from left to right, returning
-the index of the first occurence of a character which
-
-@itemize @bullet
-@item
-equals @var{char_pred}, if it is character,
-
-@item
-satisifies the predicate @var{char_pred}, if it is a procedure,
-
-@item
-is in the set @var{char_pred}, if it is a character set.
-@end itemize
-@end deffn
-
-string-index-right
-@c snarfed from srfi-13.c:1969
-@deffn {Scheme Procedure} string-index-right s char_pred [start [end]]
-@deffnx {C Function} scm_string_index_right (s, char_pred, start, end)
-Search through the string @var{s} from right to left, returning
-the index of the last occurence of a character which
-
-@itemize @bullet
-@item
-equals @var{char_pred}, if it is character,
-
-@item
-satisifies the predicate @var{char_pred}, if it is a procedure,
-
-@item
-is in the set if @var{char_pred} is a character set.
-@end itemize
-@end deffn
-
-string-rindex
-@c snarfed from srfi-13.c:2034
-@deffn {Scheme Procedure} string-rindex s char_pred [start [end]]
-@deffnx {C Function} scm_string_rindex (s, char_pred, start, end)
-Search through the string @var{s} from right to left, returning
-the index of the last occurence of a character which
-
-@itemize @bullet
-@item
-equals @var{char_pred}, if it is character,
-
-@item
-satisifies the predicate @var{char_pred}, if it is a procedure,
-
-@item
-is in the set if @var{char_pred} is a character set.
-@end itemize
-@end deffn
-
-string-skip
-@c snarfed from srfi-13.c:2056
-@deffn {Scheme Procedure} string-skip s char_pred [start [end]]
-@deffnx {C Function} scm_string_skip (s, char_pred, start, end)
-Search through the string @var{s} from left to right, returning
-the index of the first occurence of a character which
-
-@itemize @bullet
-@item
-does not equal @var{char_pred}, if it is character,
-
-@item
-does not satisify the predicate @var{char_pred}, if it is a
-procedure,
-
-@item
-is not in the set if @var{char_pred} is a character set.
-@end itemize
-@end deffn
-
-string-skip-right
-@c snarfed from srfi-13.c:2123
-@deffn {Scheme Procedure} string-skip-right s char_pred [start [end]]
-@deffnx {C Function} scm_string_skip_right (s, char_pred, start, end)
-Search through the string @var{s} from right to left, returning
-the index of the last occurence of a character which
-
-@itemize @bullet
-@item
-does not equal @var{char_pred}, if it is character,
-
-@item
-does not satisfy the predicate @var{char_pred}, if it is a
-procedure,
-
-@item
-is not in the set if @var{char_pred} is a character set.
-@end itemize
-@end deffn
-
-string-count
-@c snarfed from srfi-13.c:2190
-@deffn {Scheme Procedure} string-count s char_pred [start [end]]
-@deffnx {C Function} scm_string_count (s, char_pred, start, end)
-Return the count of the number of characters in the string
-@var{s} which
-
-@itemize @bullet
-@item
-equals @var{char_pred}, if it is character,
-
-@item
-satisifies the predicate @var{char_pred}, if it is a procedure.
-
-@item
-is in the set @var{char_pred}, if it is a character set.
-@end itemize
-@end deffn
-
-string-contains
-@c snarfed from srfi-13.c:2247
-@deffn {Scheme Procedure} string-contains s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_contains (s1, s2, start1, end1, start2, end2)
-Does string @var{s1} contain string @var{s2}? Return the index
-in @var{s1} where @var{s2} occurs as a substring, or false.
-The optional start/end indices restrict the operation to the
-indicated substrings.
-@end deffn
-
-string-contains-ci
-@c snarfed from srfi-13.c:2294
-@deffn {Scheme Procedure} string-contains-ci s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_contains_ci (s1, s2, start1, end1, start2, end2)
-Does string @var{s1} contain string @var{s2}? Return the index
-in @var{s1} where @var{s2} occurs as a substring, or false.
-The optional start/end indices restrict the operation to the
-indicated substrings. Character comparison is done
-case-insensitively.
-@end deffn
-
-string-upcase!
-@c snarfed from srfi-13.c:2359
-@deffn {Scheme Procedure} string-upcase! str [start [end]]
-@deffnx {C Function} scm_substring_upcase_x (str, start, end)
-Destructively upcase every character in @code{str}.
-
-@lisp
-(string-upcase! y)
-@result{} "ARRDEFG"
-y
-@result{} "ARRDEFG"
-@end lisp
-@end deffn
-
-string-upcase
-@c snarfed from srfi-13.c:2380
-@deffn {Scheme Procedure} string-upcase str [start [end]]
-@deffnx {C Function} scm_substring_upcase (str, start, end)
-Upcase every character in @code{str}.
-@end deffn
-
-string-downcase!
-@c snarfed from srfi-13.c:2427
-@deffn {Scheme Procedure} string-downcase! str [start [end]]
-@deffnx {C Function} scm_substring_downcase_x (str, start, end)
-Destructively downcase every character in @var{str}.
-
-@lisp
-y
-@result{} "ARRDEFG"
-(string-downcase! y)
-@result{} "arrdefg"
-y
-@result{} "arrdefg"
-@end lisp
-@end deffn
-
-string-downcase
-@c snarfed from srfi-13.c:2448
-@deffn {Scheme Procedure} string-downcase str [start [end]]
-@deffnx {C Function} scm_substring_downcase (str, start, end)
-Downcase every character in @var{str}.
-@end deffn
-
-string-titlecase!
-@c snarfed from srfi-13.c:2504
-@deffn {Scheme Procedure} string-titlecase! str [start [end]]
-@deffnx {C Function} scm_string_titlecase_x (str, start, end)
-Destructively titlecase every first character in a word in
-@var{str}.
-@end deffn
-
-string-titlecase
-@c snarfed from srfi-13.c:2520
-@deffn {Scheme Procedure} string-titlecase str [start [end]]
-@deffnx {C Function} scm_string_titlecase (str, start, end)
-Titlecase every first character in a word in @var{str}.
-@end deffn
-
-string-capitalize!
-@c snarfed from srfi-13.c:2542
-@deffn {Scheme Procedure} string-capitalize! str
-@deffnx {C Function} scm_string_capitalize_x (str)
-Upcase the first character of every word in @var{str}
-destructively and return @var{str}.
-
-@lisp
-y @result{} "hello world"
-(string-capitalize! y) @result{} "Hello World"
-y @result{} "Hello World"
-@end lisp
-@end deffn
-
-string-capitalize
-@c snarfed from srfi-13.c:2554
-@deffn {Scheme Procedure} string-capitalize str
-@deffnx {C Function} scm_string_capitalize (str)
-Return a freshly allocated string with the characters in
-@var{str}, where the first character of every word is
-capitalized.
-@end deffn
-
-string-reverse
-@c snarfed from srfi-13.c:2588
-@deffn {Scheme Procedure} string-reverse str [start [end]]
-@deffnx {C Function} scm_string_reverse (str, start, end)
-Reverse the string @var{str}. The optional arguments
-@var{start} and @var{end} delimit the region of @var{str} to
-operate on.
-@end deffn
-
-string-reverse!
-@c snarfed from srfi-13.c:2613
-@deffn {Scheme Procedure} string-reverse! str [start [end]]
-@deffnx {C Function} scm_string_reverse_x (str, start, end)
-Reverse the string @var{str} in-place. The optional arguments
-@var{start} and @var{end} delimit the region of @var{str} to
-operate on. The return value is unspecified.
-@end deffn
-
-string-append/shared
-@c snarfed from srfi-13.c:2635
-@deffn {Scheme Procedure} string-append/shared . rest
-@deffnx {C Function} scm_string_append_shared (rest)
-Like @code{string-append}, but the result may share memory
-with the argument strings.
-@end deffn
-
-string-concatenate
-@c snarfed from srfi-13.c:2656
-@deffn {Scheme Procedure} string-concatenate ls
-@deffnx {C Function} scm_string_concatenate (ls)
-Append the elements of @var{ls} (which must be strings)
-together into a single string. Guaranteed to return a freshly
-allocated string.
-@end deffn
-
-string-concatenate-reverse
-@c snarfed from srfi-13.c:2678
-@deffn {Scheme Procedure} string-concatenate-reverse ls [final_string [end]]
-@deffnx {C Function} scm_string_concatenate_reverse (ls, final_string, end)
-Without optional arguments, this procedure is equivalent to
-
-@smalllisp
-(string-concatenate (reverse ls))
-@end smalllisp
-
-If the optional argument @var{final_string} is specified, it is
-consed onto the beginning to @var{ls} before performing the
-list-reverse and string-concatenate operations. If @var{end}
-is given, only the characters of @var{final_string} up to index
-@var{end} are used.
-
-Guaranteed to return a freshly allocated string.
-@end deffn
-
-string-concatenate/shared
-@c snarfed from srfi-13.c:2695
-@deffn {Scheme Procedure} string-concatenate/shared ls
-@deffnx {C Function} scm_string_concatenate_shared (ls)
-Like @code{string-concatenate}, but the result may share memory
-with the strings in the list @var{ls}.
-@end deffn
-
-string-concatenate-reverse/shared
-@c snarfed from srfi-13.c:2706
-@deffn {Scheme Procedure} string-concatenate-reverse/shared ls [final_string [end]]
-@deffnx {C Function} scm_string_concatenate_reverse_shared (ls, final_string, end)
-Like @code{string-concatenate-reverse}, but the result may
-share memory with the strings in the @var{ls} arguments.
-@end deffn
-
-string-map
-@c snarfed from srfi-13.c:2719
-@deffn {Scheme Procedure} string-map proc s [start [end]]
-@deffnx {C Function} scm_string_map (proc, s, start, end)
-@var{proc} is a char->char procedure, it is mapped over
-@var{s}. The order in which the procedure is applied to the
-string elements is not specified.
-@end deffn
-
-string-map!
-@c snarfed from srfi-13.c:2749
-@deffn {Scheme Procedure} string-map! proc s [start [end]]
-@deffnx {C Function} scm_string_map_x (proc, s, start, end)
-@var{proc} is a char->char procedure, it is mapped over
-@var{s}. The order in which the procedure is applied to the
-string elements is not specified. The string @var{s} is
-modified in-place, the return value is not specified.
-@end deffn
-
-string-fold
-@c snarfed from srfi-13.c:2776
-@deffn {Scheme Procedure} string-fold kons knil s [start [end]]
-@deffnx {C Function} scm_string_fold (kons, knil, s, start, end)
-Fold @var{kons} over the characters of @var{s}, with @var{knil}
-as the terminating element, from left to right. @var{kons}
-must expect two arguments: The actual character and the last
-result of @var{kons}' application.
-@end deffn
-
-string-fold-right
-@c snarfed from srfi-13.c:2807
-@deffn {Scheme Procedure} string-fold-right kons knil s [start [end]]
-@deffnx {C Function} scm_string_fold_right (kons, knil, s, start, end)
-Fold @var{kons} over the characters of @var{s}, with @var{knil}
-as the terminating element, from right to left. @var{kons}
-must expect two arguments: The actual character and the last
-result of @var{kons}' application.
-@end deffn
-
-string-unfold
-@c snarfed from srfi-13.c:2852
-@deffn {Scheme Procedure} string-unfold p f g seed [base [make_final]]
-@deffnx {C Function} scm_string_unfold (p, f, g, seed, base, make_final)
-@itemize @bullet
-@item @var{g} is used to generate a series of @emph{seed}
-values from the initial @var{seed}: @var{seed}, (@var{g}
-@var{seed}), (@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}),
-@dots{}
-@item @var{p} tells us when to stop -- when it returns true
-when applied to one of these seed values.
-@item @var{f} maps each seed value to the corresponding
-character in the result string. These chars are assembled
-into the string in a left-to-right order.
-@item @var{base} is the optional initial/leftmost portion
-of the constructed string; it default to the empty
-string.
-@item @var{make_final} is applied to the terminal seed
-value (on which @var{p} returns true) to produce
-the final/rightmost portion of the constructed string.
-It defaults to @code{(lambda (x) )}.
-@end itemize
-@end deffn
-
-string-unfold-right
-@c snarfed from srfi-13.c:2915
-@deffn {Scheme Procedure} string-unfold-right p f g seed [base [make_final]]
-@deffnx {C Function} scm_string_unfold_right (p, f, g, seed, base, make_final)
-@itemize @bullet
-@item @var{g} is used to generate a series of @emph{seed}
-values from the initial @var{seed}: @var{seed}, (@var{g}
-@var{seed}), (@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}),
-@dots{}
-@item @var{p} tells us when to stop -- when it returns true
-when applied to one of these seed values.
-@item @var{f} maps each seed value to the corresponding
-character in the result string. These chars are assembled
-into the string in a right-to-left order.
-@item @var{base} is the optional initial/rightmost portion
-of the constructed string; it default to the empty
-string.
-@item @var{make_final} is applied to the terminal seed
-value (on which @var{p} returns true) to produce
-the final/leftmost portion of the constructed string.
-It defaults to @code{(lambda (x) )}.
-@end itemize
-@end deffn
-
-string-for-each
-@c snarfed from srfi-13.c:2962
-@deffn {Scheme Procedure} string-for-each proc s [start [end]]
-@deffnx {C Function} scm_string_for_each (proc, s, start, end)
-@var{proc} is mapped over @var{s} in left-to-right order. The
-return value is not specified.
-@end deffn
-
-string-for-each-index
-@c snarfed from srfi-13.c:2988
-@deffn {Scheme Procedure} string-for-each-index proc s [start [end]]
-@deffnx {C Function} scm_string_for_each_index (proc, s, start, end)
-@var{proc} is mapped over @var{s} in left-to-right order. The
-return value is not specified.
-@end deffn
-
-xsubstring
-@c snarfed from srfi-13.c:3020
-@deffn {Scheme Procedure} xsubstring s from [to [start [end]]]
-@deffnx {C Function} scm_xsubstring (s, from, to, start, end)
-This is the @emph{extended substring} procedure that implements
-replicated copying of a substring of some string.
-
-@var{s} is a string, @var{start} and @var{end} are optional
-arguments that demarcate a substring of @var{s}, defaulting to
-0 and the length of @var{s}. Replicate this substring up and
-down index space, in both the positive and negative directions.
-@code{xsubstring} returns the substring of this string
-beginning at index @var{from}, and ending at @var{to}, which
-defaults to @var{from} + (@var{end} - @var{start}).
-@end deffn
-
-string-xcopy!
-@c snarfed from srfi-13.c:3067
-@deffn {Scheme Procedure} string-xcopy! target tstart s sfrom [sto [start [end]]]
-@deffnx {C Function} scm_string_xcopy_x (target, tstart, s, sfrom, sto, start, end)
-Exactly the same as @code{xsubstring}, but the extracted text
-is written into the string @var{target} starting at index
-@var{tstart}. The operation is not defined if @code{(eq?
-@var{target} @var{s})} or these arguments share storage -- you
-cannot copy a string on top of itself.
-@end deffn
-
-string-replace
-@c snarfed from srfi-13.c:3117
-@deffn {Scheme Procedure} string-replace s1 s2 [start1 [end1 [start2 [end2]]]]
-@deffnx {C Function} scm_string_replace (s1, s2, start1, end1, start2, end2)
-Return the string @var{s1}, but with the characters
-@var{start1} @dots{} @var{end1} replaced by the characters
-@var{start2} @dots{} @var{end2} from @var{s2}.
-@end deffn
-
-string-tokenize
-@c snarfed from srfi-13.c:3154
-@deffn {Scheme Procedure} string-tokenize s [token_set [start [end]]]
-@deffnx {C Function} scm_string_tokenize (s, token_set, start, end)
-Split the string @var{s} into a list of substrings, where each
-substring is a maximal non-empty contiguous sequence of
-characters from the character set @var{token_set}, which
-defaults to @code{char-set:graphic}.
-If @var{start} or @var{end} indices are provided, they restrict
-@code{string-tokenize} to operating on the indicated substring
-of @var{s}.
-@end deffn
-
-string-split
-@c snarfed from srfi-13.c:3220
-@deffn {Scheme Procedure} string-split str chr
-@deffnx {C Function} scm_string_split (str, chr)
-Split the string @var{str} into the a list of the substrings delimited
-by appearances of the character @var{chr}. Note that an empty substring
-between separator characters will result in an empty string in the
-result list.
-
-@lisp
-(string-split "root:x:0:0:root:/root:/bin/bash" #\:)
-@result{}
-("root" "x" "0" "0" "root" "/root" "/bin/bash")
-
-(string-split "::" #\:)
-@result{}
-("" "" "")
-
-(string-split "" #\:)
-@result{}
-("")
-@end lisp
-@end deffn
-
-string-filter
-@c snarfed from srfi-13.c:3258
-@deffn {Scheme Procedure} string-filter s char_pred [start [end]]
-@deffnx {C Function} scm_string_filter (s, char_pred, start, end)
-Filter the string @var{s}, retaining only those characters that
-satisfy the @var{char_pred} argument. If the argument is a
-procedure, it is applied to each character as a predicate, if
-it is a character, it is tested for equality and if it is a
-character set, it is tested for membership.
-@end deffn
-
-string-delete
-@c snarfed from srfi-13.c:3330
-@deffn {Scheme Procedure} string-delete s char_pred [start [end]]
-@deffnx {C Function} scm_string_delete (s, char_pred, start, end)
-Filter the string @var{s}, retaining only those characters that
-do not satisfy the @var{char_pred} argument. If the argument
-is a procedure, it is applied to each character as a predicate,
-if it is a character, it is tested for equality and if it is a
-character set, it is tested for membership.
-@end deffn
-
-char-set?
-@c snarfed from srfi-14.c:85
-@deffn {Scheme Procedure} char-set? obj
-@deffnx {C Function} scm_char_set_p (obj)
-Return @code{#t} if @var{obj} is a character set, @code{#f}
-otherwise.
-@end deffn
-
-char-set=
-@c snarfed from srfi-14.c:95
-@deffn {Scheme Procedure} char-set= . char_sets
-@deffnx {C Function} scm_char_set_eq (char_sets)
-Return @code{#t} if all given character sets are equal.
-@end deffn
-
-char-set<=
-@c snarfed from srfi-14.c:125
-@deffn {Scheme Procedure} char-set<= . char_sets
-@deffnx {C Function} scm_char_set_leq (char_sets)
-Return @code{#t} if every character set @var{cs}i is a subset
-of character set @var{cs}i+1.
-@end deffn
-
-char-set-hash
-@c snarfed from srfi-14.c:163
-@deffn {Scheme Procedure} char-set-hash cs [bound]
-@deffnx {C Function} scm_char_set_hash (cs, bound)
-Compute a hash value for the character set @var{cs}. If
-@var{bound} is given and non-zero, it restricts the
-returned value to the range 0 @dots{} @var{bound - 1}.
-@end deffn
-
-char-set-cursor
-@c snarfed from srfi-14.c:196
-@deffn {Scheme Procedure} char-set-cursor cs
-@deffnx {C Function} scm_char_set_cursor (cs)
-Return a cursor into the character set @var{cs}.
-@end deffn
-
-char-set-ref
-@c snarfed from srfi-14.c:216
-@deffn {Scheme Procedure} char-set-ref cs cursor
-@deffnx {C Function} scm_char_set_ref (cs, cursor)
-Return the character at the current cursor position
-@var{cursor} in the character set @var{cs}. It is an error to
-pass a cursor for which @code{end-of-char-set?} returns true.
-@end deffn
-
-char-set-cursor-next
-@c snarfed from srfi-14.c:233
-@deffn {Scheme Procedure} char-set-cursor-next cs cursor
-@deffnx {C Function} scm_char_set_cursor_next (cs, cursor)
-Advance the character set cursor @var{cursor} to the next
-character in the character set @var{cs}. It is an error if the
-cursor given satisfies @code{end-of-char-set?}.
-@end deffn
-
-end-of-char-set?
-@c snarfed from srfi-14.c:254
-@deffn {Scheme Procedure} end-of-char-set? cursor
-@deffnx {C Function} scm_end_of_char_set_p (cursor)
-Return @code{#t} if @var{cursor} has reached the end of a
-character set, @code{#f} otherwise.
-@end deffn
-
-char-set-fold
-@c snarfed from srfi-14.c:266
-@deffn {Scheme Procedure} char-set-fold kons knil cs
-@deffnx {C Function} scm_char_set_fold (kons, knil, cs)
-Fold the procedure @var{kons} over the character set @var{cs},
-initializing it with @var{knil}.
-@end deffn
-
-char-set-unfold
-@c snarfed from srfi-14.c:296
-@deffn {Scheme Procedure} char-set-unfold p f g seed [base_cs]
-@deffnx {C Function} scm_char_set_unfold (p, f, g, seed, base_cs)
-This is a fundamental constructor for character sets.
-@itemize @bullet
-@item @var{g} is used to generate a series of ``seed'' values
-from the initial seed: @var{seed}, (@var{g} @var{seed}),
-(@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}), @dots{}
-@item @var{p} tells us when to stop -- when it returns true
-when applied to one of the seed values.
-@item @var{f} maps each seed value to a character. These
-characters are added to the base character set @var{base_cs} to
-form the result; @var{base_cs} defaults to the empty set.
-@end itemize
-@end deffn
-
-char-set-unfold!
-@c snarfed from srfi-14.c:340
-@deffn {Scheme Procedure} char-set-unfold! p f g seed base_cs
-@deffnx {C Function} scm_char_set_unfold_x (p, f, g, seed, base_cs)
-This is a fundamental constructor for character sets.
-@itemize @bullet
-@item @var{g} is used to generate a series of ``seed'' values
-from the initial seed: @var{seed}, (@var{g} @var{seed}),
-(@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}), @dots{}
-@item @var{p} tells us when to stop -- when it returns true
-when applied to one of the seed values.
-@item @var{f} maps each seed value to a character. These
-characters are added to the base character set @var{base_cs} to
-form the result; @var{base_cs} defaults to the empty set.
-@end itemize
-@end deffn
-
-char-set-for-each
-@c snarfed from srfi-14.c:369
-@deffn {Scheme Procedure} char-set-for-each proc cs
-@deffnx {C Function} scm_char_set_for_each (proc, cs)
-Apply @var{proc} to every character in the character set
-@var{cs}. The return value is not specified.
-@end deffn
-
-char-set-map
-@c snarfed from srfi-14.c:388
-@deffn {Scheme Procedure} char-set-map proc cs
-@deffnx {C Function} scm_char_set_map (proc, cs)
-Map the procedure @var{proc} over every character in @var{cs}.
-@var{proc} must be a character -> character procedure.
-@end deffn
-
-char-set-copy
-@c snarfed from srfi-14.c:414
-@deffn {Scheme Procedure} char-set-copy cs
-@deffnx {C Function} scm_char_set_copy (cs)
-Return a newly allocated character set containing all
-characters in @var{cs}.
-@end deffn
-
-char-set
-@c snarfed from srfi-14.c:434
-@deffn {Scheme Procedure} char-set . rest
-@deffnx {C Function} scm_char_set (rest)
-Return a character set containing all given characters.
-@end deffn
-
-list->char-set
-@c snarfed from srfi-14.c:462
-@deffn {Scheme Procedure} list->char-set list [base_cs]
-@deffnx {C Function} scm_list_to_char_set (list, base_cs)
-Convert the character list @var{list} to a character set. If
-the character set @var{base_cs} is given, the character in this
-set are also included in the result.
-@end deffn
-
-list->char-set!
-@c snarfed from srfi-14.c:496
-@deffn {Scheme Procedure} list->char-set! list base_cs
-@deffnx {C Function} scm_list_to_char_set_x (list, base_cs)
-Convert the character list @var{list} to a character set. The
-characters are added to @var{base_cs} and @var{base_cs} is
-returned.
-@end deffn
-
-string->char-set
-@c snarfed from srfi-14.c:523
-@deffn {Scheme Procedure} string->char-set str [base_cs]
-@deffnx {C Function} scm_string_to_char_set (str, base_cs)
-Convert the string @var{str} to a character set. If the
-character set @var{base_cs} is given, the characters in this
-set are also included in the result.
-@end deffn
-
-string->char-set!
-@c snarfed from srfi-14.c:557
-@deffn {Scheme Procedure} string->char-set! str base_cs
-@deffnx {C Function} scm_string_to_char_set_x (str, base_cs)
-Convert the string @var{str} to a character set. The
-characters from the string are added to @var{base_cs}, and
-@var{base_cs} is returned.
-@end deffn
-
-char-set-filter
-@c snarfed from srfi-14.c:584
-@deffn {Scheme Procedure} char-set-filter pred cs [base_cs]
-@deffnx {C Function} scm_char_set_filter (pred, cs, base_cs)
-Return a character set containing every character from @var{cs}
-so that it satisfies @var{pred}. If provided, the characters
-from @var{base_cs} are added to the result.
-@end deffn
-
-char-set-filter!
-@c snarfed from srfi-14.c:620
-@deffn {Scheme Procedure} char-set-filter! pred cs base_cs
-@deffnx {C Function} scm_char_set_filter_x (pred, cs, base_cs)
-Return a character set containing every character from @var{cs}
-so that it satisfies @var{pred}. The characters are added to
-@var{base_cs} and @var{base_cs} is returned.
-@end deffn
-
-ucs-range->char-set
-@c snarfed from srfi-14.c:658
-@deffn {Scheme Procedure} ucs-range->char-set lower upper [error [base_cs]]
-@deffnx {C Function} scm_ucs_range_to_char_set (lower, upper, error, base_cs)
-Return a character set containing all characters whose
-character codes lie in the half-open range
-[@var{lower},@var{upper}).
-
-If @var{error} is a true value, an error is signalled if the
-specified range contains characters which are not contained in
-the implemented character range. If @var{error} is @code{#f},
-these characters are silently left out of the resultung
-character set.
-
-The characters in @var{base_cs} are added to the result, if
-given.
-@end deffn
-
-ucs-range->char-set!
-@c snarfed from srfi-14.c:711
-@deffn {Scheme Procedure} ucs-range->char-set! lower upper error base_cs
-@deffnx {C Function} scm_ucs_range_to_char_set_x (lower, upper, error, base_cs)
-Return a character set containing all characters whose
-character codes lie in the half-open range
-[@var{lower},@var{upper}).
-
-If @var{error} is a true value, an error is signalled if the
-specified range contains characters which are not contained in
-the implemented character range. If @var{error} is @code{#f},
-these characters are silently left out of the resultung
-character set.
-
-The characters are added to @var{base_cs} and @var{base_cs} is
-returned.
-@end deffn
-
-->char-set
-@c snarfed from srfi-14.c:741
-@deffn {Scheme Procedure} ->char-set x
-@deffnx {C Function} scm_to_char_set (x)
-Coerces x into a char-set. @var{x} may be a string, character or char-set. A string is converted to the set of its constituent characters; a character is converted to a singleton set; a char-set is returned as-is.
-@end deffn
-
-char-set-size
-@c snarfed from srfi-14.c:757
-@deffn {Scheme Procedure} char-set-size cs
-@deffnx {C Function} scm_char_set_size (cs)
-Return the number of elements in character set @var{cs}.
-@end deffn
-
-char-set-count
-@c snarfed from srfi-14.c:774
-@deffn {Scheme Procedure} char-set-count pred cs
-@deffnx {C Function} scm_char_set_count (pred, cs)
-Return the number of the elements int the character set
-@var{cs} which satisfy the predicate @var{pred}.
-@end deffn
-
-char-set->list
-@c snarfed from srfi-14.c:797
-@deffn {Scheme Procedure} char-set->list cs
-@deffnx {C Function} scm_char_set_to_list (cs)
-Return a list containing the elements of the character set
-@var{cs}.
-@end deffn
-
-char-set->string
-@c snarfed from srfi-14.c:816
-@deffn {Scheme Procedure} char-set->string cs
-@deffnx {C Function} scm_char_set_to_string (cs)
-Return a string containing the elements of the character set
-@var{cs}. The order in which the characters are placed in the
-string is not defined.
-@end deffn
-
-char-set-contains?
-@c snarfed from srfi-14.c:841
-@deffn {Scheme Procedure} char-set-contains? cs ch
-@deffnx {C Function} scm_char_set_contains_p (cs, ch)
-Return @code{#t} iff the character @var{ch} is contained in the
-character set @var{cs}.
-@end deffn
-
-char-set-every
-@c snarfed from srfi-14.c:854
-@deffn {Scheme Procedure} char-set-every pred cs
-@deffnx {C Function} scm_char_set_every (pred, cs)
-Return a true value if every character in the character set
-@var{cs} satisfies the predicate @var{pred}.
-@end deffn
-
-char-set-any
-@c snarfed from srfi-14.c:878
-@deffn {Scheme Procedure} char-set-any pred cs
-@deffnx {C Function} scm_char_set_any (pred, cs)
-Return a true value if any character in the character set
-@var{cs} satisfies the predicate @var{pred}.
-@end deffn
-
-char-set-adjoin
-@c snarfed from srfi-14.c:901
-@deffn {Scheme Procedure} char-set-adjoin cs . rest
-@deffnx {C Function} scm_char_set_adjoin (cs, rest)
-Add all character arguments to the first argument, which must
-be a character set.
-@end deffn
-
-char-set-delete
-@c snarfed from srfi-14.c:929
-@deffn {Scheme Procedure} char-set-delete cs . rest
-@deffnx {C Function} scm_char_set_delete (cs, rest)
-Delete all character arguments from the first argument, which
-must be a character set.
-@end deffn
-
-char-set-adjoin!
-@c snarfed from srfi-14.c:957
-@deffn {Scheme Procedure} char-set-adjoin! cs . rest
-@deffnx {C Function} scm_char_set_adjoin_x (cs, rest)
-Add all character arguments to the first argument, which must
-be a character set.
-@end deffn
-
-char-set-delete!
-@c snarfed from srfi-14.c:984
-@deffn {Scheme Procedure} char-set-delete! cs . rest
-@deffnx {C Function} scm_char_set_delete_x (cs, rest)
-Delete all character arguments from the first argument, which
-must be a character set.
-@end deffn
-
-char-set-complement
-@c snarfed from srfi-14.c:1010
-@deffn {Scheme Procedure} char-set-complement cs
-@deffnx {C Function} scm_char_set_complement (cs)
-Return the complement of the character set @var{cs}.
-@end deffn
-
-char-set-union
-@c snarfed from srfi-14.c:1031
-@deffn {Scheme Procedure} char-set-union . rest
-@deffnx {C Function} scm_char_set_union (rest)
-Return the union of all argument character sets.
-@end deffn
-
-char-set-intersection
-@c snarfed from srfi-14.c:1060
-@deffn {Scheme Procedure} char-set-intersection . rest
-@deffnx {C Function} scm_char_set_intersection (rest)
-Return the intersection of all argument character sets.
-@end deffn
-
-char-set-difference
-@c snarfed from srfi-14.c:1100
-@deffn {Scheme Procedure} char-set-difference cs1 . rest
-@deffnx {C Function} scm_char_set_difference (cs1, rest)
-Return the difference of all argument character sets.
-@end deffn
-
-char-set-xor
-@c snarfed from srfi-14.c:1130
-@deffn {Scheme Procedure} char-set-xor . rest
-@deffnx {C Function} scm_char_set_xor (rest)
-Return the exclusive-or of all argument character sets.
-@end deffn
-
-char-set-diff+intersection
-@c snarfed from srfi-14.c:1171
-@deffn {Scheme Procedure} char-set-diff+intersection cs1 . rest
-@deffnx {C Function} scm_char_set_diff_plus_intersection (cs1, rest)
-Return the difference and the intersection of all argument
-character sets.
-@end deffn
-
-char-set-complement!
-@c snarfed from srfi-14.c:1209
-@deffn {Scheme Procedure} char-set-complement! cs
-@deffnx {C Function} scm_char_set_complement_x (cs)
-Return the complement of the character set @var{cs}.
-@end deffn
-
-char-set-union!
-@c snarfed from srfi-14.c:1226
-@deffn {Scheme Procedure} char-set-union! cs1 . rest
-@deffnx {C Function} scm_char_set_union_x (cs1, rest)
-Return the union of all argument character sets.
-@end deffn
-
-char-set-intersection!
-@c snarfed from srfi-14.c:1254
-@deffn {Scheme Procedure} char-set-intersection! cs1 . rest
-@deffnx {C Function} scm_char_set_intersection_x (cs1, rest)
-Return the intersection of all argument character sets.
-@end deffn
-
-char-set-difference!
-@c snarfed from srfi-14.c:1282
-@deffn {Scheme Procedure} char-set-difference! cs1 . rest
-@deffnx {C Function} scm_char_set_difference_x (cs1, rest)
-Return the difference of all argument character sets.
-@end deffn
-
-char-set-xor!
-@c snarfed from srfi-14.c:1310
-@deffn {Scheme Procedure} char-set-xor! cs1 . rest
-@deffnx {C Function} scm_char_set_xor_x (cs1, rest)
-Return the exclusive-or of all argument character sets.
-@end deffn
-
-char-set-diff+intersection!
-@c snarfed from srfi-14.c:1349
-@deffn {Scheme Procedure} char-set-diff+intersection! cs1 cs2 . rest
-@deffnx {C Function} scm_char_set_diff_plus_intersection_x (cs1, cs2, rest)
-Return the difference and the intersection of all argument
-character sets.
-@end deffn
-
-string=?
-@c snarfed from strorder.c:50
-@deffn {Scheme Procedure} string=? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_equal_p (s1, s2, rest)
-Lexicographic equality predicate; return @code{#t} if the two
-strings are the same length and contain the same characters in
-the same positions, otherwise return @code{#f}.
-
-The procedure @code{string-ci=?} treats upper and lower case
-letters as though they were the same character, but
-@code{string=?} treats upper and lower case as distinct
-characters.
-@end deffn
-
-string-ci=?
-@c snarfed from strorder.c:62
-@deffn {Scheme Procedure} string-ci=? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_ci_equal_p (s1, s2, rest)
-Case-insensitive string equality predicate; return @code{#t} if
-the two strings are the same length and their component
-characters match (ignoring case) at each position; otherwise
-return @code{#f}.
-@end deffn
-
-string
-@c snarfed from strorder.c:72
-@deffn {Scheme Procedure} string [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_less_p (s1, s2, rest)
-Lexicographic ordering predicate; return @code{#t} if @var{s1}
-is lexicographically less than @var{s2}.
-@end deffn
-
-string<=?
-@c snarfed from strorder.c:82
-@deffn {Scheme Procedure} string<=? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_leq_p (s1, s2, rest)
-Lexicographic ordering predicate; return @code{#t} if @var{s1}
-is lexicographically less than or equal to @var{s2}.
-@end deffn
-
-string>?
-@c snarfed from strorder.c:92
-@deffn {Scheme Procedure} string>? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_gr_p (s1, s2, rest)
-Lexicographic ordering predicate; return @code{#t} if @var{s1}
-is lexicographically greater than @var{s2}.
-@end deffn
-
-string>=?
-@c snarfed from strorder.c:102
-@deffn {Scheme Procedure} string>=? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_geq_p (s1, s2, rest)
-Lexicographic ordering predicate; return @code{#t} if @var{s1}
-is lexicographically greater than or equal to @var{s2}.
-@end deffn
-
-string-ci
-@c snarfed from strorder.c:113
-@deffn {Scheme Procedure} string-ci [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_ci_less_p (s1, s2, rest)
-Case insensitive lexicographic ordering predicate; return
-@code{#t} if @var{s1} is lexicographically less than @var{s2}
-regardless of case.
-@end deffn
-
-string-ci<=?
-@c snarfed from strorder.c:124
-@deffn {Scheme Procedure} string-ci<=? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_ci_leq_p (s1, s2, rest)
-Case insensitive lexicographic ordering predicate; return
-@code{#t} if @var{s1} is lexicographically less than or equal
-to @var{s2} regardless of case.
-@end deffn
-
-string-ci>?
-@c snarfed from strorder.c:135
-@deffn {Scheme Procedure} string-ci>? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_ci_gr_p (s1, s2, rest)
-Case insensitive lexicographic ordering predicate; return
-@code{#t} if @var{s1} is lexicographically greater than
-@var{s2} regardless of case.
-@end deffn
-
-string-ci>=?
-@c snarfed from strorder.c:146
-@deffn {Scheme Procedure} string-ci>=? [s1 [s2 . rest]]
-@deffnx {C Function} scm_i_string_ci_geq_p (s1, s2, rest)
-Case insensitive lexicographic ordering predicate; return
-@code{#t} if @var{s1} is lexicographically greater than or
-equal to @var{s2} regardless of case.
-@end deffn
-
-object->string
-@c snarfed from strports.c:332
-@deffn {Scheme Procedure} object->string obj [printer]
-@deffnx {C Function} scm_object_to_string (obj, printer)
-Return a Scheme string obtained by printing @var{obj}.
-Printing function can be specified by the optional second
-argument @var{printer} (default: @code{write}).
-@end deffn
-
-call-with-output-string
-@c snarfed from strports.c:356
-@deffn {Scheme Procedure} call-with-output-string proc
-@deffnx {C Function} scm_call_with_output_string (proc)
-Calls the one-argument procedure @var{proc} with a newly created output
-port. When the function returns, the string composed of the characters
-written into the port is returned.
-@end deffn
-
-call-with-input-string
-@c snarfed from strports.c:375
-@deffn {Scheme Procedure} call-with-input-string string proc
-@deffnx {C Function} scm_call_with_input_string (string, proc)
-Calls the one-argument procedure @var{proc} with a newly
-created input port from which @var{string}'s contents may be
-read. The value yielded by the @var{proc} is returned.
-@end deffn
-
-open-input-string
-@c snarfed from strports.c:388
-@deffn {Scheme Procedure} open-input-string str
-@deffnx {C Function} scm_open_input_string (str)
-Take a string and return an input port that delivers characters
-from the string. The port can be closed by
-@code{close-input-port}, though its storage will be reclaimed
-by the garbage collector if it becomes inaccessible.
-@end deffn
-
-open-output-string
-@c snarfed from strports.c:402
-@deffn {Scheme Procedure} open-output-string
-@deffnx {C Function} scm_open_output_string ()
-Return an output port that will accumulate characters for
-retrieval by @code{get-output-string}. The port can be closed
-by the procedure @code{close-output-port}, though its storage
-will be reclaimed by the garbage collector if it becomes
-inaccessible.
-@end deffn
-
-get-output-string
-@c snarfed from strports.c:419
-@deffn {Scheme Procedure} get-output-string port
-@deffnx {C Function} scm_get_output_string (port)
-Given an output port created by @code{open-output-string},
-return a string consisting of the characters that have been
-output to the port so far.
-@end deffn
-
-eval-string
-@c snarfed from strports.c:488
-@deffn {Scheme Procedure} eval-string string [module]
-@deffnx {C Function} scm_eval_string_in_module (string, module)
-Evaluate @var{string} as the text representation of a Scheme
-form or forms, and return whatever value they produce.
-Evaluation takes place in the given module, or the current
-module when no module is given.
-While the code is evaluated, the given module is made the
-current one. The current module is restored when this
-procedure returns.
-@end deffn
-
-make-struct-layout
-@c snarfed from struct.c:56
-@deffn {Scheme Procedure} make-struct-layout fields
-@deffnx {C Function} scm_make_struct_layout (fields)
-Return a new structure layout object.
-
-@var{fields} must be a string made up of pairs of characters
-strung together. The first character of each pair describes a field
-type, the second a field protection. Allowed types are 'p' for
-GC-protected Scheme data, 'u' for unprotected binary data, and 's' for
-a field that points to the structure itself. Allowed protections
-are 'w' for mutable fields, 'r' for read-only fields, and 'o' for opaque
-fields. The last field protection specification may be capitalized to
-indicate that the field is a tail-array.
-@end deffn
-
-struct?
-@c snarfed from struct.c:223
-@deffn {Scheme Procedure} struct? x
-@deffnx {C Function} scm_struct_p (x)
-Return @code{#t} iff @var{x} is a structure object, else
-@code{#f}.
-@end deffn
-
-struct-vtable?
-@c snarfed from struct.c:232
-@deffn {Scheme Procedure} struct-vtable? x
-@deffnx {C Function} scm_struct_vtable_p (x)
-Return @code{#t} iff @var{x} is a vtable structure.
-@end deffn
-
-make-struct
-@c snarfed from struct.c:418
-@deffn {Scheme Procedure} make-struct vtable tail_array_size . init
-@deffnx {C Function} scm_make_struct (vtable, tail_array_size, init)
-Create a new structure.
-
-@var{type} must be a vtable structure (@pxref{Vtables}).
-
-@var{tail-elts} must be a non-negative integer. If the layout
-specification indicated by @var{type} includes a tail-array,
-this is the number of elements allocated to that array.
-
-The @var{init1}, @dots{} are optional arguments describing how
-successive fields of the structure should be initialized. Only fields
-with protection 'r' or 'w' can be initialized, except for fields of
-type 's', which are automatically initialized to point to the new
-structure itself; fields with protection 'o' can not be initialized by
-Scheme programs.
-
-If fewer optional arguments than initializable fields are supplied,
-fields of type 'p' get default value #f while fields of type 'u' are
-initialized to 0.
-
-Structs are currently the basic representation for record-like data
-structures in Guile. The plan is to eventually replace them with a
-new representation which will at the same time be easier to use and
-more powerful.
-
-For more information, see the documentation for @code{make-vtable-vtable}.
-@end deffn
-
-make-vtable-vtable
-@c snarfed from struct.c:502
-@deffn {Scheme Procedure} make-vtable-vtable user_fields tail_array_size . init
-@deffnx {C Function} scm_make_vtable_vtable (user_fields, tail_array_size, init)
-Return a new, self-describing vtable structure.
-
-@var{user-fields} is a string describing user defined fields of the
-vtable beginning at index @code{vtable-offset-user}
-(see @code{make-struct-layout}).
-
-@var{tail-size} specifies the size of the tail-array (if any) of
-this vtable.
-
-@var{init1}, @dots{} are the optional initializers for the fields of
-the vtable.
-
-Vtables have one initializable system field---the struct printer.
-This field comes before the user fields in the initializers passed
-to @code{make-vtable-vtable} and @code{make-struct}, and thus works as
-a third optional argument to @code{make-vtable-vtable} and a fourth to
-@code{make-struct} when creating vtables:
-
-If the value is a procedure, it will be called instead of the standard
-printer whenever a struct described by this vtable is printed.
-The procedure will be called with arguments STRUCT and PORT.
-
-The structure of a struct is described by a vtable, so the vtable is
-in essence the type of the struct. The vtable is itself a struct with
-a vtable. This could go on forever if it weren't for the
-vtable-vtables which are self-describing vtables, and thus terminate
-the chain.
-
-There are several potential ways of using structs, but the standard
-one is to use three kinds of structs, together building up a type
-sub-system: one vtable-vtable working as the root and one or several
-"types", each with a set of "instances". (The vtable-vtable should be
-compared to the class which is the class of itself.)
-
-@lisp
-(define ball-root (make-vtable-vtable "pr" 0))
-
-(define (make-ball-type ball-color)
- (make-struct ball-root 0
- (make-struct-layout "pw")
- (lambda (ball port)
- (format port "#"
- (color ball)
- (owner ball)))
- ball-color))
-(define (color ball) (struct-ref (struct-vtable ball) vtable-offset-user))
-(define (owner ball) (struct-ref ball 0))
-
-(define red (make-ball-type 'red))
-(define green (make-ball-type 'green))
-
-(define (make-ball type owner) (make-struct type 0 owner))
-
-(define ball (make-ball green 'Nisse))
-ball @result{} #
-@end lisp
-@end deffn
-
-struct-ref
-@c snarfed from struct.c:542
-@deffn {Scheme Procedure} struct-ref handle pos
-@deffnx {Scheme Procedure} struct-set! struct n value
-@deffnx {C Function} scm_struct_ref (handle, pos)
-Access (or modify) the @var{n}th field of @var{struct}.
-
-If the field is of type 'p', then it can be set to an arbitrary value.
-
-If the field is of type 'u', then it can only be set to a non-negative
-integer value small enough to fit in one machine word.
-@end deffn
-
-struct-set!
-@c snarfed from struct.c:621
-@deffn {Scheme Procedure} struct-set! handle pos val
-@deffnx {C Function} scm_struct_set_x (handle, pos, val)
-Set the slot of the structure @var{handle} with index @var{pos}
-to @var{val}. Signal an error if the slot can not be written
-to.
-@end deffn
-
-struct-vtable
-@c snarfed from struct.c:692
-@deffn {Scheme Procedure} struct-vtable handle
-@deffnx {C Function} scm_struct_vtable (handle)
-Return the vtable structure that describes the type of @var{struct}.
-@end deffn
-
-struct-vtable-tag
-@c snarfed from struct.c:703
-@deffn {Scheme Procedure} struct-vtable-tag handle
-@deffnx {C Function} scm_struct_vtable_tag (handle)
-Return the vtable tag of the structure @var{handle}.
-@end deffn
-
-struct-vtable-name
-@c snarfed from struct.c:742
-@deffn {Scheme Procedure} struct-vtable-name vtable
-@deffnx {C Function} scm_struct_vtable_name (vtable)
-Return the name of the vtable @var{vtable}.
-@end deffn
-
-set-struct-vtable-name!
-@c snarfed from struct.c:752
-@deffn {Scheme Procedure} set-struct-vtable-name! vtable name
-@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name)
-Set the name of the vtable @var{vtable} to @var{name}.
-@end deffn
-
-symbol?
-@c snarfed from symbols.c:156
-@deffn {Scheme Procedure} symbol? obj
-@deffnx {C Function} scm_symbol_p (obj)
-Return @code{#t} if @var{obj} is a symbol, otherwise return
-@code{#f}.
-@end deffn
-
-symbol-interned?
-@c snarfed from symbols.c:166
-@deffn {Scheme Procedure} symbol-interned? symbol
-@deffnx {C Function} scm_symbol_interned_p (symbol)
-Return @code{#t} if @var{symbol} is interned, otherwise return
-@code{#f}.
-@end deffn
-
-make-symbol
-@c snarfed from symbols.c:178
-@deffn {Scheme Procedure} make-symbol name
-@deffnx {C Function} scm_make_symbol (name)
-Return a new uninterned symbol with the name @var{name}. The returned symbol is guaranteed to be unique and future calls to @code{string->symbol} will not return it.
-@end deffn
-
-symbol->string
-@c snarfed from symbols.c:210
-@deffn {Scheme Procedure} symbol->string s
-@deffnx {C Function} scm_symbol_to_string (s)
-Return the name of @var{symbol} as a string. If the symbol was
-part of an object returned as the value of a literal expression
-(section @pxref{Literal expressions,,,r5rs, The Revised^5
-Report on Scheme}) or by a call to the @code{read} procedure,
-and its name contains alphabetic characters, then the string
-returned will contain characters in the implementation's
-preferred standard case---some implementations will prefer
-upper case, others lower case. If the symbol was returned by
-@code{string->symbol}, the case of characters in the string
-returned will be the same as the case in the string that was
-passed to @code{string->symbol}. It is an error to apply
-mutation procedures like @code{string-set!} to strings returned
-by this procedure.
-
-The following examples assume that the implementation's
-standard case is lower case:
-
-@lisp
-(symbol->string 'flying-fish) @result{} "flying-fish"
-(symbol->string 'Martin) @result{} "martin"
-(symbol->string
- (string->symbol "Malvina")) @result{} "Malvina"
-@end lisp
-@end deffn
-
-string->symbol
-@c snarfed from symbols.c:240
-@deffn {Scheme Procedure} string->symbol string
-@deffnx {C Function} scm_string_to_symbol (string)
-Return the symbol whose name is @var{string}. This procedure
-can create symbols with names containing special characters or
-letters in the non-standard case, but it is usually a bad idea
-to create such symbols because in some implementations of
-Scheme they cannot be read as themselves. See
-@code{symbol->string}.
-
-The following examples assume that the implementation's
-standard case is lower case:
-
-@lisp
-(eq? 'mISSISSIppi 'mississippi) @result{} #t
-(string->symbol "mISSISSIppi") @result{} @r{the symbol with name "mISSISSIppi"}
-(eq? 'bitBlt (string->symbol "bitBlt")) @result{} #f
-(eq? 'JollyWog
- (string->symbol (symbol->string 'JollyWog))) @result{} #t
-(string=? "K. Harper, M.D."
- (symbol->string
- (string->symbol "K. Harper, M.D."))) @result{}#t
-@end lisp
-@end deffn
-
-string-ci->symbol
-@c snarfed from symbols.c:252
-@deffn {Scheme Procedure} string-ci->symbol str
-@deffnx {C Function} scm_string_ci_to_symbol (str)
-Return the symbol whose name is @var{str}. @var{str} is
-converted to lowercase before the conversion is done, if Guile
-is currently reading symbols case-insensitively.
-@end deffn
-
-gensym
-@c snarfed from symbols.c:269
-@deffn {Scheme Procedure} gensym [prefix]
-@deffnx {C Function} scm_gensym (prefix)
-Create a new symbol with a name constructed from a prefix and
-a counter value. The string @var{prefix} can be specified as
-an optional argument. Default prefix is @code{ g}. The counter
-is increased by 1 at each call. There is no provision for
-resetting the counter.
-@end deffn
-
-symbol-hash
-@c snarfed from symbols.c:295
-@deffn {Scheme Procedure} symbol-hash symbol
-@deffnx {C Function} scm_symbol_hash (symbol)
-Return a hash value for @var{symbol}.
-@end deffn
-
-symbol-fref
-@c snarfed from symbols.c:305
-@deffn {Scheme Procedure} symbol-fref s
-@deffnx {C Function} scm_symbol_fref (s)
-Return the contents of @var{symbol}'s @dfn{function slot}.
-@end deffn
-
-symbol-pref
-@c snarfed from symbols.c:316
-@deffn {Scheme Procedure} symbol-pref s
-@deffnx {C Function} scm_symbol_pref (s)
-Return the @dfn{property list} currently associated with @var{symbol}.
-@end deffn
-
-symbol-fset!
-@c snarfed from symbols.c:327
-@deffn {Scheme Procedure} symbol-fset! s val
-@deffnx {C Function} scm_symbol_fset_x (s, val)
-Change the binding of @var{symbol}'s function slot.
-@end deffn
-
-symbol-pset!
-@c snarfed from symbols.c:339
-@deffn {Scheme Procedure} symbol-pset! s val
-@deffnx {C Function} scm_symbol_pset_x (s, val)
-Change the binding of @var{symbol}'s property slot.
-@end deffn
-
-call-with-new-thread
-@c snarfed from threads.c:611
-@deffn {Scheme Procedure} call-with-new-thread thunk [handler]
-@deffnx {C Function} scm_call_with_new_thread (thunk, handler)
-Call @code{thunk} in a new thread and with a new dynamic state,
-returning a new thread object representing the thread. The procedure
-@var{thunk} is called via @code{with-continuation-barrier}.
-
-When @var{handler} is specified, then @var{thunk} is called from
-within a @code{catch} with tag @code{#t} that has @var{handler} as its
-handler. This catch is established inside the continuation barrier.
-
-Once @var{thunk} or @var{handler} returns, the return value is made
-the @emph{exit value} of the thread and the thread is terminated.
-@end deffn
-
-yield
-@c snarfed from threads.c:722
-@deffn {Scheme Procedure} yield
-@deffnx {C Function} scm_yield ()
-Move the calling thread to the end of the scheduling queue.
-@end deffn
-
-join-thread
-@c snarfed from threads.c:732
-@deffn {Scheme Procedure} join-thread thread
-@deffnx {C Function} scm_join_thread (thread)
-Suspend execution of the calling thread until the target @var{thread} terminates, unless the target @var{thread} has already terminated.
-@end deffn
-
-make-mutex
-@c snarfed from threads.c:828
-@deffn {Scheme Procedure} make-mutex
-@deffnx {C Function} scm_make_mutex ()
-Create a new mutex.
-@end deffn
-
-make-recursive-mutex
-@c snarfed from threads.c:837
-@deffn {Scheme Procedure} make-recursive-mutex
-@deffnx {C Function} scm_make_recursive_mutex ()
-Create a new recursive mutex.
-@end deffn
-
-lock-mutex
-@c snarfed from threads.c:883
-@deffn {Scheme Procedure} lock-mutex mx
-@deffnx {C Function} scm_lock_mutex (mx)
-Lock @var{mutex}. If the mutex is already locked, the calling thread blocks until the mutex becomes available. The function returns when the calling thread owns the lock on @var{mutex}. Locking a mutex that a thread already owns will succeed right away and will not block the thread. That is, Guile's mutexes are @emph{recursive}.
-@end deffn
-
-try-mutex
-@c snarfed from threads.c:931
-@deffn {Scheme Procedure} try-mutex mutex
-@deffnx {C Function} scm_try_mutex (mutex)
-Try to lock @var{mutex}. If the mutex is already locked by someone else, return @code{#f}. Else lock the mutex and return @code{#t}.
-@end deffn
-
-unlock-mutex
-@c snarfed from threads.c:976
-@deffn {Scheme Procedure} unlock-mutex mx
-@deffnx {C Function} scm_unlock_mutex (mx)
-Unlocks @var{mutex} if the calling thread owns the lock on @var{mutex}. Calling unlock-mutex on a mutex not owned by the current thread results in undefined behaviour. Once a mutex has been unlocked, one thread blocked on @var{mutex} is awakened and grabs the mutex lock. Every call to @code{lock-mutex} by this thread must be matched with a call to @code{unlock-mutex}. Only the last call to @code{unlock-mutex} will actually unlock the mutex.
-@end deffn
-
-make-condition-variable
-@c snarfed from threads.c:1052
-@deffn {Scheme Procedure} make-condition-variable
-@deffnx {C Function} scm_make_condition_variable ()
-Make a new condition variable.
-@end deffn
-
-wait-condition-variable
-@c snarfed from threads.c:1120
-@deffn {Scheme Procedure} wait-condition-variable cv mx [t]
-@deffnx {C Function} scm_timed_wait_condition_variable (cv, mx, t)
-Wait until @var{cond-var} has been signalled. While waiting, @var{mutex} is atomically unlocked (as with @code{unlock-mutex}) and is locked again when this function returns. When @var{time} is given, it specifies a point in time where the waiting should be aborted. It can be either a integer as returned by @code{current-time} or a pair as returned by @code{gettimeofday}. When the waiting is aborted the mutex is locked and @code{#f} is returned. When the condition variable is in fact signalled, the mutex is also locked and @code{#t} is returned.
-@end deffn
-
-signal-condition-variable
-@c snarfed from threads.c:1157
-@deffn {Scheme Procedure} signal-condition-variable cv
-@deffnx {C Function} scm_signal_condition_variable (cv)
-Wake up one thread that is waiting for @var{cv}
-@end deffn
-
-broadcast-condition-variable
-@c snarfed from threads.c:1177
-@deffn {Scheme Procedure} broadcast-condition-variable cv
-@deffnx {C Function} scm_broadcast_condition_variable (cv)
-Wake up all threads that are waiting for @var{cv}.
-@end deffn
-
-current-thread
-@c snarfed from threads.c:1354
-@deffn {Scheme Procedure} current-thread
-@deffnx {C Function} scm_current_thread ()
-Return the thread that called this function.
-@end deffn
-
-all-threads
-@c snarfed from threads.c:1372
-@deffn {Scheme Procedure} all-threads
-@deffnx {C Function} scm_all_threads ()
-Return a list of all threads.
-@end deffn
-
-thread-exited?
-@c snarfed from threads.c:1398
-@deffn {Scheme Procedure} thread-exited? thread
-@deffnx {C Function} scm_thread_exited_p (thread)
-Return @code{#t} iff @var{thread} has exited.
-
-@end deffn
-
-catch
-@c snarfed from throw.c:512
-@deffn {Scheme Procedure} catch key thunk handler
-@deffnx {C Function} scm_catch (key, thunk, handler)
-Invoke @var{thunk} in the dynamic context of @var{handler} for
-exceptions matching @var{key}. If thunk throws to the symbol
-@var{key}, then @var{handler} is invoked this way:
-@lisp
-(handler key args ...)
-@end lisp
-
-@var{key} is a symbol or @code{#t}.
-
-@var{thunk} takes no arguments. If @var{thunk} returns
-normally, that is the return value of @code{catch}.
-
-Handler is invoked outside the scope of its own @code{catch}.
-If @var{handler} again throws to the same key, a new handler
-from further up the call chain is invoked.
-
-If the key is @code{#t}, then a throw to @emph{any} symbol will
-match this call to @code{catch}.
-@end deffn
-
-lazy-catch
-@c snarfed from throw.c:540
-@deffn {Scheme Procedure} lazy-catch key thunk handler
-@deffnx {C Function} scm_lazy_catch (key, thunk, handler)
-This behaves exactly like @code{catch}, except that it does
-not unwind the stack before invoking @var{handler}.
-The @var{handler} procedure is not allowed to return:
-it must throw to another catch, or otherwise exit non-locally.
-@end deffn
-
-throw
-@c snarfed from throw.c:573
-@deffn {Scheme Procedure} throw key . args
-@deffnx {C Function} scm_throw (key, args)
-Invoke the catch form matching @var{key}, passing @var{args} to the
-@var{handler}.
-
-@var{key} is a symbol. It will match catches of the same symbol or of
-@code{#t}.
-
-If there is no handler at all, Guile prints an error and then exits.
-@end deffn
-
-values
-@c snarfed from values.c:53
-@deffn {Scheme Procedure} values . args
-@deffnx {C Function} scm_values (args)
-Delivers all of its arguments to its continuation. Except for
-continuations created by the @code{call-with-values} procedure,
-all continuations take exactly one value. The effect of
-passing no value or more than one value to continuations that
-were not created by @code{call-with-values} is unspecified.
-@end deffn
-
-make-variable
-@c snarfed from variable.c:52
-@deffn {Scheme Procedure} make-variable init
-@deffnx {C Function} scm_make_variable (init)
-Return a variable initialized to value @var{init}.
-@end deffn
-
-make-undefined-variable
-@c snarfed from variable.c:62
-@deffn {Scheme Procedure} make-undefined-variable
-@deffnx {C Function} scm_make_undefined_variable ()
-Return a variable that is initially unbound.
-@end deffn
-
-variable?
-@c snarfed from variable.c:73
-@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
-
-variable-ref
-@c snarfed from variable.c:85
-@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
-
-variable-set!
-@c snarfed from variable.c:101
-@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
-
-variable-bound?
-@c snarfed from variable.c:113
-@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
-
-vector?
-@c snarfed from vectors.c:91
-@deffn {Scheme Procedure} vector? obj
-@deffnx {C Function} scm_vector_p (obj)
-Return @code{#t} if @var{obj} is a vector, otherwise return
-@code{#f}.
-@end deffn
-
-list->vector
-@c snarfed from vectors.c:123
-@deffn {Scheme Procedure} list->vector
-implemented by the C function "scm_vector"
-@end deffn
-
-vector
-@c snarfed from vectors.c:140
-@deffn {Scheme Procedure} vector . l
-@deffnx {Scheme Procedure} list->vector l
-@deffnx {C Function} scm_vector (l)
-Return a newly allocated vector composed of the
-given arguments. Analogous to @code{list}.
-
-@lisp
-(vector 'a 'b 'c) @result{} #(a b c)
-@end lisp
-@end deffn
-
-make-vector
-@c snarfed from vectors.c:276
-@deffn {Scheme Procedure} make-vector k [fill]
-@deffnx {C Function} scm_make_vector (k, fill)
-Return a newly allocated vector of @var{k} elements. If a
-second argument is given, then each position is initialized to
-@var{fill}. Otherwise the initial contents of each position is
-unspecified.
-@end deffn
-
-vector-copy
-@c snarfed from vectors.c:318
-@deffn {Scheme Procedure} vector-copy vec
-@deffnx {C Function} scm_vector_copy (vec)
-Return a copy of @var{vec}.
-@end deffn
-
-vector->list
-@c snarfed from vectors.c:389
-@deffn {Scheme Procedure} vector->list v
-@deffnx {C Function} scm_vector_to_list (v)
-Return a newly allocated list composed of the elements of @var{v}.
-
-@lisp
-(vector->list '#(dah dah didah)) @result{} (dah dah didah)
-(list->vector '(dididit dah)) @result{} #(dididit dah)
-@end lisp
-@end deffn
-
-vector-fill!
-@c snarfed from vectors.c:413
-@deffn {Scheme Procedure} vector-fill! v fill
-@deffnx {C Function} scm_vector_fill_x (v, fill)
-Store @var{fill} in every position of @var{vector}. The value
-returned by @code{vector-fill!} is unspecified.
-@end deffn
-
-vector-move-left!
-@c snarfed from vectors.c:450
-@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2
-@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2)
-Copy elements from @var{vec1}, positions @var{start1} to @var{end1},
-to @var{vec2} starting at position @var{start2}. @var{start1} and
-@var{start2} are inclusive indices; @var{end1} is exclusive.
-
-@code{vector-move-left!} copies elements in leftmost order.
-Therefore, in the case where @var{vec1} and @var{vec2} refer to the
-same vector, @code{vector-move-left!} is usually appropriate when
-@var{start1} is greater than @var{start2}.
-@end deffn
-
-vector-move-right!
-@c snarfed from vectors.c:488
-@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2
-@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2)
-Copy elements from @var{vec1}, positions @var{start1} to @var{end1},
-to @var{vec2} starting at position @var{start2}. @var{start1} and
-@var{start2} are inclusive indices; @var{end1} is exclusive.
-
-@code{vector-move-right!} copies elements in rightmost order.
-Therefore, in the case where @var{vec1} and @var{vec2} refer to the
-same vector, @code{vector-move-right!} is usually appropriate when
-@var{start1} is less than @var{start2}.
-@end deffn
-
-generalized-vector?
-@c snarfed from vectors.c:537
-@deffn {Scheme Procedure} generalized-vector? obj
-@deffnx {C Function} scm_generalized_vector_p (obj)
-Return @code{#t} if @var{obj} is a vector, string,
-bitvector, or uniform numeric vector.
-@end deffn
-
-generalized-vector-length
-@c snarfed from vectors.c:569
-@deffn {Scheme Procedure} generalized-vector-length v
-@deffnx {C Function} scm_generalized_vector_length (v)
-Return the length of the generalized vector @var{v}.
-@end deffn
-
-generalized-vector-ref
-@c snarfed from vectors.c:594
-@deffn {Scheme Procedure} generalized-vector-ref v idx
-@deffnx {C Function} scm_generalized_vector_ref (v, idx)
-Return the element at index @var{idx} of the
-generalized vector @var{v}.
-@end deffn
-
-generalized-vector-set!
-@c snarfed from vectors.c:619
-@deffn {Scheme Procedure} generalized-vector-set! v idx val
-@deffnx {C Function} scm_generalized_vector_set_x (v, idx, val)
-Set the element at index @var{idx} of the
-generalized vector @var{v} to @var{val}.
-@end deffn
-
-generalized-vector->list
-@c snarfed from vectors.c:630
-@deffn {Scheme Procedure} generalized-vector->list v
-@deffnx {C Function} scm_generalized_vector_to_list (v)
-Return a new list whose elements are the elements of the
-generalized vector @var{v}.
-@end deffn
-
-major-version
-@c snarfed from version.c:35
-@deffn {Scheme Procedure} major-version
-@deffnx {C Function} scm_major_version ()
-Return a string containing Guile's major version number.
-E.g., the 1 in "1.6.5".
-@end deffn
-
-minor-version
-@c snarfed from version.c:48
-@deffn {Scheme Procedure} minor-version
-@deffnx {C Function} scm_minor_version ()
-Return a string containing Guile's minor version number.
-E.g., the 6 in "1.6.5".
-@end deffn
-
-micro-version
-@c snarfed from version.c:61
-@deffn {Scheme Procedure} micro-version
-@deffnx {C Function} scm_micro_version ()
-Return a string containing Guile's micro version number.
-E.g., the 5 in "1.6.5".
-@end deffn
-
-version
-@c snarfed from version.c:83
-@deffn {Scheme Procedure} version
-@deffnx {Scheme Procedure} major-version
-@deffnx {Scheme Procedure} minor-version
-@deffnx {Scheme Procedure} micro-version
-@deffnx {C Function} scm_version ()
-Return a string describing Guile's version number, or its major, minor
-or micro version number, respectively.
-
-@lisp
-(version) @result{} "1.6.0"
-(major-version) @result{} "1"
-(minor-version) @result{} "6"
-(micro-version) @result{} "0"
-@end lisp
-@end deffn
-
-effective-version
-@c snarfed from version.c:113
-@deffn {Scheme Procedure} effective-version
-@deffnx {C Function} scm_effective_version ()
-Return a string describing Guile's effective version number.
-@lisp
-(version) @result{} "1.6.0"
-(effective-version) @result{} "1.6"
-(major-version) @result{} "1"
-(minor-version) @result{} "6"
-(micro-version) @result{} "0"
-@end lisp
-@end deffn
-
-make-soft-port
-@c snarfed from vports.c:185
-@deffn {Scheme Procedure} make-soft-port pv modes
-@deffnx {C Function} scm_make_soft_port (pv, modes)
-Return a port capable of receiving or delivering characters as
-specified by the @var{modes} string (@pxref{File Ports,
-open-file}). @var{pv} must be a vector of length 5 or 6. Its
-components are as follows:
-
-@enumerate 0
-@item
-procedure accepting one character for output
-@item
-procedure accepting a string for output
-@item
-thunk for flushing output
-@item
-thunk for getting one character
-@item
-thunk for closing port (not by garbage collection)
-@item
-(if present and not @code{#f}) thunk for computing the number of
-characters that can be read from the port without blocking.
-@end enumerate
-
-For an output-only port only elements 0, 1, 2, and 4 need be
-procedures. For an input-only port only elements 3 and 4 need
-be procedures. Thunks 2 and 4 can instead be @code{#f} if
-there is no useful operation for them to perform.
-
-If thunk 3 returns @code{#f} or an @code{eof-object}
-(@pxref{Input, eof-object?, ,r5rs, The Revised^5 Report on
-Scheme}) it indicates that the port has reached end-of-file.
-For example:
-
-@lisp
-(define stdout (current-output-port))
-(define p (make-soft-port
- (vector
- (lambda (c) (write c stdout))
- (lambda (s) (display s stdout))
- (lambda () (display "." stdout))
- (lambda () (char-upcase (read-char)))
- (lambda () (display "@@" stdout)))
- "rw"))
-
-(write p p) @result{} #
-@end lisp
-@end deffn
-
-make-weak-vector
-@c snarfed from weaks.c:74
-@deffn {Scheme Procedure} make-weak-vector size [fill]
-@deffnx {C Function} scm_make_weak_vector (size, fill)
-Return a weak vector with @var{size} elements. If the optional
-argument @var{fill} is given, all entries in the vector will be
-set to @var{fill}. The default value for @var{fill} is the
-empty list.
-@end deffn
-
-list->weak-vector
-@c snarfed from weaks.c:82
-@deffn {Scheme Procedure} list->weak-vector
-implemented by the C function "scm_weak_vector"
-@end deffn
-
-weak-vector
-@c snarfed from weaks.c:90
-@deffn {Scheme Procedure} weak-vector . l
-@deffnx {Scheme Procedure} list->weak-vector l
-@deffnx {C Function} scm_weak_vector (l)
-Construct a weak vector from a list: @code{weak-vector} uses
-the list of its arguments while @code{list->weak-vector} uses
-its only argument @var{l} (a list) to construct a weak vector
-the same way @code{list->vector} would.
-@end deffn
-
-weak-vector?
-@c snarfed from weaks.c:120
-@deffn {Scheme Procedure} weak-vector? obj
-@deffnx {C Function} scm_weak_vector_p (obj)
-Return @code{#t} if @var{obj} is a weak vector. Note that all
-weak hashes are also weak vectors.
-@end deffn
-
-make-weak-key-alist-vector
-@c snarfed from weaks.c:138
-@deffn {Scheme Procedure} make-weak-key-alist-vector [size]
-@deffnx {Scheme Procedure} make-weak-value-alist-vector size
-@deffnx {Scheme Procedure} make-doubly-weak-alist-vector size
-@deffnx {C Function} scm_make_weak_key_alist_vector (size)
-Return a weak hash table with @var{size} buckets. As with any
-hash table, choosing a good size for the table requires some
-caution.
-
-You can modify weak hash tables in exactly the same way you
-would modify regular hash tables. (@pxref{Hash Tables})
-@end deffn
-
-make-weak-value-alist-vector
-@c snarfed from weaks.c:150
-@deffn {Scheme Procedure} make-weak-value-alist-vector [size]
-@deffnx {C Function} scm_make_weak_value_alist_vector (size)
-Return a hash table with weak values with @var{size} buckets.
-(@pxref{Hash Tables})
-@end deffn
-
-make-doubly-weak-alist-vector
-@c snarfed from weaks.c:162
-@deffn {Scheme Procedure} make-doubly-weak-alist-vector size
-@deffnx {C Function} scm_make_doubly_weak_alist_vector (size)
-Return a hash table with weak keys and values with @var{size}
-buckets. (@pxref{Hash Tables})
-@end deffn
-
-weak-key-alist-vector?
-@c snarfed from weaks.c:177
-@deffn {Scheme Procedure} weak-key-alist-vector? obj
-@deffnx {Scheme Procedure} weak-value-alist-vector? obj
-@deffnx {Scheme Procedure} doubly-weak-alist-vector? obj
-@deffnx {C Function} scm_weak_key_alist_vector_p (obj)
-Return @code{#t} if @var{obj} is the specified weak hash
-table. Note that a doubly weak hash table is neither a weak key
-nor a weak value hash table.
-@end deffn
-
-weak-value-alist-vector?
-@c snarfed from weaks.c:187
-@deffn {Scheme Procedure} weak-value-alist-vector? obj
-@deffnx {C Function} scm_weak_value_alist_vector_p (obj)
-Return @code{#t} if @var{obj} is a weak value hash table.
-@end deffn
-
-doubly-weak-alist-vector?
-@c snarfed from weaks.c:197
-@deffn {Scheme Procedure} doubly-weak-alist-vector? obj
-@deffnx {C Function} scm_doubly_weak_alist_vector_p (obj)
-Return @code{#t} if @var{obj} is a doubly weak hash table.
-@end deffn
-
-array-fill!
-@c snarfed from ramap.c:352
-@deffn {Scheme Procedure} array-fill! ra fill
-@deffnx {C Function} scm_array_fill_x (ra, fill)
-Store @var{fill} in every element of @var{array}. The value returned
-is unspecified.
-@end deffn
-
-array-copy-in-order!
-@c snarfed from ramap.c:399
-@deffn {Scheme Procedure} array-copy-in-order!
-implemented by the C function "scm_array_copy_x"
-@end deffn
-
-array-copy!
-@c snarfed from ramap.c:408
-@deffn {Scheme Procedure} array-copy! src dst
-@deffnx {Scheme Procedure} array-copy-in-order! src dst
-@deffnx {C Function} scm_array_copy_x (src, dst)
-Copy every element from vector or array @var{source} to the
-corresponding element of @var{destination}. @var{destination} must have
-the same rank as @var{source}, and be at least as large in each
-dimension. The order is unspecified.
-@end deffn
-
-array-map-in-order!
-@c snarfed from ramap.c:798
-@deffn {Scheme Procedure} array-map-in-order!
-implemented by the C function "scm_array_map_x"
-@end deffn
-
-array-map!
-@c snarfed from ramap.c:809
-@deffn {Scheme Procedure} array-map! ra0 proc . lra
-@deffnx {Scheme Procedure} array-map-in-order! ra0 proc . lra
-@deffnx {C Function} scm_array_map_x (ra0, proc, lra)
-@var{array1}, @dots{} must have the same number of dimensions as
-@var{array0} and have a range for each index which includes the range
-for the corresponding index in @var{array0}. @var{proc} is applied to
-each tuple of elements of @var{array1} @dots{} and the result is stored
-as the corresponding element in @var{array0}. The value returned is
-unspecified. The order of application is unspecified.
-@end deffn
-
-array-for-each
-@c snarfed from ramap.c:950
-@deffn {Scheme Procedure} array-for-each proc ra0 . lra
-@deffnx {C Function} scm_array_for_each (proc, ra0, lra)
-Apply @var{proc} to each tuple of elements of @var{array0} @dots{}
-in row-major order. The value returned is unspecified.
-@end deffn
-
-array-index-map!
-@c snarfed from ramap.c:978
-@deffn {Scheme Procedure} array-index-map! ra proc
-@deffnx {C Function} scm_array_index_map_x (ra, proc)
-Apply @var{proc} to the indices of each element of @var{array} in
-turn, storing the result in the corresponding element. The value
-returned and the order of application are unspecified.
-
-One can implement @var{array-indexes} as
-@lisp
-(define (array-indexes array)
- (let ((ra (apply make-array #f (array-shape array))))
- (array-index-map! ra (lambda x x))
- ra))
-@end lisp
-Another example:
-@lisp
-(define (apl:index-generator n)
- (let ((v (make-uniform-vector n 1)))
- (array-index-map! v (lambda (i) i))
- v))
-@end lisp
-@end deffn
-
-array?
-@c snarfed from unif.c:501
-@deffn {Scheme Procedure} array? obj [prot]
-@deffnx {C Function} scm_array_p (obj, prot)
-Return @code{#t} if the @var{obj} is an array, and @code{#f} if
-not.
-@end deffn
-
-typed-array?
-@c snarfed from unif.c:548
-@deffn {Scheme Procedure} typed-array? obj type
-@deffnx {C Function} scm_typed_array_p (obj, type)
-Return @code{#t} if the @var{obj} is an array of type
-@var{type}, and @code{#f} if not.
-@end deffn
-
-array-rank
-@c snarfed from unif.c:569
-@deffn {Scheme Procedure} array-rank array
-@deffnx {C Function} scm_array_rank (array)
-Return the number of dimensions of the array @var{array.}
-
-@end deffn
-
-array-dimensions
-@c snarfed from unif.c:583
-@deffn {Scheme Procedure} array-dimensions ra
-@deffnx {C Function} scm_array_dimensions (ra)
-@code{array-dimensions} is similar to @code{array-shape} but replaces
-elements with a @code{0} minimum with one greater than the maximum. So:
-@lisp
-(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5)
-@end lisp
-@end deffn
-
-shared-array-root
-@c snarfed from unif.c:611
-@deffn {Scheme Procedure} shared-array-root ra
-@deffnx {C Function} scm_shared_array_root (ra)
-Return the root vector of a shared array.
-@end deffn
-
-shared-array-offset
-@c snarfed from unif.c:625
-@deffn {Scheme Procedure} shared-array-offset ra
-@deffnx {C Function} scm_shared_array_offset (ra)
-Return the root vector index of the first element in the array.
-@end deffn
-
-shared-array-increments
-@c snarfed from unif.c:641
-@deffn {Scheme Procedure} shared-array-increments ra
-@deffnx {C Function} scm_shared_array_increments (ra)
-For each dimension, return the distance between elements in the root vector.
-@end deffn
-
-make-typed-array
-@c snarfed from unif.c:740
-@deffn {Scheme Procedure} make-typed-array type fill . bounds
-@deffnx {C Function} scm_make_typed_array (type, fill, bounds)
-Create and return an array of type @var{type}.
-@end deffn
-
-make-array
-@c snarfed from unif.c:775
-@deffn {Scheme Procedure} make-array fill . bounds
-@deffnx {C Function} scm_make_array (fill, bounds)
-Create and return an array.
-@end deffn
-
-dimensions->uniform-array
-@c snarfed from unif.c:790
-@deffn {Scheme Procedure} dimensions->uniform-array dims prot [fill]
-@deffnx {Scheme Procedure} make-uniform-vector length prototype [fill]
-@deffnx {C Function} scm_dimensions_to_uniform_array (dims, prot, fill)
-Create and return a uniform array or vector of type
-corresponding to @var{prototype} with dimensions @var{dims} or
-length @var{length}. If @var{fill} is supplied, it's used to
-fill the array, otherwise @var{prototype} is used.
-@end deffn
-
-make-shared-array
-@c snarfed from unif.c:843
-@deffn {Scheme Procedure} make-shared-array oldra mapfunc . dims
-@deffnx {C Function} scm_make_shared_array (oldra, mapfunc, dims)
-@code{make-shared-array} can be used to create shared subarrays of other
-arrays. The @var{mapper} is a function that translates coordinates in
-the new array into coordinates in the old array. A @var{mapper} must be
-linear, and its range must stay within the bounds of the old array, but
-it can be otherwise arbitrary. A simple example:
-@lisp
-(define fred (make-array #f 8 8))
-(define freds-diagonal
- (make-shared-array fred (lambda (i) (list i i)) 8))
-(array-set! freds-diagonal 'foo 3)
-(array-ref fred 3 3) @result{} foo
-(define freds-center
- (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2))
-(array-ref freds-center 0 0) @result{} foo
-@end lisp
-@end deffn
-
-transpose-array
-@c snarfed from unif.c:961
-@deffn {Scheme Procedure} transpose-array ra . args
-@deffnx {C Function} scm_transpose_array (ra, args)
-Return an array sharing contents with @var{array}, but with
-dimensions arranged in a different order. There must be one
-@var{dim} argument for each dimension of @var{array}.
-@var{dim0}, @var{dim1}, @dots{} should be integers between 0
-and the rank of the array to be returned. Each integer in that
-range must appear at least once in the argument list.
-
-The values of @var{dim0}, @var{dim1}, @dots{} correspond to
-dimensions in the array to be returned, their positions in the
-argument list to dimensions of @var{array}. Several @var{dim}s
-may have the same value, in which case the returned array will
-have smaller rank than @var{array}.
-
-@lisp
-(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d))
-(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d)
-(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{}
- #2((a 4) (b 5) (c 6))
-@end lisp
-@end deffn
-
-enclose-array
-@c snarfed from unif.c:1059
-@deffn {Scheme Procedure} enclose-array ra . axes
-@deffnx {C Function} scm_enclose_array (ra, axes)
-@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than
-the rank of @var{array}. @var{enclose-array} returns an array
-resembling an array of shared arrays. The dimensions of each shared
-array are the same as the @var{dim}th dimensions of the original array,
-the dimensions of the outer array are the same as those of the original
-array that did not match a @var{dim}.
-
-An enclosed array is not a general Scheme array. Its elements may not
-be set using @code{array-set!}. Two references to the same element of
-an enclosed array will be @code{equal?} but will not in general be
-@code{eq?}. The value returned by @var{array-prototype} when given an
-enclosed array is unspecified.
-
-examples:
-@lisp
-(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{}
- #
-
-(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{}
- #
-@end lisp
-@end deffn
-
-array-in-bounds?
-@c snarfed from unif.c:1132
-@deffn {Scheme Procedure} array-in-bounds? v . args
-@deffnx {C Function} scm_array_in_bounds_p (v, args)
-Return @code{#t} if its arguments would be acceptable to
-@code{array-ref}.
-@end deffn
-
-array-ref
-@c snarfed from unif.c:1209
-@deffn {Scheme Procedure} array-ref v . args
-@deffnx {C Function} scm_array_ref (v, args)
-Return the element at the @code{(index1, index2)} element in
-@var{array}.
-@end deffn
-
-array-set!
-@c snarfed from unif.c:1226
-@deffn {Scheme Procedure} array-set! v obj . args
-@deffnx {C Function} scm_array_set_x (v, obj, args)
-Set the element at the @code{(index1, index2)} element in @var{array} to
-@var{new-value}. The value returned by array-set! is unspecified.
-@end deffn
-
-array-contents
-@c snarfed from unif.c:1252
-@deffn {Scheme Procedure} array-contents ra [strict]
-@deffnx {C Function} scm_array_contents (ra, strict)
-If @var{array} may be @dfn{unrolled} into a one dimensional shared array
-without changing their order (last subscript changing fastest), then
-@code{array-contents} returns that shared array, otherwise it returns
-@code{#f}. All arrays made by @var{make-array} and
-@var{make-uniform-array} may be unrolled, some arrays made by
-@var{make-shared-array} may not be.
-
-If the optional argument @var{strict} is provided, a shared array will
-be returned only if its elements are stored internally contiguous in
-memory.
-@end deffn
-
-uniform-array-read!
-@c snarfed from unif.c:1352
-@deffn {Scheme Procedure} uniform-array-read! ura [port_or_fd [start [end]]]
-@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end]
-@deffnx {C Function} scm_uniform_array_read_x (ura, port_or_fd, start, end)
-Attempt to read all elements of @var{ura}, in lexicographic order, as
-binary objects from @var{port-or-fdes}.
-If an end of file is encountered,
-the objects up to that point are put into @var{ura}
-(starting at the beginning) and the remainder of the array is
-unchanged.
-
-The optional arguments @var{start} and @var{end} allow
-a specified region of a vector (or linearized array) to be read,
-leaving the remainder of the vector unchanged.
-
-@code{uniform-array-read!} returns the number of objects read.
-@var{port-or-fdes} may be omitted, in which case it defaults to the value
-returned by @code{(current-input-port)}.
-@end deffn
-
-uniform-array-write
-@c snarfed from unif.c:1406
-@deffn {Scheme Procedure} uniform-array-write ura [port_or_fd [start [end]]]
-@deffnx {C Function} scm_uniform_array_write (ura, port_or_fd, start, end)
-Writes all elements of @var{ura} as binary objects to
-@var{port-or-fdes}.
-
-The optional arguments @var{start}
-and @var{end} allow
-a specified region of a vector (or linearized array) to be written.
-
-The number of objects actually written is returned.
-@var{port-or-fdes} may be
-omitted, in which case it defaults to the value returned by
-@code{(current-output-port)}.
-@end deffn
-
-bitvector?
-@c snarfed from unif.c:1518
-@deffn {Scheme Procedure} bitvector? obj
-@deffnx {C Function} scm_bitvector_p (obj)
-Return @code{#t} when @var{obj} is a bitvector, else
-return @code{#f}.
-@end deffn
-
-make-bitvector
-@c snarfed from unif.c:1545
-@deffn {Scheme Procedure} make-bitvector len [fill]
-@deffnx {C Function} scm_make_bitvector (len, fill)
-Create a new bitvector of length @var{len} and
-optionally initialize all elements to @var{fill}.
-@end deffn
-
-bitvector
-@c snarfed from unif.c:1554
-@deffn {Scheme Procedure} bitvector . bits
-@deffnx {C Function} scm_bitvector (bits)
-Create a new bitvector with the arguments as elements.
-@end deffn
-
-bitvector-length
-@c snarfed from unif.c:1570
-@deffn {Scheme Procedure} bitvector-length vec
-@deffnx {C Function} scm_bitvector_length (vec)
-Return the length of the bitvector @var{vec}.
-@end deffn
-
-bitvector-ref
-@c snarfed from unif.c:1661
-@deffn {Scheme Procedure} bitvector-ref vec idx
-@deffnx {C Function} scm_bitvector_ref (vec, idx)
-Return the element at index @var{idx} of the bitvector
-@var{vec}.
-@end deffn
-
-bitvector-set!
-@c snarfed from unif.c:1704
-@deffn {Scheme Procedure} bitvector-set! vec idx val
-@deffnx {C Function} scm_bitvector_set_x (vec, idx, val)
-Set the element at index @var{idx} of the bitvector
-@var{vec} when @var{val} is true, else clear it.
-@end deffn
-
-bitvector-fill!
-@c snarfed from unif.c:1715
-@deffn {Scheme Procedure} bitvector-fill! vec val
-@deffnx {C Function} scm_bitvector_fill_x (vec, val)
-Set all elements of the bitvector
-@var{vec} when @var{val} is true, else clear them.
-@end deffn
-
-list->bitvector
-@c snarfed from unif.c:1760
-@deffn {Scheme Procedure} list->bitvector list
-@deffnx {C Function} scm_list_to_bitvector (list)
-Return a new bitvector initialized with the elements
-of @var{list}.
-@end deffn
-
-bitvector->list
-@c snarfed from unif.c:1790
-@deffn {Scheme Procedure} bitvector->list vec
-@deffnx {C Function} scm_bitvector_to_list (vec)
-Return a new list initialized with the elements
-of the bitvector @var{vec}.
-@end deffn
-
-bit-count
-@c snarfed from unif.c:1854
-@deffn {Scheme Procedure} bit-count b bitvector
-@deffnx {C Function} scm_bit_count (b, bitvector)
-Return the number of occurrences of the boolean @var{b} in
-@var{bitvector}.
-@end deffn
-
-bit-position
-@c snarfed from unif.c:1923
-@deffn {Scheme Procedure} bit-position item v k
-@deffnx {C Function} scm_bit_position (item, v, k)
-Return the index of the first occurrance of @var{item} in bit
-vector @var{v}, starting from @var{k}. If there is no
-@var{item} entry between @var{k} and the end of
-@var{bitvector}, then return @code{#f}. For example,
-
-@example
-(bit-position #t #*000101 0) @result{} 3
-(bit-position #f #*0001111 3) @result{} #f
-@end example
-@end deffn
-
-bit-set*!
-@c snarfed from unif.c:2006
-@deffn {Scheme Procedure} bit-set*! v kv obj
-@deffnx {C Function} scm_bit_set_star_x (v, kv, obj)
-Set entries of bit vector @var{v} to @var{obj}, with @var{kv}
-selecting the entries to change. The return value is
-unspecified.
-
-If @var{kv} is a bit vector, then those entries where it has
-@code{#t} are the ones in @var{v} which are set to @var{obj}.
-@var{kv} and @var{v} must be the same length. When @var{obj}
-is @code{#t} it's like @var{kv} is OR'ed into @var{v}. Or when
-@var{obj} is @code{#f} it can be seen as an ANDNOT.
-
-@example
-(define bv #*01000010)
-(bit-set*! bv #*10010001 #t)
-bv
-@result{} #*11010011
-@end example
-
-If @var{kv} is a u32vector, then its elements are
-indices into @var{v} which are set to @var{obj}.
-
-@example
-(define bv #*01000010)
-(bit-set*! bv #u32(5 2 7) #t)
-bv
-@result{} #*01100111
-@end example
-@end deffn
-
-bit-count*
-@c snarfed from unif.c:2109
-@deffn {Scheme Procedure} bit-count* v kv obj
-@deffnx {C Function} scm_bit_count_star (v, kv, obj)
-Return a count of how many entries in bit vector @var{v} are
-equal to @var{obj}, with @var{kv} selecting the entries to
-consider.
-
-If @var{kv} is a bit vector, then those entries where it has
-@code{#t} are the ones in @var{v} which are considered.
-@var{kv} and @var{v} must be the same length.
-
-If @var{kv} is a u32vector, then it contains
-the indexes in @var{v} to consider.
-
-For example,
-
-@example
-(bit-count* #*01110111 #*11001101 #t) @result{} 3
-(bit-count* #*01110111 #u32(7 0 4) #f) @result{} 2
-@end example
-@end deffn
-
-bit-invert!
-@c snarfed from unif.c:2196
-@deffn {Scheme Procedure} bit-invert! v
-@deffnx {C Function} scm_bit_invert_x (v)
-Modify the bit vector @var{v} by replacing each element with
-its negation.
-@end deffn
-
-array->list
-@c snarfed from unif.c:2303
-@deffn {Scheme Procedure} array->list v
-@deffnx {C Function} scm_array_to_list (v)
-Return a list consisting of all the elements, in order, of
-@var{array}.
-@end deffn
-
-list->typed-array
-@c snarfed from unif.c:2332
-@deffn {Scheme Procedure} list->typed-array type shape lst
-@deffnx {C Function} scm_list_to_typed_array (type, shape, lst)
-Return an array of the type @var{type}
-with elements the same as those of @var{lst}.
-
-The argument @var{shape} determines the number of dimensions
-of the array and their shape. It is either an exact integer,
-giving the
-number of dimensions directly, or a list whose length
-specifies the number of dimensions and each element specified
-the lower and optionally the upper bound of the corresponding
-dimension.
-When the element is list of two elements, these elements
-give the lower and upper bounds. When it is an exact
-integer, it gives only the lower bound.
-@end deffn
-
-list->array
-@c snarfed from unif.c:2390
-@deffn {Scheme Procedure} list->array ndim lst
-@deffnx {C Function} scm_list_to_array (ndim, lst)
-Return an array with elements the same as those of @var{lst}.
-@end deffn
-
-list->uniform-array
-@c snarfed from unif.c:2440
-@deffn {Scheme Procedure} list->uniform-array ndim prot lst
-@deffnx {C Function} scm_list_to_uniform_array (ndim, prot, lst)
-Return a uniform array of the type indicated by prototype
-@var{prot} with elements the same as those of @var{lst}.
-Elements must be of the appropriate type, no coercions are
-done.
-
-The argument @var{ndim} determines the number of dimensions
-of the array. It is either an exact integer, giving the
-number directly, or a list of exact integers, whose length
-specifies the number of dimensions and each element is the
-lower index bound of its dimension.
-@end deffn
-
-array-type
-@c snarfed from unif.c:2789
-@deffn {Scheme Procedure} array-type ra
-@deffnx {C Function} scm_array_type (ra)
-
-@end deffn
-
-array-prototype
-@c snarfed from unif.c:2809
-@deffn {Scheme Procedure} array-prototype ra
-@deffnx {C Function} scm_array_prototype (ra)
-Return an object that would produce an array of the same type
-as @var{array}, if used as the @var{prototype} for
-@code{make-uniform-array}.
-@end deffn
-
-dynamic-link
-@c snarfed from dynl.c:149
-@deffn {Scheme Procedure} dynamic-link filename
-@deffnx {C Function} scm_dynamic_link (filename)
-Find the shared object (shared library) denoted by
-@var{filename} and link it into the running Guile
-application. The returned
-scheme object is a ``handle'' for the library which can
-be passed to @code{dynamic-func}, @code{dynamic-call} etc.
-
-Searching for object files is system dependent. Normally,
-if @var{filename} does have an explicit directory it will
-be searched for in locations
-such as @file{/usr/lib} and @file{/usr/local/lib}.
-@end deffn
-
-dynamic-object?
-@c snarfed from dynl.c:168
-@deffn {Scheme Procedure} dynamic-object? obj
-@deffnx {C Function} scm_dynamic_object_p (obj)
-Return @code{#t} if @var{obj} is a dynamic object handle,
-or @code{#f} otherwise.
-@end deffn
-
-dynamic-unlink
-@c snarfed from dynl.c:182
-@deffn {Scheme Procedure} dynamic-unlink dobj
-@deffnx {C Function} scm_dynamic_unlink (dobj)
-Unlink a dynamic object from the application, if possible. The
-object must have been linked by @code{dynamic-link}, with
-@var{dobj} the corresponding handle. After this procedure
-is called, the handle can no longer be used to access the
-object.
-@end deffn
-
-dynamic-func
-@c snarfed from dynl.c:207
-@deffn {Scheme Procedure} dynamic-func name dobj
-@deffnx {C Function} scm_dynamic_func (name, dobj)
-Return a ``handle'' for the function @var{name} in the
-shared object referred to by @var{dobj}. The handle
-can be passed to @code{dynamic-call} to actually
-call the function.
-
-Regardless whether your C compiler prepends an underscore
-@samp{_} to the global names in a program, you should
-@strong{not} include this underscore in @var{name}
-since it will be added automatically when necessary.
-@end deffn
-
-dynamic-call
-@c snarfed from dynl.c:253
-@deffn {Scheme Procedure} dynamic-call func dobj
-@deffnx {C Function} scm_dynamic_call (func, dobj)
-Call a C function in a dynamic object. Two styles of
-invocation are supported:
-
-@itemize @bullet
-@item @var{func} can be a function handle returned by
-@code{dynamic-func}. In this case @var{dobj} is
-ignored
-@item @var{func} can be a string with the name of the
-function to call, with @var{dobj} the handle of the
-dynamic object in which to find the function.
-This is equivalent to
-@smallexample
-
-(dynamic-call (dynamic-func @var{func} @var{dobj}) #f)
-@end smallexample
-@end itemize
-
-In either case, the function is passed no arguments
-and its return value is ignored.
-@end deffn
-
-dynamic-args-call
-@c snarfed from dynl.c:285
-@deffn {Scheme Procedure} dynamic-args-call func dobj args
-@deffnx {C Function} scm_dynamic_args_call (func, dobj, args)
-Call the C function indicated by @var{func} and @var{dobj},
-just like @code{dynamic-call}, but pass it some arguments and
-return its return value. The C function is expected to take
-two arguments and return an @code{int}, just like @code{main}:
-@smallexample
-int c_func (int argc, char **argv);
-@end smallexample
-
-The parameter @var{args} must be a list of strings and is
-converted into an array of @code{char *}. The array is passed
-in @var{argv} and its size in @var{argc}. The return value is
-converted to a Scheme number and returned from the call to
-@code{dynamic-args-call}.
-@end deffn
-
-chown
-@c snarfed from filesys.c:224
-@deffn {Scheme Procedure} chown object owner group
-@deffnx {C Function} scm_chown (object, owner, group)
-Change the ownership and group of the file referred to by @var{object} to
-the integer values @var{owner} and @var{group}. @var{object} can be
-a string containing a file name or, if the platform
-supports fchown, a port or integer file descriptor
-which is open on the file. The return value
-is unspecified.
-
-If @var{object} is a symbolic link, either the
-ownership of the link or the ownership of the referenced file will be
-changed depending on the operating system (lchown is
-unsupported at present). If @var{owner} or @var{group} is specified
-as @code{-1}, then that ID is not changed.
-@end deffn
-
-chmod
-@c snarfed from filesys.c:262
-@deffn {Scheme Procedure} chmod object mode
-@deffnx {C Function} scm_chmod (object, mode)
-Changes the permissions of the file referred to by @var{obj}.
-@var{obj} can be a string containing a file name or a port or integer file
-descriptor which is open on a file (in which case @code{fchmod} is used
-as the underlying system call).
-@var{mode} specifies
-the new permissions as a decimal number, e.g., @code{(chmod "foo" #o755)}.
-The return value is unspecified.
-@end deffn
-
-umask
-@c snarfed from filesys.c:294
-@deffn {Scheme Procedure} umask [mode]
-@deffnx {C Function} scm_umask (mode)
-If @var{mode} is omitted, returns a decimal number representing the current
-file creation mask. Otherwise the file creation mask is set to
-@var{mode} and the previous value is returned.
-
-E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18.
-@end deffn
-
-open-fdes
-@c snarfed from filesys.c:316
-@deffn {Scheme Procedure} open-fdes path flags [mode]
-@deffnx {C Function} scm_open_fdes (path, flags, mode)
-Similar to @code{open} but return a file descriptor instead of
-a port.
-@end deffn
-
-open
-@c snarfed from filesys.c:357
-@deffn {Scheme Procedure} open path flags [mode]
-@deffnx {C Function} scm_open (path, flags, mode)
-Open the file named by @var{path} for reading and/or writing.
-@var{flags} is an integer specifying how the file should be opened.
-@var{mode} is an integer specifying the permission bits of the file, if
-it needs to be created, before the umask is applied. The default is 666
-(Unix itself has no default).
-
-@var{flags} can be constructed by combining variables using @code{logior}.
-Basic flags are:
-
-@defvar O_RDONLY
-Open the file read-only.
-@end defvar
-@defvar O_WRONLY
-Open the file write-only.
-@end defvar
-@defvar O_RDWR
-Open the file read/write.
-@end defvar
-@defvar O_APPEND
-Append to the file instead of truncating.
-@end defvar
-@defvar O_CREAT
-Create the file if it does not already exist.
-@end defvar
-
-See the Unix documentation of the @code{open} system call
-for additional flags.
-@end deffn
-
-close
-@c snarfed from filesys.c:395
-@deffn {Scheme Procedure} close fd_or_port
-@deffnx {C Function} scm_close (fd_or_port)
-Similar to close-port (@pxref{Closing, close-port}),
-but also works on file descriptors. A side
-effect of closing a file descriptor is that any ports using that file
-descriptor are moved to a different file descriptor and have
-their revealed counts set to zero.
-@end deffn
-
-close-fdes
-@c snarfed from filesys.c:422
-@deffn {Scheme Procedure} close-fdes fd
-@deffnx {C Function} scm_close_fdes (fd)
-A simple wrapper for the @code{close} system call.
-Close file descriptor @var{fd}, which must be an integer.
-Unlike close (@pxref{Ports and File Descriptors, close}),
-the file descriptor will be closed even if a port is using it.
-The return value is unspecified.
-@end deffn
-
-stat
-@c snarfed from filesys.c:624
-@deffn {Scheme Procedure} stat object
-@deffnx {C Function} scm_stat (object)
-Return an object containing various information about the file
-determined by @var{obj}. @var{obj} can be a string containing
-a file name or a port or integer file descriptor which is open
-on a file (in which case @code{fstat} is used as the underlying
-system call).
-
-The object returned by @code{stat} can be passed as a single
-parameter to the following procedures, all of which return
-integers:
-
-@table @code
-@item stat:dev
-The device containing the file.
-@item stat:ino
-The file serial number, which distinguishes this file from all
-other files on the same device.
-@item stat:mode
-The mode of the file. This includes file type information and
-the file permission bits. See @code{stat:type} and
-@code{stat:perms} below.
-@item stat:nlink
-The number of hard links to the file.
-@item stat:uid
-The user ID of the file's owner.
-@item stat:gid
-The group ID of the file.
-@item stat:rdev
-Device ID; this entry is defined only for character or block
-special files.
-@item stat:size
-The size of a regular file in bytes.
-@item stat:atime
-The last access time for the file.
-@item stat:mtime
-The last modification time for the file.
-@item stat:ctime
-The last modification time for the attributes of the file.
-@item stat:blksize
-The optimal block size for reading or writing the file, in
-bytes.
-@item stat:blocks
-The amount of disk space that the file occupies measured in
-units of 512 byte blocks.
-@end table
-
-In addition, the following procedures return the information
-from stat:mode in a more convenient form:
-
-@table @code
-@item stat:type
-A symbol representing the type of file. Possible values are
-regular, directory, symlink, block-special, char-special, fifo,
-socket and unknown
-@item stat:perms
-An integer representing the access permission bits.
-@end table
-@end deffn
-
-link
-@c snarfed from filesys.c:686
-@deffn {Scheme Procedure} link oldpath newpath
-@deffnx {C Function} scm_link (oldpath, newpath)
-Creates a new name @var{newpath} in the file system for the
-file named by @var{oldpath}. If @var{oldpath} is a symbolic
-link, the link may or may not be followed depending on the
-system.
-@end deffn
-
-rename-file
-@c snarfed from filesys.c:724
-@deffn {Scheme Procedure} rename-file oldname newname
-@deffnx {C Function} scm_rename (oldname, newname)
-Renames the file specified by @var{oldname} to @var{newname}.
-The return value is unspecified.
-@end deffn
-
-delete-file
-@c snarfed from filesys.c:741
-@deffn {Scheme Procedure} delete-file str
-@deffnx {C Function} scm_delete_file (str)
-Deletes (or "unlinks") the file specified by @var{path}.
-@end deffn
-
-mkdir
-@c snarfed from filesys.c:758
-@deffn {Scheme Procedure} mkdir path [mode]
-@deffnx {C Function} scm_mkdir (path, mode)
-Create a new directory named by @var{path}. If @var{mode} is omitted
-then the permissions of the directory file are set using the current
-umask. Otherwise they are set to the decimal value specified with
-@var{mode}. The return value is unspecified.
-@end deffn
-
-rmdir
-@c snarfed from filesys.c:785
-@deffn {Scheme Procedure} rmdir path
-@deffnx {C Function} scm_rmdir (path)
-Remove the existing directory named by @var{path}. The directory must
-be empty for this to succeed. The return value is unspecified.
-@end deffn
-
-directory-stream?
-@c snarfed from filesys.c:809
-@deffn {Scheme Procedure} directory-stream? obj
-@deffnx {C Function} scm_directory_stream_p (obj)
-Return a boolean indicating whether @var{object} is a directory
-stream as returned by @code{opendir}.
-@end deffn
-
-opendir
-@c snarfed from filesys.c:820
-@deffn {Scheme Procedure} opendir dirname
-@deffnx {C Function} scm_opendir (dirname)
-Open the directory specified by @var{path} and return a directory
-stream.
-@end deffn
-
-readdir
-@c snarfed from filesys.c:841
-@deffn {Scheme Procedure} readdir port
-@deffnx {C Function} scm_readdir (port)
-Return (as a string) the next directory entry from the directory stream
-@var{stream}. If there is no remaining entry to be read then the
-end of file object is returned.
-@end deffn
-
-rewinddir
-@c snarfed from filesys.c:880
-@deffn {Scheme Procedure} rewinddir port
-@deffnx {C Function} scm_rewinddir (port)
-Reset the directory port @var{stream} so that the next call to
-@code{readdir} will return the first directory entry.
-@end deffn
-
-closedir
-@c snarfed from filesys.c:897
-@deffn {Scheme Procedure} closedir port
-@deffnx {C Function} scm_closedir (port)
-Close the directory stream @var{stream}.
-The return value is unspecified.
-@end deffn
-
-chdir
-@c snarfed from filesys.c:947
-@deffn {Scheme Procedure} chdir str
-@deffnx {C Function} scm_chdir (str)
-Change the current working directory to @var{path}.
-The return value is unspecified.
-@end deffn
-
-getcwd
-@c snarfed from filesys.c:962
-@deffn {Scheme Procedure} getcwd
-@deffnx {C Function} scm_getcwd ()
-Return the name of the current working directory.
-@end deffn
-
-select
-@c snarfed from filesys.c:1164
-@deffn {Scheme Procedure} select reads writes excepts [secs [usecs]]
-@deffnx {C Function} scm_select (reads, writes, excepts, secs, usecs)
-This procedure has a variety of uses: waiting for the ability
-to provide input, accept output, or the existence of
-exceptional conditions on a collection of ports or file
-descriptors, or waiting for a timeout to occur.
-It also returns if interrupted by a signal.
-
-@var{reads}, @var{writes} and @var{excepts} can be lists or
-vectors, with each member a port or a file descriptor.
-The value returned is a list of three corresponding
-lists or vectors containing only the members which meet the
-specified requirement. The ability of port buffers to
-provide input or accept output is taken into account.
-Ordering of the input lists or vectors is not preserved.
-
-The optional arguments @var{secs} and @var{usecs} specify the
-timeout. Either @var{secs} can be specified alone, as
-either an integer or a real number, or both @var{secs} and
-@var{usecs} can be specified as integers, in which case
-@var{usecs} is an additional timeout expressed in
-microseconds. If @var{secs} is omitted or is @code{#f} then
-select will wait for as long as it takes for one of the other
-conditions to be satisfied.
-
-The scsh version of @code{select} differs as follows:
-Only vectors are accepted for the first three arguments.
-The @var{usecs} argument is not supported.
-Multiple values are returned instead of a list.
-Duplicates in the input vectors appear only once in output.
-An additional @code{select!} interface is provided.
-@end deffn
-
-fcntl
-@c snarfed from filesys.c:1302
-@deffn {Scheme Procedure} fcntl object cmd [value]
-@deffnx {C Function} scm_fcntl (object, cmd, value)
-Apply @var{command} to the specified file descriptor or the underlying
-file descriptor of the specified port. @var{value} is an optional
-integer argument.
-
-Values for @var{command} are:
-
-@table @code
-@item F_DUPFD
-Duplicate a file descriptor
-@item F_GETFD
-Get flags associated with the file descriptor.
-@item F_SETFD
-Set flags associated with the file descriptor to @var{value}.
-@item F_GETFL
-Get flags associated with the open file.
-@item F_SETFL
-Set flags associated with the open file to @var{value}
-@item F_GETOWN
-Get the process ID of a socket's owner, for @code{SIGIO} signals.
-@item F_SETOWN
-Set the process that owns a socket to @var{value}, for @code{SIGIO} signals.
-@item FD_CLOEXEC
-The value used to indicate the "close on exec" flag with @code{F_GETFL} or
-@code{F_SETFL}.
-@end table
-@end deffn
-
-fsync
-@c snarfed from filesys.c:1334
-@deffn {Scheme Procedure} fsync object
-@deffnx {C Function} scm_fsync (object)
-Copies any unwritten data for the specified output file descriptor to disk.
-If @var{port/fd} is a port, its buffer is flushed before the underlying
-file descriptor is fsync'd.
-The return value is unspecified.
-@end deffn
-
-symlink
-@c snarfed from filesys.c:1359
-@deffn {Scheme Procedure} symlink oldpath newpath
-@deffnx {C Function} scm_symlink (oldpath, newpath)
-Create a symbolic link named @var{path-to} with the value (i.e., pointing to)
-@var{path-from}. The return value is unspecified.
-@end deffn
-
-readlink
-@c snarfed from filesys.c:1378
-@deffn {Scheme Procedure} readlink path
-@deffnx {C Function} scm_readlink (path)
-Return the value of the symbolic link named by @var{path} (a
-string), i.e., the file that the link points to.
-@end deffn
-
-lstat
-@c snarfed from filesys.c:1420
-@deffn {Scheme Procedure} lstat str
-@deffnx {C Function} scm_lstat (str)
-Similar to @code{stat}, but does not follow symbolic links, i.e.,
-it will return information about a symbolic link itself, not the
-file it points to. @var{path} must be a string.
-@end deffn
-
-copy-file
-@c snarfed from filesys.c:1443
-@deffn {Scheme Procedure} copy-file oldfile newfile
-@deffnx {C Function} scm_copy_file (oldfile, newfile)
-Copy the file specified by @var{path-from} to @var{path-to}.
-The return value is unspecified.
-@end deffn
-
-dirname
-@c snarfed from filesys.c:1506
-@deffn {Scheme Procedure} dirname filename
-@deffnx {C Function} scm_dirname (filename)
-Return the directory name component of the file name
-@var{filename}. If @var{filename} does not contain a directory
-component, @code{.} is returned.
-@end deffn
-
-basename
-@c snarfed from filesys.c:1549
-@deffn {Scheme Procedure} basename filename [suffix]
-@deffnx {C Function} scm_basename (filename, suffix)
-Return the base name of the file name @var{filename}. The
-base name is the file name without any directory components.
-If @var{suffix} is provided, and is equal to the end of
-@var{basename}, it is removed also.
-@end deffn
-
-pipe
-@c snarfed from posix.c:233
-@deffn {Scheme Procedure} pipe
-@deffnx {C Function} scm_pipe ()
-Return a newly created pipe: a pair of ports which are linked
-together on the local machine. The @emph{car} is the input
-port and the @emph{cdr} is the output port. Data written (and
-flushed) to the output port can be read from the input port.
-Pipes are commonly used for communication with a newly forked
-child process. The need to flush the output port can be
-avoided by making it unbuffered using @code{setvbuf}.
-
-Writes occur atomically provided the size of the data in bytes
-is not greater than the value of @code{PIPE_BUF}. Note that
-the output port is likely to block if too much data (typically
-equal to @code{PIPE_BUF}) has been written but not yet read
-from the input port.
-@end deffn
-
-getgroups
-@c snarfed from posix.c:254
-@deffn {Scheme Procedure} getgroups
-@deffnx {C Function} scm_getgroups ()
-Return a vector of integers representing the current
-supplementary group IDs.
-@end deffn
-
-setgroups
-@c snarfed from posix.c:287
-@deffn {Scheme Procedure} setgroups group_vec
-@deffnx {C Function} scm_setgroups (group_vec)
-Set the current set of supplementary group IDs to the integers
-in the given vector @var{vec}. The return value is
-unspecified.
-
-Generally only the superuser can set the process group IDs.
-@end deffn
-
-getpw
-@c snarfed from posix.c:336
-@deffn {Scheme Procedure} getpw [user]
-@deffnx {C Function} scm_getpwuid (user)
-Look up an entry in the user database. @var{obj} can be an integer,
-a string, or omitted, giving the behaviour of getpwuid, getpwnam
-or getpwent respectively.
-@end deffn
-
-setpw
-@c snarfed from posix.c:386
-@deffn {Scheme Procedure} setpw [arg]
-@deffnx {C Function} scm_setpwent (arg)
-If called with a true argument, initialize or reset the password data
-stream. Otherwise, close the stream. The @code{setpwent} and
-@code{endpwent} procedures are implemented on top of this.
-@end deffn
-
-getgr
-@c snarfed from posix.c:405
-@deffn {Scheme Procedure} getgr [name]
-@deffnx {C Function} scm_getgrgid (name)
-Look up an entry in the group database. @var{obj} can be an integer,
-a string, or omitted, giving the behaviour of getgrgid, getgrnam
-or getgrent respectively.
-@end deffn
-
-setgr
-@c snarfed from posix.c:441
-@deffn {Scheme Procedure} setgr [arg]
-@deffnx {C Function} scm_setgrent (arg)
-If called with a true argument, initialize or reset the group data
-stream. Otherwise, close the stream. The @code{setgrent} and
-@code{endgrent} procedures are implemented on top of this.
-@end deffn
-
-kill
-@c snarfed from posix.c:477
-@deffn {Scheme Procedure} kill pid sig
-@deffnx {C Function} scm_kill (pid, sig)
-Sends a signal to the specified process or group of processes.
-
-@var{pid} specifies the processes to which the signal is sent:
-
-@table @r
-@item @var{pid} greater than 0
-The process whose identifier is @var{pid}.
-@item @var{pid} equal to 0
-All processes in the current process group.
-@item @var{pid} less than -1
-The process group whose identifier is -@var{pid}
-@item @var{pid} equal to -1
-If the process is privileged, all processes except for some special
-system processes. Otherwise, all processes with the current effective
-user ID.
-@end table
-
-@var{sig} should be specified using a variable corresponding to
-the Unix symbolic name, e.g.,
-
-@defvar SIGHUP
-Hang-up signal.
-@end defvar
-
-@defvar SIGINT
-Interrupt signal.
-@end defvar
-@end deffn
-
-waitpid
-@c snarfed from posix.c:528
-@deffn {Scheme Procedure} waitpid pid [options]
-@deffnx {C Function} scm_waitpid (pid, options)
-This procedure collects status information from a child process which
-has terminated or (optionally) stopped. Normally it will
-suspend the calling process until this can be done. If more than one
-child process is eligible then one will be chosen by the operating system.
-
-The value of @var{pid} determines the behaviour:
-
-@table @r
-@item @var{pid} greater than 0
-Request status information from the specified child process.
-@item @var{pid} equal to -1 or WAIT_ANY
-Request status information for any child process.
-@item @var{pid} equal to 0 or WAIT_MYPGRP
-Request status information for any child process in the current process
-group.
-@item @var{pid} less than -1
-Request status information for any child process whose process group ID
-is -@var{PID}.
-@end table
-
-The @var{options} argument, if supplied, should be the bitwise OR of the
-values of zero or more of the following variables:
-
-@defvar WNOHANG
-Return immediately even if there are no child processes to be collected.
-@end defvar
-
-@defvar WUNTRACED
-Report status information for stopped processes as well as terminated
-processes.
-@end defvar
-
-The return value is a pair containing:
-
-@enumerate
-@item
-The process ID of the child process, or 0 if @code{WNOHANG} was
-specified and no process was collected.
-@item
-The integer status value.
-@end enumerate
-@end deffn
-
-status:exit-val
-@c snarfed from posix.c:554
-@deffn {Scheme Procedure} status:exit-val status
-@deffnx {C Function} scm_status_exit_val (status)
-Return the exit status value, as would be set if a process
-ended normally through a call to @code{exit} or @code{_exit},
-if any, otherwise @code{#f}.
-@end deffn
-
-status:term-sig
-@c snarfed from posix.c:572
-@deffn {Scheme Procedure} status:term-sig status
-@deffnx {C Function} scm_status_term_sig (status)
-Return the signal number which terminated the process, if any,
-otherwise @code{#f}.
-@end deffn
-
-status:stop-sig
-@c snarfed from posix.c:588
-@deffn {Scheme Procedure} status:stop-sig status
-@deffnx {C Function} scm_status_stop_sig (status)
-Return the signal number which stopped the process, if any,
-otherwise @code{#f}.
-@end deffn
-
-getppid
-@c snarfed from posix.c:606
-@deffn {Scheme Procedure} getppid
-@deffnx {C Function} scm_getppid ()
-Return an integer representing the process ID of the parent
-process.
-@end deffn
-
-getuid
-@c snarfed from posix.c:618
-@deffn {Scheme Procedure} getuid
-@deffnx {C Function} scm_getuid ()
-Return an integer representing the current real user ID.
-@end deffn
-
-getgid
-@c snarfed from posix.c:629
-@deffn {Scheme Procedure} getgid
-@deffnx {C Function} scm_getgid ()
-Return an integer representing the current real group ID.
-@end deffn
-
-geteuid
-@c snarfed from posix.c:643
-@deffn {Scheme Procedure} geteuid
-@deffnx {C Function} scm_geteuid ()
-Return an integer representing the current effective user ID.
-If the system does not support effective IDs, then the real ID
-is returned. @code{(provided? 'EIDs)} reports whether the
-system supports effective IDs.
-@end deffn
-
-getegid
-@c snarfed from posix.c:660
-@deffn {Scheme Procedure} getegid
-@deffnx {C Function} scm_getegid ()
-Return an integer representing the current effective group ID.
-If the system does not support effective IDs, then the real ID
-is returned. @code{(provided? 'EIDs)} reports whether the
-system supports effective IDs.
-@end deffn
-
-setuid
-@c snarfed from posix.c:676
-@deffn {Scheme Procedure} setuid id
-@deffnx {C Function} scm_setuid (id)
-Sets both the real and effective user IDs to the integer @var{id}, provided
-the process has appropriate privileges.
-The return value is unspecified.
-@end deffn
-
-setgid
-@c snarfed from posix.c:689
-@deffn {Scheme Procedure} setgid id
-@deffnx {C Function} scm_setgid (id)
-Sets both the real and effective group IDs to the integer @var{id}, provided
-the process has appropriate privileges.
-The return value is unspecified.
-@end deffn
-
-seteuid
-@c snarfed from posix.c:704
-@deffn {Scheme Procedure} seteuid id
-@deffnx {C Function} scm_seteuid (id)
-Sets the effective user ID to the integer @var{id}, provided the process
-has appropriate privileges. If effective IDs are not supported, the
-real ID is set instead -- @code{(provided? 'EIDs)} reports whether the
-system supports effective IDs.
-The return value is unspecified.
-@end deffn
-
-setegid
-@c snarfed from posix.c:729
-@deffn {Scheme Procedure} setegid id
-@deffnx {C Function} scm_setegid (id)
-Sets the effective group ID to the integer @var{id}, provided the process
-has appropriate privileges. If effective IDs are not supported, the
-real ID is set instead -- @code{(provided? 'EIDs)} reports whether the
-system supports effective IDs.
-The return value is unspecified.
-@end deffn
-
-getpgrp
-@c snarfed from posix.c:752
-@deffn {Scheme Procedure} getpgrp
-@deffnx {C Function} scm_getpgrp ()
-Return an integer representing the current process group ID.
-This is the POSIX definition, not BSD.
-@end deffn
-
-setpgid
-@c snarfed from posix.c:770
-@deffn {Scheme Procedure} setpgid pid pgid
-@deffnx {C Function} scm_setpgid (pid, pgid)
-Move the process @var{pid} into the process group @var{pgid}. @var{pid} or
-@var{pgid} must be integers: they can be zero to indicate the ID of the
-current process.
-Fails on systems that do not support job control.
-The return value is unspecified.
-@end deffn
-
-setsid
-@c snarfed from posix.c:787
-@deffn {Scheme Procedure} setsid
-@deffnx {C Function} scm_setsid ()
-Creates a new session. The current process becomes the session leader
-and is put in a new process group. The process will be detached
-from its controlling terminal if it has one.
-The return value is an integer representing the new process group ID.
-@end deffn
-
-ttyname
-@c snarfed from posix.c:811
-@deffn {Scheme Procedure} ttyname port
-@deffnx {C Function} scm_ttyname (port)
-Return a string with the name of the serial terminal device
-underlying @var{port}.
-@end deffn
-
-ctermid
-@c snarfed from posix.c:850
-@deffn {Scheme Procedure} ctermid
-@deffnx {C Function} scm_ctermid ()
-Return a string containing the file name of the controlling
-terminal for the current process.
-@end deffn
-
-tcgetpgrp
-@c snarfed from posix.c:874
-@deffn {Scheme Procedure} tcgetpgrp port
-@deffnx {C Function} scm_tcgetpgrp (port)
-Return the process group ID of the foreground process group
-associated with the terminal open on the file descriptor
-underlying @var{port}.
-
-If there is no foreground process group, the return value is a
-number greater than 1 that does not match the process group ID
-of any existing process group. This can happen if all of the
-processes in the job that was formerly the foreground job have
-terminated, and no other job has yet been moved into the
-foreground.
-@end deffn
-
-tcsetpgrp
-@c snarfed from posix.c:898
-@deffn {Scheme Procedure} tcsetpgrp port pgid
-@deffnx {C Function} scm_tcsetpgrp (port, pgid)
-Set the foreground process group ID for the terminal used by the file
-descriptor underlying @var{port} to the integer @var{pgid}.
-The calling process
-must be a member of the same session as @var{pgid} and must have the same
-controlling terminal. The return value is unspecified.
-@end deffn
-
-execl
-@c snarfed from posix.c:930
-@deffn {Scheme Procedure} execl filename . args
-@deffnx {C Function} scm_execl (filename, args)
-Executes the file named by @var{path} as a new process image.
-The remaining arguments are supplied to the process; from a C program
-they are accessible as the @code{argv} argument to @code{main}.
-Conventionally the first @var{arg} is the same as @var{path}.
-All arguments must be strings.
-
-If @var{arg} is missing, @var{path} is executed with a null
-argument list, which may have system-dependent side-effects.
-
-This procedure is currently implemented using the @code{execv} system
-call, but we call it @code{execl} because of its Scheme calling interface.
-@end deffn
-
-execlp
-@c snarfed from posix.c:961
-@deffn {Scheme Procedure} execlp filename . args
-@deffnx {C Function} scm_execlp (filename, args)
-Similar to @code{execl}, however if
-@var{filename} does not contain a slash
-then the file to execute will be located by searching the
-directories listed in the @code{PATH} environment variable.
-
-This procedure is currently implemented using the @code{execvp} system
-call, but we call it @code{execlp} because of its Scheme calling interface.
-@end deffn
-
-execle
-@c snarfed from posix.c:995
-@deffn {Scheme Procedure} execle filename env . args
-@deffnx {C Function} scm_execle (filename, env, args)
-Similar to @code{execl}, but the environment of the new process is
-specified by @var{env}, which must be a list of strings as returned by the
-@code{environ} procedure.
-
-This procedure is currently implemented using the @code{execve} system
-call, but we call it @code{execle} because of its Scheme calling interface.
-@end deffn
-
-primitive-fork
-@c snarfed from posix.c:1031
-@deffn {Scheme Procedure} primitive-fork
-@deffnx {C Function} scm_fork ()
-Creates a new "child" process by duplicating the current "parent" process.
-In the child the return value is 0. In the parent the return value is
-the integer process ID of the child.
-
-This procedure has been renamed from @code{fork} to avoid a naming conflict
-with the scsh fork.
-@end deffn
-
-uname
-@c snarfed from posix.c:1051
-@deffn {Scheme Procedure} uname
-@deffnx {C Function} scm_uname ()
-Return an object with some information about the computer
-system the program is running on.
-@end deffn
-
-environ
-@c snarfed from posix.c:1080
-@deffn {Scheme Procedure} environ [env]
-@deffnx {C Function} scm_environ (env)
-If @var{env} is omitted, return the current environment (in the
-Unix sense) as a list of strings. Otherwise set the current
-environment, which is also the default environment for child
-processes, to the supplied list of strings. Each member of
-@var{env} should be of the form @code{NAME=VALUE} and values of
-@code{NAME} should not be duplicated. If @var{env} is supplied
-then the return value is unspecified.
-@end deffn
-
-tmpnam
-@c snarfed from posix.c:1113
-@deffn {Scheme Procedure} tmpnam
-@deffnx {C Function} scm_tmpnam ()
-Return a name in the file system that does not match any
-existing file. However there is no guarantee that another
-process will not create the file after @code{tmpnam} is called.
-Care should be taken if opening the file, e.g., use the
-@code{O_EXCL} open flag or use @code{mkstemp!} instead.
-@end deffn
-
-mkstemp!
-@c snarfed from posix.c:1144
-@deffn {Scheme Procedure} mkstemp! tmpl
-@deffnx {C Function} scm_mkstemp (tmpl)
-Create a new unique file in the file system and returns a new
-buffered port open for reading and writing to the file.
-
-@var{tmpl} is a string specifying where the file should be
-created: it must end with @samp{XXXXXX} and will be changed in
-place to return the name of the temporary file.
-
-The file is created with mode @code{0600}, which means read and
-write for the owner only. @code{chmod} can be used to change
-this.
-@end deffn
-
-utime
-@c snarfed from posix.c:1179
-@deffn {Scheme Procedure} utime pathname [actime [modtime]]
-@deffnx {C Function} scm_utime (pathname, actime, modtime)
-@code{utime} sets the access and modification times for the
-file named by @var{path}. If @var{actime} or @var{modtime} is
-not supplied, then the current time is used. @var{actime} and
-@var{modtime} must be integer time values as returned by the
-@code{current-time} procedure.
-@lisp
-(utime "foo" (- (current-time) 3600))
-@end lisp
-will set the access time to one hour in the past and the
-modification time to the current time.
-@end deffn
-
-access?
-@c snarfed from posix.c:1244
-@deffn {Scheme Procedure} access? path how
-@deffnx {C Function} scm_access (path, how)
-Test accessibility of a file under the real UID and GID of the
-calling process. The return is @code{#t} if @var{path} exists
-and the permissions requested by @var{how} are all allowed, or
-@code{#f} if not.
-
-@var{how} is an integer which is one of the following values,
-or a bitwise-OR (@code{logior}) of multiple values.
-
-@defvar R_OK
-Test for read permission.
-@end defvar
-@defvar W_OK
-Test for write permission.
-@end defvar
-@defvar X_OK
-Test for execute permission.
-@end defvar
-@defvar F_OK
-Test for existence of the file. This is implied by each of the
-other tests, so there's no need to combine it with them.
-@end defvar
-
-It's important to note that @code{access?} does not simply
-indicate what will happen on attempting to read or write a
-file. In normal circumstances it does, but in a set-UID or
-set-GID program it doesn't because @code{access?} tests the
-real ID, whereas an open or execute attempt uses the effective
-ID.
-
-A program which will never run set-UID/GID can ignore the
-difference between real and effective IDs, but for maximum
-generality, especially in library functions, it's best not to
-use @code{access?} to predict the result of an open or execute,
-instead simply attempt that and catch any exception.
-
-The main use for @code{access?} is to let a set-UID/GID program
-determine what the invoking user would have been allowed to do,
-without the greater (or perhaps lesser) privileges afforded by
-the effective ID. For more on this, see ``Testing File
-Access'' in The GNU C Library Reference Manual.
-@end deffn
-
-getpid
-@c snarfed from posix.c:1257
-@deffn {Scheme Procedure} getpid
-@deffnx {C Function} scm_getpid ()
-Return an integer representing the current process ID.
-@end deffn
-
-putenv
-@c snarfed from posix.c:1274
-@deffn {Scheme Procedure} putenv str
-@deffnx {C Function} scm_putenv (str)
-Modifies the environment of the current process, which is
-also the default environment inherited by child processes.
-
-If @var{string} is of the form @code{NAME=VALUE} then it will be written
-directly into the environment, replacing any existing environment string
-with
-name matching @code{NAME}. If @var{string} does not contain an equal
-sign, then any existing string with name matching @var{string} will
-be removed.
-
-The return value is unspecified.
-@end deffn
-
-setlocale
-@c snarfed from posix.c:1358
-@deffn {Scheme Procedure} setlocale category [locale]
-@deffnx {C Function} scm_setlocale (category, locale)
-If @var{locale} is omitted, return the current value of the
-specified locale category as a system-dependent string.
-@var{category} should be specified using the values
-@code{LC_COLLATE}, @code{LC_ALL} etc.
-
-Otherwise the specified locale category is set to the string
-@var{locale} and the new value is returned as a
-system-dependent string. If @var{locale} is an empty string,
-the locale will be set using environment variables.
-@end deffn
-
-mknod
-@c snarfed from posix.c:1407
-@deffn {Scheme Procedure} mknod path type perms dev
-@deffnx {C Function} scm_mknod (path, type, perms, dev)
-Creates a new special file, such as a file corresponding to a device.
-@var{path} specifies the name of the file. @var{type} should
-be one of the following symbols:
-regular, directory, symlink, block-special, char-special,
-fifo, or socket. @var{perms} (an integer) specifies the file permissions.
-@var{dev} (an integer) specifies which device the special file refers
-to. Its exact interpretation depends on the kind of special file
-being created.
-
-E.g.,
-@lisp
-(mknod "/dev/fd0" 'block-special #o660 (+ (* 2 256) 2))
-@end lisp
-
-The return value is unspecified.
-@end deffn
-
-nice
-@c snarfed from posix.c:1453
-@deffn {Scheme Procedure} nice incr
-@deffnx {C Function} scm_nice (incr)
-Increment the priority of the current process by @var{incr}. A higher
-priority value means that the process runs less often.
-The return value is unspecified.
-@end deffn
-
-sync
-@c snarfed from posix.c:1471
-@deffn {Scheme Procedure} sync
-@deffnx {C Function} scm_sync ()
-Flush the operating system disk buffers.
-The return value is unspecified.
-@end deffn
-
-crypt
-@c snarfed from posix.c:1502
-@deffn {Scheme Procedure} crypt key salt
-@deffnx {C Function} scm_crypt (key, salt)
-Encrypt @var{key} using @var{salt} as the salt value to the
-crypt(3) library call.
-@end deffn
-
-chroot
-@c snarfed from posix.c:1531
-@deffn {Scheme Procedure} chroot path
-@deffnx {C Function} scm_chroot (path)
-Change the root directory to that specified in @var{path}.
-This directory will be used for path names beginning with
-@file{/}. The root directory is inherited by all children
-of the current process. Only the superuser may change the
-root directory.
-@end deffn
-
-getlogin
-@c snarfed from posix.c:1565
-@deffn {Scheme Procedure} getlogin
-@deffnx {C Function} scm_getlogin ()
-Return a string containing the name of the user logged in on
-the controlling terminal of the process, or @code{#f} if this
-information cannot be obtained.
-@end deffn
-
-cuserid
-@c snarfed from posix.c:1583
-@deffn {Scheme Procedure} cuserid
-@deffnx {C Function} scm_cuserid ()
-Return a string containing a user name associated with the
-effective user id of the process. Return @code{#f} if this
-information cannot be obtained.
-@end deffn
-
-getpriority
-@c snarfed from posix.c:1609
-@deffn {Scheme Procedure} getpriority which who
-@deffnx {C Function} scm_getpriority (which, who)
-Return the scheduling priority of the process, process group
-or user, as indicated by @var{which} and @var{who}. @var{which}
-is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP}
-or @code{PRIO_USER}, and @var{who} is interpreted relative to
-@var{which} (a process identifier for @code{PRIO_PROCESS},
-process group identifier for @code{PRIO_PGRP}, and a user
-identifier for @code{PRIO_USER}. A zero value of @var{who}
-denotes the current process, process group, or user. Return
-the highest priority (lowest numerical value) of any of the
-specified processes.
-@end deffn
-
-setpriority
-@c snarfed from posix.c:1643
-@deffn {Scheme Procedure} setpriority which who prio
-@deffnx {C Function} scm_setpriority (which, who, prio)
-Set the scheduling priority of the process, process group
-or user, as indicated by @var{which} and @var{who}. @var{which}
-is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP}
-or @code{PRIO_USER}, and @var{who} is interpreted relative to
-@var{which} (a process identifier for @code{PRIO_PROCESS},
-process group identifier for @code{PRIO_PGRP}, and a user
-identifier for @code{PRIO_USER}. A zero value of @var{who}
-denotes the current process, process group, or user.
-@var{prio} is a value in the range -20 and 20, the default
-priority is 0; lower priorities cause more favorable
-scheduling. Sets the priority of all of the specified
-processes. Only the super-user may lower priorities.
-The return value is not specified.
-@end deffn
-
-getpass
-@c snarfed from posix.c:1668
-@deffn {Scheme Procedure} getpass prompt
-@deffnx {C Function} scm_getpass (prompt)
-Display @var{prompt} to the standard error output and read
-a password from @file{/dev/tty}. If this file is not
-accessible, it reads from standard input. The password may be
-up to 127 characters in length. Additional characters and the
-terminating newline character are discarded. While reading
-the password, echoing and the generation of signals by special
-characters is disabled.
-@end deffn
-
-flock
-@c snarfed from posix.c:1780
-@deffn {Scheme Procedure} flock file operation
-@deffnx {C Function} scm_flock (file, operation)
-Apply or remove an advisory lock on an open file.
-@var{operation} specifies the action to be done:
-
-@defvar LOCK_SH
-Shared lock. More than one process may hold a shared lock
-for a given file at a given time.
-@end defvar
-@defvar LOCK_EX
-Exclusive lock. Only one process may hold an exclusive lock
-for a given file at a given time.
-@end defvar
-@defvar LOCK_UN
-Unlock the file.
-@end defvar
-@defvar LOCK_NB
-Don't block when locking. This is combined with one of the
-other operations using @code{logior}. If @code{flock} would
-block an @code{EWOULDBLOCK} error is thrown.
-@end defvar
-
-The return value is not specified. @var{file} may be an open
-file descriptor or an open file descriptor port.
-
-Note that @code{flock} does not lock files across NFS.
-@end deffn
-
-sethostname
-@c snarfed from posix.c:1805
-@deffn {Scheme Procedure} sethostname name
-@deffnx {C Function} scm_sethostname (name)
-Set the host name of the current processor to @var{name}. May
-only be used by the superuser. The return value is not
-specified.
-@end deffn
-
-gethostname
-@c snarfed from posix.c:1823
-@deffn {Scheme Procedure} gethostname
-@deffnx {C Function} scm_gethostname ()
-Return the host name of the current processor.
-@end deffn
-
-gethost
-@c snarfed from net_db.c:134
-@deffn {Scheme Procedure} gethost [host]
-@deffnx {Scheme Procedure} gethostbyname hostname
-@deffnx {Scheme Procedure} gethostbyaddr address
-@deffnx {C Function} scm_gethost (host)
-Look up a host by name or address, returning a host object. The
-@code{gethost} procedure will accept either a string name or an integer
-address; if given no arguments, it behaves like @code{gethostent} (see
-below). If a name or address is supplied but the address can not be
-found, an error will be thrown to one of the keys:
-@code{host-not-found}, @code{try-again}, @code{no-recovery} or
-@code{no-data}, corresponding to the equivalent @code{h_error} values.
-Unusual conditions may result in errors thrown to the
-@code{system-error} or @code{misc_error} keys.
-@end deffn
-
-getnet
-@c snarfed from net_db.c:216
-@deffn {Scheme Procedure} getnet [net]
-@deffnx {Scheme Procedure} getnetbyname net-name
-@deffnx {Scheme Procedure} getnetbyaddr net-number
-@deffnx {C Function} scm_getnet (net)
-Look up a network by name or net number in the network database. The
-@var{net-name} argument must be a string, and the @var{net-number}
-argument must be an integer. @code{getnet} will accept either type of
-argument, behaving like @code{getnetent} (see below) if no arguments are
-given.
-@end deffn
-
-getproto
-@c snarfed from net_db.c:268
-@deffn {Scheme Procedure} getproto [protocol]
-@deffnx {Scheme Procedure} getprotobyname name
-@deffnx {Scheme Procedure} getprotobynumber number
-@deffnx {C Function} scm_getproto (protocol)
-Look up a network protocol by name or by number. @code{getprotobyname}
-takes a string argument, and @code{getprotobynumber} takes an integer
-argument. @code{getproto} will accept either type, behaving like
-@code{getprotoent} (see below) if no arguments are supplied.
-@end deffn
-
-getserv
-@c snarfed from net_db.c:334
-@deffn {Scheme Procedure} getserv [name [protocol]]
-@deffnx {Scheme Procedure} getservbyname name protocol
-@deffnx {Scheme Procedure} getservbyport port protocol
-@deffnx {C Function} scm_getserv (name, protocol)
-Look up a network service by name or by service number, and return a
-network service object. The @var{protocol} argument specifies the name
-of the desired protocol; if the protocol found in the network service
-database does not match this name, a system error is signalled.
-
-The @code{getserv} procedure will take either a service name or number
-as its first argument; if given no arguments, it behaves like
-@code{getservent} (see below).
-@end deffn
-
-sethost
-@c snarfed from net_db.c:385
-@deffn {Scheme Procedure} sethost [stayopen]
-@deffnx {C Function} scm_sethost (stayopen)
-If @var{stayopen} is omitted, this is equivalent to @code{endhostent}.
-Otherwise it is equivalent to @code{sethostent stayopen}.
-@end deffn
-
-setnet
-@c snarfed from net_db.c:401
-@deffn {Scheme Procedure} setnet [stayopen]
-@deffnx {C Function} scm_setnet (stayopen)
-If @var{stayopen} is omitted, this is equivalent to @code{endnetent}.
-Otherwise it is equivalent to @code{setnetent stayopen}.
-@end deffn
-
-setproto
-@c snarfed from net_db.c:417
-@deffn {Scheme Procedure} setproto [stayopen]
-@deffnx {C Function} scm_setproto (stayopen)
-If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}.
-Otherwise it is equivalent to @code{setprotoent stayopen}.
-@end deffn
-
-setserv
-@c snarfed from net_db.c:433
-@deffn {Scheme Procedure} setserv [stayopen]
-@deffnx {C Function} scm_setserv (stayopen)
-If @var{stayopen} is omitted, this is equivalent to @code{endservent}.
-Otherwise it is equivalent to @code{setservent stayopen}.
-@end deffn
-
-htons
-@c snarfed from socket.c:80
-@deffn {Scheme Procedure} htons value
-@deffnx {C Function} scm_htons (value)
-Convert a 16 bit quantity from host to network byte ordering.
-@var{value} is packed into 2 bytes, which are then converted
-and returned as a new integer.
-@end deffn
-
-ntohs
-@c snarfed from socket.c:91
-@deffn {Scheme Procedure} ntohs value
-@deffnx {C Function} scm_ntohs (value)
-Convert a 16 bit quantity from network to host byte ordering.
-@var{value} is packed into 2 bytes, which are then converted
-and returned as a new integer.
-@end deffn
-
-htonl
-@c snarfed from socket.c:102
-@deffn {Scheme Procedure} htonl value
-@deffnx {C Function} scm_htonl (value)
-Convert a 32 bit quantity from host to network byte ordering.
-@var{value} is packed into 4 bytes, which are then converted
-and returned as a new integer.
-@end deffn
-
-ntohl
-@c snarfed from socket.c:115
-@deffn {Scheme Procedure} ntohl value
-@deffnx {C Function} scm_ntohl (value)
-Convert a 32 bit quantity from network to host byte ordering.
-@var{value} is packed into 4 bytes, which are then converted
-and returned as a new integer.
-@end deffn
-
-inet-aton
-@c snarfed from socket.c:135
-@deffn {Scheme Procedure} inet-aton address
-@deffnx {C Function} scm_inet_aton (address)
-Convert an IPv4 Internet address from printable string
-(dotted decimal notation) to an integer. E.g.,
-
-@lisp
-(inet-aton "127.0.0.1") @result{} 2130706433
-@end lisp
-@end deffn
-
-inet-ntoa
-@c snarfed from socket.c:158
-@deffn {Scheme Procedure} inet-ntoa inetid
-@deffnx {C Function} scm_inet_ntoa (inetid)
-Convert an IPv4 Internet address to a printable
-(dotted decimal notation) string. E.g.,
-
-@lisp
-(inet-ntoa 2130706433) @result{} "127.0.0.1"
-@end lisp
-@end deffn
-
-inet-netof
-@c snarfed from socket.c:178
-@deffn {Scheme Procedure} inet-netof address
-@deffnx {C Function} scm_inet_netof (address)
-Return the network number part of the given IPv4
-Internet address. E.g.,
-
-@lisp
-(inet-netof 2130706433) @result{} 127
-@end lisp
-@end deffn
-
-inet-lnaof
-@c snarfed from socket.c:196
-@deffn {Scheme Procedure} inet-lnaof address
-@deffnx {C Function} scm_lnaof (address)
-Return the local-address-with-network part of the given
-IPv4 Internet address, using the obsolete class A/B/C system.
-E.g.,
-
-@lisp
-(inet-lnaof 2130706433) @result{} 1
-@end lisp
-@end deffn
-
-inet-makeaddr
-@c snarfed from socket.c:214
-@deffn {Scheme Procedure} inet-makeaddr net lna
-@deffnx {C Function} scm_inet_makeaddr (net, lna)
-Make an IPv4 Internet address by combining the network number
-@var{net} with the local-address-within-network number
-@var{lna}. E.g.,
-
-@lisp
-(inet-makeaddr 127 1) @result{} 2130706433
-@end lisp
-@end deffn
-
-inet-pton
-@c snarfed from socket.c:350
-@deffn {Scheme Procedure} inet-pton family address
-@deffnx {C Function} scm_inet_pton (family, address)
-Convert a string containing a printable network address to
-an integer address. Note that unlike the C version of this
-function,
-the result is an integer with normal host byte ordering.
-@var{family} can be @code{AF_INET} or @code{AF_INET6}. E.g.,
-
-@lisp
-(inet-pton AF_INET "127.0.0.1") @result{} 2130706433
-(inet-pton AF_INET6 "::1") @result{} 1
-@end lisp
-@end deffn
-
-inet-ntop
-@c snarfed from socket.c:388
-@deffn {Scheme Procedure} inet-ntop family address
-@deffnx {C Function} scm_inet_ntop (family, address)
-Convert a network address into a printable string.
-Note that unlike the C version of this function,
-the input is an integer with normal host byte ordering.
-@var{family} can be @code{AF_INET} or @code{AF_INET6}. E.g.,
-
-@lisp
-(inet-ntop AF_INET 2130706433) @result{} "127.0.0.1"
-(inet-ntop AF_INET6 (- (expt 2 128) 1))
- @result{} "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
-@end lisp
-@end deffn
-
-socket
-@c snarfed from socket.c:430
-@deffn {Scheme Procedure} socket family style proto
-@deffnx {C Function} scm_socket (family, style, proto)
-Return a new socket port of the type specified by @var{family},
-@var{style} and @var{proto}. All three parameters are
-integers. Supported values for @var{family} are
-@code{AF_UNIX}, @code{AF_INET} and @code{AF_INET6}.
-Typical values for @var{style} are @code{SOCK_STREAM},
-@code{SOCK_DGRAM} and @code{SOCK_RAW}.
-
-@var{proto} can be obtained from a protocol name using
-@code{getprotobyname}. A value of zero specifies the default
-protocol, which is usually right.
-
-A single socket port cannot by used for communication until it
-has been connected to another socket.
-@end deffn
-
-socketpair
-@c snarfed from socket.c:451
-@deffn {Scheme Procedure} socketpair family style proto
-@deffnx {C Function} scm_socketpair (family, style, proto)
-Return a pair of connected (but unnamed) socket ports of the
-type specified by @var{family}, @var{style} and @var{proto}.
-Many systems support only socket pairs of the @code{AF_UNIX}
-family. Zero is likely to be the only meaningful value for
-@var{proto}.
-@end deffn
-
-getsockopt
-@c snarfed from socket.c:476
-@deffn {Scheme Procedure} getsockopt sock level optname
-@deffnx {C Function} scm_getsockopt (sock, level, optname)
-Return the value of a particular socket option for the socket
-port @var{sock}. @var{level} is an integer code for type of
-option being requested, e.g., @code{SOL_SOCKET} for
-socket-level options. @var{optname} is an integer code for the
-option required and should be specified using one of the
-symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc.
-
-The returned value is typically an integer but @code{SO_LINGER}
-returns a pair of integers.
-@end deffn
-
-setsockopt
-@c snarfed from socket.c:544
-@deffn {Scheme Procedure} setsockopt sock level optname value
-@deffnx {C Function} scm_setsockopt (sock, level, optname, value)
-Set the value of a particular socket option for the socket
-port @var{sock}. @var{level} is an integer code for type of option
-being set, e.g., @code{SOL_SOCKET} for socket-level options.
-@var{optname} is an
-integer code for the option to set and should be specified using one of
-the symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc.
-@var{value} is the value to which the option should be set. For
-most options this must be an integer, but for @code{SO_LINGER} it must
-be a pair.
-
-The return value is unspecified.
-@end deffn
-
-shutdown
-@c snarfed from socket.c:646
-@deffn {Scheme Procedure} shutdown sock how
-@deffnx {C Function} scm_shutdown (sock, how)
-Sockets can be closed simply by using @code{close-port}. The
-@code{shutdown} procedure allows reception or transmission on a
-connection to be shut down individually, according to the parameter
-@var{how}:
-
-@table @asis
-@item 0
-Stop receiving data for this socket. If further data arrives, reject it.
-@item 1
-Stop trying to transmit data from this socket. Discard any
-data waiting to be sent. Stop looking for acknowledgement of
-data already sent; don't retransmit it if it is lost.
-@item 2
-Stop both reception and transmission.
-@end table
-
-The return value is unspecified.
-@end deffn
-
-connect
-@c snarfed from socket.c:789
-@deffn {Scheme Procedure} connect sock fam address . args
-@deffnx {C Function} scm_connect (sock, fam, address, args)
-Initiate a connection from a socket using a specified address
-family to the address
-specified by @var{address} and possibly @var{args}.
-The format required for @var{address}
-and @var{args} depends on the family of the socket.
-
-For a socket of family @code{AF_UNIX},
-only @var{address} is specified and must be a string with the
-filename where the socket is to be created.
-
-For a socket of family @code{AF_INET},
-@var{address} must be an integer IPv4 host address and
-@var{args} must be a single integer port number.
-
-For a socket of family @code{AF_INET6},
-@var{address} must be an integer IPv6 host address and
-@var{args} may be up to three integers:
-port [flowinfo] [scope_id],
-where flowinfo and scope_id default to zero.
-
-The return value is unspecified.
-@end deffn
-
-bind
-@c snarfed from socket.c:848
-@deffn {Scheme Procedure} bind sock fam address . args
-@deffnx {C Function} scm_bind (sock, fam, address, args)
-Assign an address to the socket port @var{sock}.
-Generally this only needs to be done for server sockets,
-so they know where to look for incoming connections. A socket
-without an address will be assigned one automatically when it
-starts communicating.
-
-The format of @var{address} and @var{args} depends
-on the family of the socket.
-
-For a socket of family @code{AF_UNIX}, only @var{address}
-is specified and must be a string with the filename where
-the socket is to be created.
-
-For a socket of family @code{AF_INET}, @var{address}
-must be an integer IPv4 address and @var{args}
-must be a single integer port number.
-
-The values of the following variables can also be used for
-@var{address}:
-
-@defvar INADDR_ANY
-Allow connections from any address.
-@end defvar
-
-@defvar INADDR_LOOPBACK
-The address of the local host using the loopback device.
-@end defvar
-
-@defvar INADDR_BROADCAST
-The broadcast address on the local network.
-@end defvar
-
-@defvar INADDR_NONE
-No address.
-@end defvar
-
-For a socket of family @code{AF_INET6}, @var{address}
-must be an integer IPv6 address and @var{args}
-may be up to three integers:
-port [flowinfo] [scope_id],
-where flowinfo and scope_id default to zero.
-
-The return value is unspecified.
-@end deffn
-
-listen
-@c snarfed from socket.c:881
-@deffn {Scheme Procedure} listen sock backlog
-@deffnx {C Function} scm_listen (sock, backlog)
-Enable @var{sock} to accept connection
-requests. @var{backlog} is an integer specifying
-the maximum length of the queue for pending connections.
-If the queue fills, new clients will fail to connect until
-the server calls @code{accept} to accept a connection from
-the queue.
-
-The return value is unspecified.
-@end deffn
-
-accept
-@c snarfed from socket.c:993
-@deffn {Scheme Procedure} accept sock
-@deffnx {C Function} scm_accept (sock)
-Accept a connection on a bound, listening socket.
-If there
-are no pending connections in the queue, wait until
-one is available unless the non-blocking option has been
-set on the socket.
-
-The return value is a
-pair in which the @emph{car} is a new socket port for the
-connection and
-the @emph{cdr} is an object with address information about the
-client which initiated the connection.
-
-@var{sock} does not become part of the
-connection and will continue to accept new requests.
-@end deffn
-
-getsockname
-@c snarfed from socket.c:1020
-@deffn {Scheme Procedure} getsockname sock
-@deffnx {C Function} scm_getsockname (sock)
-Return the address of @var{sock}, in the same form as the
-object returned by @code{accept}. On many systems the address
-of a socket in the @code{AF_FILE} namespace cannot be read.
-@end deffn
-
-getpeername
-@c snarfed from socket.c:1042
-@deffn {Scheme Procedure} getpeername sock
-@deffnx {C Function} scm_getpeername (sock)
-Return the address that @var{sock}
-is connected to, in the same form as the object returned by
-@code{accept}. On many systems the address of a socket in the
-@code{AF_FILE} namespace cannot be read.
-@end deffn
-
-recv!
-@c snarfed from socket.c:1077
-@deffn {Scheme Procedure} recv! sock buf [flags]
-@deffnx {C Function} scm_recv (sock, buf, flags)
-Receive data from a socket port.
-@var{sock} must already
-be bound to the address from which data is to be received.
-@var{buf} is a string into which
-the data will be written. The size of @var{buf} limits
-the amount of
-data which can be received: in the case of packet
-protocols, if a packet larger than this limit is encountered
-then some data
-will be irrevocably lost.
-
-The optional @var{flags} argument is a value or
-bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
-
-The value returned is the number of bytes read from the
-socket.
-
-Note that the data is read directly from the socket file
-descriptor:
-any unread buffered port data is ignored.
-@end deffn
-
-send
-@c snarfed from socket.c:1120
-@deffn {Scheme Procedure} send sock message [flags]
-@deffnx {C Function} scm_send (sock, message, flags)
-Transmit the string @var{message} on a socket port @var{sock}.
-@var{sock} must already be bound to a destination address. The
-value returned is the number of bytes transmitted --
-it's possible for
-this to be less than the length of @var{message}
-if the socket is
-set to be non-blocking. The optional @var{flags} argument
-is a value or
-bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
-
-Note that the data is written directly to the socket
-file descriptor:
-any unflushed buffered port data is ignored.
-@end deffn
-
-recvfrom!
-@c snarfed from socket.c:1171
-@deffn {Scheme Procedure} recvfrom! sock str [flags [start [end]]]
-@deffnx {C Function} scm_recvfrom (sock, str, flags, start, end)
-Return data from the socket port @var{sock} and also
-information about where the data was received from.
-@var{sock} must already be bound to the address from which
-data is to be received. @code{str}, is a string into which the
-data will be written. The size of @var{str} limits the amount
-of data which can be received: in the case of packet protocols,
-if a packet larger than this limit is encountered then some
-data will be irrevocably lost.
-
-The optional @var{flags} argument is a value or bitwise OR of
-@code{MSG_OOB}, @code{MSG_PEEK}, @code{MSG_DONTROUTE} etc.
-
-The value returned is a pair: the @emph{car} is the number of
-bytes read from the socket and the @emph{cdr} an address object
-in the same form as returned by @code{accept}. The address
-will given as @code{#f} if not available, as is usually the
-case for stream sockets.
-
-The @var{start} and @var{end} arguments specify a substring of
-@var{str} to which the data should be written.
-
-Note that the data is read directly from the socket file
-descriptor: any unread buffered port data is ignored.
-@end deffn
-
-sendto
-@c snarfed from socket.c:1236
-@deffn {Scheme Procedure} sendto sock message fam address . args_and_flags
-@deffnx {C Function} scm_sendto (sock, message, fam, address, args_and_flags)
-Transmit the string @var{message} on the socket port
-@var{sock}. The
-destination address is specified using the @var{fam},
-@var{address} and
-@var{args_and_flags} arguments, in a similar way to the
-@code{connect} procedure. @var{args_and_flags} contains
-the usual connection arguments optionally followed by
-a flags argument, which is a value or
-bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
-
-The value returned is the number of bytes transmitted --
-it's possible for
-this to be less than the length of @var{message} if the
-socket is
-set to be non-blocking.
-Note that the data is written directly to the socket
-file descriptor:
-any unflushed buffered port data is ignored.
-@end deffn
-
-regexp?
-@c snarfed from regex-posix.c:106
-@deffn {Scheme Procedure} regexp? obj
-@deffnx {C Function} scm_regexp_p (obj)
-Return @code{#t} if @var{obj} is a compiled regular expression,
-or @code{#f} otherwise.
-@end deffn
-
-make-regexp
-@c snarfed from regex-posix.c:151
-@deffn {Scheme Procedure} make-regexp pat . flags
-@deffnx {C Function} scm_make_regexp (pat, flags)
-Compile the regular expression described by @var{pat}, and
-return the compiled regexp structure. If @var{pat} does not
-describe a legal regular expression, @code{make-regexp} throws
-a @code{regular-expression-syntax} error.
-
-The @var{flags} arguments change the behavior of the compiled
-regular expression. The following flags may be supplied:
-
-@table @code
-@item regexp/icase
-Consider uppercase and lowercase letters to be the same when
-matching.
-@item regexp/newline
-If a newline appears in the target string, then permit the
-@samp{^} and @samp{$} operators to match immediately after or
-immediately before the newline, respectively. Also, the
-@samp{.} and @samp{[^...]} operators will never match a newline
-character. The intent of this flag is to treat the target
-string as a buffer containing many lines of text, and the
-regular expression as a pattern that may match a single one of
-those lines.
-@item regexp/basic
-Compile a basic (``obsolete'') regexp instead of the extended
-(``modern'') regexps that are the default. Basic regexps do
-not consider @samp{|}, @samp{+} or @samp{?} to be special
-characters, and require the @samp{@{...@}} and @samp{(...)}
-metacharacters to be backslash-escaped (@pxref{Backslash
-Escapes}). There are several other differences between basic
-and extended regular expressions, but these are the most
-significant.
-@item regexp/extended
-Compile an extended regular expression rather than a basic
-regexp. This is the default behavior; this flag will not
-usually be needed. If a call to @code{make-regexp} includes
-both @code{regexp/basic} and @code{regexp/extended} flags, the
-one which comes last will override the earlier one.
-@end table
-@end deffn
-
-regexp-exec
-@c snarfed from regex-posix.c:217
-@deffn {Scheme Procedure} regexp-exec rx str [start [flags]]
-@deffnx {C Function} scm_regexp_exec (rx, str, start, flags)
-Match the compiled regular expression @var{rx} against
-@code{str}. If the optional integer @var{start} argument is
-provided, begin matching from that position in the string.
-Return a match structure describing the results of the match,
-or @code{#f} if no match could be found.
-
-The @var{flags} arguments change the matching behavior.
-The following flags may be supplied:
-
-@table @code
-@item regexp/notbol
-Operator @samp{^} always fails (unless @code{regexp/newline}
-is used). Use this when the beginning of the string should
-not be considered the beginning of a line.
-@item regexp/noteol
-Operator @samp{$} always fails (unless @code{regexp/newline}
-is used). Use this when the end of the string should not be
-considered the end of a line.
-@end table
-@end deffn
diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am
index 83c6e5ee0..05393cd96 100644
--- a/doc/ref/Makefile.am
+++ b/doc/ref/Makefile.am
@@ -75,7 +75,6 @@ guile_TEXINFOS = preface.texi \
r6rs.texi \
match.texi \
misc-modules.texi \
- api-compound.texi \
libguile-autoconf.texi \
autoconf-macros.texi \
tools.texi \
@@ -120,7 +119,7 @@ EXTRA_DIST = ChangeLog-2008 $(PICTURES)
libguile-autoconf.texi: autoconf-macros.texi
autoconf-macros.texi: $(top_srcdir)/meta/guile.m4
- GUILE_AUTO_COMPILE=0 $(top_builddir)/meta/uninstalled-env guild \
+ GUILE_AUTO_COMPILE=0 $(top_builddir)/meta/build-env guild \
snarf-guile-m4-docs $(top_srcdir)/meta/guile.m4 \
> $(srcdir)/$@
diff --git a/doc/ref/api-binding.texi b/doc/ref/api-binding.texi
index 5857e782f..c3ee01b8c 100644
--- a/doc/ref/api-binding.texi
+++ b/doc/ref/api-binding.texi
@@ -93,7 +93,7 @@ Many people end up in a development style of adding and changing
definitions at runtime, building out their program without restarting
it. (You can do this using @code{reload-module}, the @code{reload} REPL
command, the @code{load} procedure, or even just pasting code into a
-REPL.) If you are one of these people, you will find that sometimes you
+REPL.) If you are one of these people, you will find that sometimes
there are some variables that you @emph{don't} want to redefine all the
time. For these, use @code{define-once}.
@@ -301,7 +301,7 @@ following case:
(define a 1)
(define b (+ a a))
(+ a b))
-@end lisp
+@end lisp
@noindent
Guile decided to follow the R6RS in this regard, and now expands
diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi
deleted file mode 100644
index 8ec32d687..000000000
--- a/doc/ref/api-compound.texi
+++ /dev/null
@@ -1,4022 +0,0 @@
-@c -*-texinfo-*-
-@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-@c 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
-@c See the file guile.texi for copying conditions.
-
-@node Compound Data Types
-@section Compound Data Types
-
-This chapter describes Guile's compound data types. By @dfn{compound}
-we mean that the primary purpose of these data types is to act as
-containers for other kinds of data (including other compound objects).
-For instance, a (non-uniform) vector with length 5 is a container that
-can hold five arbitrary Scheme objects.
-
-The various kinds of container object differ from each other in how
-their memory is allocated, how they are indexed, and how particular
-values can be looked up within them.
-
-@menu
-* Pairs:: Scheme's basic building block.
-* Lists:: Special list functions supported by Guile.
-* Vectors:: One-dimensional arrays of Scheme objects.
-* Bit Vectors:: Vectors of bits.
-* Arrays:: Matrices, etc.
-* VLists:: Vector-like lists.
-* Record Overview:: Walking through the maze of record APIs.
-* SRFI-9 Records:: The standard, recommended record API.
-* Records:: Guile's historical record API.
-* Structures:: Low-level record representation.
-* Dictionary Types:: About dictionary types in general.
-* Association Lists:: List-based dictionaries.
-* VHashes:: VList-based dictionaries.
-* Hash Tables:: Table-based dictionaries.
-@end menu
-
-
-@node Pairs
-@subsection Pairs
-@tpindex Pairs
-
-Pairs are used to combine two Scheme objects into one compound object.
-Hence the name: A pair stores a pair of objects.
-
-The data type @dfn{pair} is extremely important in Scheme, just like in
-any other Lisp dialect. The reason is that pairs are not only used to
-make two values available as one object, but that pairs are used for
-constructing lists of values. Because lists are so important in Scheme,
-they are described in a section of their own (@pxref{Lists}).
-
-Pairs can literally get entered in source code or at the REPL, in the
-so-called @dfn{dotted list} syntax. This syntax consists of an opening
-parentheses, the first element of the pair, a dot, the second element
-and a closing parentheses. The following example shows how a pair
-consisting of the two numbers 1 and 2, and a pair containing the symbols
-@code{foo} and @code{bar} can be entered. It is very important to write
-the whitespace before and after the dot, because otherwise the Scheme
-parser would not be able to figure out where to split the tokens.
-
-@lisp
-(1 . 2)
-(foo . bar)
-@end lisp
-
-But beware, if you want to try out these examples, you have to
-@dfn{quote} the expressions. More information about quotation is
-available in the section @ref{Expression Syntax}. The correct way
-to try these examples is as follows.
-
-@lisp
-'(1 . 2)
-@result{}
-(1 . 2)
-'(foo . bar)
-@result{}
-(foo . bar)
-@end lisp
-
-A new pair is made by calling the procedure @code{cons} with two
-arguments. Then the argument values are stored into a newly allocated
-pair, and the pair is returned. The name @code{cons} stands for
-"construct". Use the procedure @code{pair?} to test whether a
-given Scheme object is a pair or not.
-
-@rnindex cons
-@deffn {Scheme Procedure} cons x y
-@deffnx {C Function} scm_cons (x, y)
-Return a newly allocated pair whose car is @var{x} and whose
-cdr is @var{y}. The pair is guaranteed to be different (in the
-sense of @code{eq?}) from every previously existing object.
-@end deffn
-
-@rnindex pair?
-@deffn {Scheme Procedure} pair? x
-@deffnx {C Function} scm_pair_p (x)
-Return @code{#t} if @var{x} is a pair; otherwise return
-@code{#f}.
-@end deffn
-
-@deftypefn {C Function} int scm_is_pair (SCM x)
-Return 1 when @var{x} is a pair; otherwise return 0.
-@end deftypefn
-
-The two parts of a pair are traditionally called @dfn{car} and
-@dfn{cdr}. They can be retrieved with procedures of the same name
-(@code{car} and @code{cdr}), and can be modified with the procedures
-@code{set-car!} and @code{set-cdr!}.
-
-Since a very common operation in Scheme programs is to access the car of
-a car of a pair, or the car of the cdr of a pair, etc., the procedures
-called @code{caar}, @code{cadr} and so on are also predefined. However,
-using these procedures is often detrimental to readability, and
-error-prone. Thus, accessing the contents of a list is usually better
-achieved using pattern matching techniques (@pxref{Pattern Matching}).
-
-@rnindex car
-@rnindex cdr
-@deffn {Scheme Procedure} car pair
-@deffnx {Scheme Procedure} cdr pair
-@deffnx {C Function} scm_car (pair)
-@deffnx {C Function} scm_cdr (pair)
-Return the car or the cdr of @var{pair}, respectively.
-@end deffn
-
-@deftypefn {C Macro} SCM SCM_CAR (SCM pair)
-@deftypefnx {C Macro} SCM SCM_CDR (SCM pair)
-These two macros are the fastest way to access the car or cdr of a
-pair; they can be thought of as compiling into a single memory
-reference.
-
-These macros do no checking at all. The argument @var{pair} must be a
-valid pair.
-@end deftypefn
-
-@deffn {Scheme Procedure} cddr pair
-@deffnx {Scheme Procedure} cdar pair
-@deffnx {Scheme Procedure} cadr pair
-@deffnx {Scheme Procedure} caar pair
-@deffnx {Scheme Procedure} cdddr pair
-@deffnx {Scheme Procedure} cddar pair
-@deffnx {Scheme Procedure} cdadr pair
-@deffnx {Scheme Procedure} cdaar pair
-@deffnx {Scheme Procedure} caddr pair
-@deffnx {Scheme Procedure} cadar pair
-@deffnx {Scheme Procedure} caadr pair
-@deffnx {Scheme Procedure} caaar pair
-@deffnx {Scheme Procedure} cddddr pair
-@deffnx {Scheme Procedure} cdddar pair
-@deffnx {Scheme Procedure} cddadr pair
-@deffnx {Scheme Procedure} cddaar pair
-@deffnx {Scheme Procedure} cdaddr pair
-@deffnx {Scheme Procedure} cdadar pair
-@deffnx {Scheme Procedure} cdaadr pair
-@deffnx {Scheme Procedure} cdaaar pair
-@deffnx {Scheme Procedure} cadddr pair
-@deffnx {Scheme Procedure} caddar pair
-@deffnx {Scheme Procedure} cadadr pair
-@deffnx {Scheme Procedure} cadaar pair
-@deffnx {Scheme Procedure} caaddr pair
-@deffnx {Scheme Procedure} caadar pair
-@deffnx {Scheme Procedure} caaadr pair
-@deffnx {Scheme Procedure} caaaar pair
-@deffnx {C Function} scm_cddr (pair)
-@deffnx {C Function} scm_cdar (pair)
-@deffnx {C Function} scm_cadr (pair)
-@deffnx {C Function} scm_caar (pair)
-@deffnx {C Function} scm_cdddr (pair)
-@deffnx {C Function} scm_cddar (pair)
-@deffnx {C Function} scm_cdadr (pair)
-@deffnx {C Function} scm_cdaar (pair)
-@deffnx {C Function} scm_caddr (pair)
-@deffnx {C Function} scm_cadar (pair)
-@deffnx {C Function} scm_caadr (pair)
-@deffnx {C Function} scm_caaar (pair)
-@deffnx {C Function} scm_cddddr (pair)
-@deffnx {C Function} scm_cdddar (pair)
-@deffnx {C Function} scm_cddadr (pair)
-@deffnx {C Function} scm_cddaar (pair)
-@deffnx {C Function} scm_cdaddr (pair)
-@deffnx {C Function} scm_cdadar (pair)
-@deffnx {C Function} scm_cdaadr (pair)
-@deffnx {C Function} scm_cdaaar (pair)
-@deffnx {C Function} scm_cadddr (pair)
-@deffnx {C Function} scm_caddar (pair)
-@deffnx {C Function} scm_cadadr (pair)
-@deffnx {C Function} scm_cadaar (pair)
-@deffnx {C Function} scm_caaddr (pair)
-@deffnx {C Function} scm_caadar (pair)
-@deffnx {C Function} scm_caaadr (pair)
-@deffnx {C Function} scm_caaaar (pair)
-These procedures are compositions of @code{car} and @code{cdr}, where
-for example @code{caddr} could be defined by
-
-@lisp
-(define caddr (lambda (x) (car (cdr (cdr x)))))
-@end lisp
-
-@code{cadr}, @code{caddr} and @code{cadddr} pick out the second, third
-or fourth elements of a list, respectively. SRFI-1 provides the same
-under the names @code{second}, @code{third} and @code{fourth}
-(@pxref{SRFI-1 Selectors}).
-@end deffn
-
-@rnindex set-car!
-@deffn {Scheme Procedure} set-car! pair value
-@deffnx {C Function} scm_set_car_x (pair, value)
-Stores @var{value} in the car field of @var{pair}. The value returned
-by @code{set-car!} is unspecified.
-@end deffn
-
-@rnindex set-cdr!
-@deffn {Scheme Procedure} set-cdr! pair value
-@deffnx {C Function} scm_set_cdr_x (pair, value)
-Stores @var{value} in the cdr field of @var{pair}. The value returned
-by @code{set-cdr!} is unspecified.
-@end deffn
-
-
-@node Lists
-@subsection Lists
-@tpindex Lists
-
-A very important data type in Scheme---as well as in all other Lisp
-dialects---is the data type @dfn{list}.@footnote{Strictly speaking,
-Scheme does not have a real datatype @dfn{list}. Lists are made up of
-@dfn{chained pairs}, and only exist by definition---a list is a chain
-of pairs which looks like a list.}
-
-This is the short definition of what a list is:
-
-@itemize @bullet
-@item
-Either the empty list @code{()},
-
-@item
-or a pair which has a list in its cdr.
-@end itemize
-
-@c FIXME::martin: Describe the pair chaining in more detail.
-
-@c FIXME::martin: What is a proper, what an improper list?
-@c What is a circular list?
-
-@c FIXME::martin: Maybe steal some graphics from the Elisp reference
-@c manual?
-
-@menu
-* List Syntax:: Writing literal lists.
-* List Predicates:: Testing lists.
-* List Constructors:: Creating new lists.
-* List Selection:: Selecting from lists, getting their length.
-* Append/Reverse:: Appending and reversing lists.
-* List Modification:: Modifying existing lists.
-* List Searching:: Searching for list elements
-* List Mapping:: Applying procedures to lists.
-@end menu
-
-@node List Syntax
-@subsubsection List Read Syntax
-
-The syntax for lists is an opening parentheses, then all the elements of
-the list (separated by whitespace) and finally a closing
-parentheses.@footnote{Note that there is no separation character between
-the list elements, like a comma or a semicolon.}.
-
-@lisp
-(1 2 3) ; @r{a list of the numbers 1, 2 and 3}
-("foo" bar 3.1415) ; @r{a string, a symbol and a real number}
-() ; @r{the empty list}
-@end lisp
-
-The last example needs a bit more explanation. A list with no elements,
-called the @dfn{empty list}, is special in some ways. It is used for
-terminating lists by storing it into the cdr of the last pair that makes
-up a list. An example will clear that up:
-
-@lisp
-(car '(1))
-@result{}
-1
-(cdr '(1))
-@result{}
-()
-@end lisp
-
-This example also shows that lists have to be quoted when written
-(@pxref{Expression Syntax}), because they would otherwise be
-mistakingly taken as procedure applications (@pxref{Simple
-Invocation}).
-
-
-@node List Predicates
-@subsubsection List Predicates
-
-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
-whether their input is valid, or they could do different things
-depending on the datatype of their arguments.
-
-@rnindex list?
-@deffn {Scheme Procedure} list? x
-@deffnx {C Function} scm_list_p (x)
-Return @code{#t} if @var{x} is a proper list, else @code{#f}.
-@end deffn
-
-The predicate @code{null?} is often used in list-processing code to
-tell whether a given list has run out of elements. That is, a loop
-somehow deals with the elements of a list until the list satisfies
-@code{null?}. Then, the algorithm terminates.
-
-@rnindex null?
-@deffn {Scheme Procedure} null? x
-@deffnx {C Function} scm_null_p (x)
-Return @code{#t} if @var{x} is the empty list, else @code{#f}.
-@end deffn
-
-@deftypefn {C Function} int scm_is_null (SCM x)
-Return 1 when @var{x} is the empty list; otherwise return 0.
-@end deftypefn
-
-
-@node List Constructors
-@subsubsection List Constructors
-
-This section describes the procedures for constructing new lists.
-@code{list} simply returns a list where the elements are the arguments,
-@code{cons*} is similar, but the last argument is stored in the cdr of
-the last pair of the list.
-
-@c C Function scm_list(rest) used to be documented here, but it's a
-@c no-op since it does nothing but return the list the caller must
-@c have already created.
-@c
-@deffn {Scheme Procedure} list elem @dots{}
-@deffnx {C Function} scm_list_1 (elem1)
-@deffnx {C Function} scm_list_2 (elem1, elem2)
-@deffnx {C Function} scm_list_3 (elem1, elem2, elem3)
-@deffnx {C Function} scm_list_4 (elem1, elem2, elem3, elem4)
-@deffnx {C Function} scm_list_5 (elem1, elem2, elem3, elem4, elem5)
-@deffnx {C Function} scm_list_n (elem1, @dots{}, elemN, @nicode{SCM_UNDEFINED})
-@rnindex list
-Return a new list containing elements @var{elem} @enddots{}.
-
-@code{scm_list_n} takes a variable number of arguments, terminated by
-the special @code{SCM_UNDEFINED}. That final @code{SCM_UNDEFINED} is
-not included in the list. None of @var{elem} @dots{} can
-themselves be @code{SCM_UNDEFINED}, or @code{scm_list_n} will
-terminate at that point.
-@end deffn
-
-@c C Function scm_cons_star(arg1,rest) used to be documented here,
-@c but it's not really a useful interface, since it expects the
-@c caller to have already consed up all but the first argument
-@c already.
-@c
-@deffn {Scheme Procedure} cons* arg1 arg2 @dots{}
-Like @code{list}, but the last arg provides the tail of the
-constructed list, returning @code{(cons @var{arg1} (cons
-@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one
-argument. If given one argument, that argument is returned as
-result. This function is called @code{list*} in some other
-Schemes and in Common LISP.
-@end deffn
-
-@deffn {Scheme Procedure} list-copy lst
-@deffnx {C Function} scm_list_copy (lst)
-Return a (newly-created) copy of @var{lst}.
-@end deffn
-
-@deffn {Scheme Procedure} make-list n [init]
-Create a list containing of @var{n} elements, where each element is
-initialized to @var{init}. @var{init} defaults to the empty list
-@code{()} if not given.
-@end deffn
-
-Note that @code{list-copy} only makes a copy of the pairs which make up
-the spine of the lists. The list elements are not copied, which means
-that modifying the elements of the new list also modifies the elements
-of the old list. On the other hand, applying procedures like
-@code{set-cdr!} or @code{delv!} to the new list will not alter the old
-list. If you also need to copy the list elements (making a deep copy),
-use the procedure @code{copy-tree} (@pxref{Copying}).
-
-@node List Selection
-@subsubsection List Selection
-
-These procedures are used to get some information about a list, or to
-retrieve one or more elements of a list.
-
-@rnindex length
-@deffn {Scheme Procedure} length lst
-@deffnx {C Function} scm_length (lst)
-Return the number of elements in list @var{lst}.
-@end deffn
-
-@deffn {Scheme Procedure} last-pair lst
-@deffnx {C Function} scm_last_pair (lst)
-Return the last pair in @var{lst}, signalling an error if
-@var{lst} is circular.
-@end deffn
-
-@rnindex list-ref
-@deffn {Scheme Procedure} list-ref list k
-@deffnx {C Function} scm_list_ref (list, k)
-Return the @var{k}th element from @var{list}.
-@end deffn
-
-@rnindex list-tail
-@deffn {Scheme Procedure} list-tail lst k
-@deffnx {Scheme Procedure} list-cdr-ref lst k
-@deffnx {C Function} scm_list_tail (lst, k)
-Return the "tail" of @var{lst} beginning with its @var{k}th element.
-The first element of the list is considered to be element 0.
-
-@code{list-tail} and @code{list-cdr-ref} are identical. It may help to
-think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list,
-or returning the results of cdring @var{k} times down @var{lst}.
-@end deffn
-
-@deffn {Scheme Procedure} list-head lst k
-@deffnx {C Function} scm_list_head (lst, k)
-Copy the first @var{k} elements from @var{lst} into a new list, and
-return it.
-@end deffn
-
-@node Append/Reverse
-@subsubsection Append and Reverse
-
-@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!}
-return lists with the same elements as their arguments, but in reverse
-order. The procedure variants with an @code{!} directly modify the
-pairs which form the list, whereas the other procedures create new
-pairs. This is why you should be careful when using the side-effecting
-variants.
-
-@rnindex append
-@deffn {Scheme Procedure} append lst @dots{} obj
-@deffnx {Scheme Procedure} append
-@deffnx {Scheme Procedure} append! lst @dots{} obj
-@deffnx {Scheme Procedure} append!
-@deffnx {C Function} scm_append (lstlst)
-@deffnx {C Function} scm_append_x (lstlst)
-Return a list comprising all the elements of lists @var{lst} @dots{}
-@var{obj}. If called with no arguments, return the empty list.
-
-@lisp
-(append '(x) '(y)) @result{} (x y)
-(append '(a) '(b c d)) @result{} (a b c d)
-(append '(a (b)) '((c))) @result{} (a (b) (c))
-@end lisp
-
-The last argument @var{obj} may actually be any object; an improper
-list results if the last argument is not a proper list.
-
-@lisp
-(append '(a b) '(c . d)) @result{} (a b c . d)
-(append '() 'a) @result{} a
-@end lisp
-
-@code{append} doesn't modify the given lists, but the return may share
-structure with the final @var{obj}. @code{append!} is permitted, but
-not required, to modify the given lists to form its return.
-
-For @code{scm_append} and @code{scm_append_x}, @var{lstlst} is a list
-of the list operands @var{lst} @dots{} @var{obj}. That @var{lstlst}
-itself is not modified or used in the return.
-@end deffn
-
-@rnindex reverse
-@deffn {Scheme Procedure} reverse lst
-@deffnx {Scheme Procedure} reverse! lst [newtail]
-@deffnx {C Function} scm_reverse (lst)
-@deffnx {C Function} scm_reverse_x (lst, newtail)
-Return a list comprising the elements of @var{lst}, in reverse order.
-
-@code{reverse} constructs a new list. @code{reverse!} is permitted, but
-not required, to modify @var{lst} in constructing its return.
-
-For @code{reverse!}, the optional @var{newtail} is appended to the
-result. @var{newtail} isn't reversed, it simply becomes the list
-tail. For @code{scm_reverse_x}, the @var{newtail} parameter is
-mandatory, but can be @code{SCM_EOL} if no further tail is required.
-@end deffn
-
-@node List Modification
-@subsubsection List Modification
-
-The following procedures modify an existing list, either by changing
-elements of the list, or by changing the list structure itself.
-
-@deffn {Scheme Procedure} list-set! list k val
-@deffnx {C Function} scm_list_set_x (list, k, val)
-Set the @var{k}th element of @var{list} to @var{val}.
-@end deffn
-
-@deffn {Scheme Procedure} list-cdr-set! list k val
-@deffnx {C Function} scm_list_cdr_set_x (list, k, val)
-Set the @var{k}th cdr of @var{list} to @var{val}.
-@end deffn
-
-@deffn {Scheme Procedure} delq item lst
-@deffnx {C Function} scm_delq (item, lst)
-Return a newly-created copy of @var{lst} with elements
-@code{eq?} to @var{item} removed. This procedure mirrors
-@code{memq}: @code{delq} compares elements of @var{lst} against
-@var{item} with @code{eq?}.
-@end deffn
-
-@deffn {Scheme Procedure} delv item lst
-@deffnx {C Function} scm_delv (item, lst)
-Return a newly-created copy of @var{lst} with elements
-@code{eqv?} to @var{item} removed. This procedure mirrors
-@code{memv}: @code{delv} compares elements of @var{lst} against
-@var{item} with @code{eqv?}.
-@end deffn
-
-@deffn {Scheme Procedure} delete item lst
-@deffnx {C Function} scm_delete (item, lst)
-Return a newly-created copy of @var{lst} with elements
-@code{equal?} to @var{item} removed. This procedure mirrors
-@code{member}: @code{delete} compares elements of @var{lst}
-against @var{item} with @code{equal?}.
-
-See also SRFI-1 which has an extended @code{delete} (@ref{SRFI-1
-Deleting}), and also an @code{lset-difference} which can delete
-multiple @var{item}s in one call (@ref{SRFI-1 Set Operations}).
-@end deffn
-
-@deffn {Scheme Procedure} delq! item lst
-@deffnx {Scheme Procedure} delv! item lst
-@deffnx {Scheme Procedure} delete! item lst
-@deffnx {C Function} scm_delq_x (item, lst)
-@deffnx {C Function} scm_delv_x (item, lst)
-@deffnx {C Function} scm_delete_x (item, lst)
-These procedures are destructive versions of @code{delq}, @code{delv}
-and @code{delete}: they modify the pointers in the existing @var{lst}
-rather than creating a new list. Caveat evaluator: Like other
-destructive list functions, these functions cannot modify the binding of
-@var{lst}, and so cannot be used to delete the first element of
-@var{lst} destructively.
-@end deffn
-
-@deffn {Scheme Procedure} delq1! item lst
-@deffnx {C Function} scm_delq1_x (item, lst)
-Like @code{delq!}, but only deletes the first occurrence of
-@var{item} from @var{lst}. Tests for equality using
-@code{eq?}. See also @code{delv1!} and @code{delete1!}.
-@end deffn
-
-@deffn {Scheme Procedure} delv1! item lst
-@deffnx {C Function} scm_delv1_x (item, lst)
-Like @code{delv!}, but only deletes the first occurrence of
-@var{item} from @var{lst}. Tests for equality using
-@code{eqv?}. See also @code{delq1!} and @code{delete1!}.
-@end deffn
-
-@deffn {Scheme Procedure} delete1! item lst
-@deffnx {C Function} scm_delete1_x (item, lst)
-Like @code{delete!}, but only deletes the first occurrence of
-@var{item} from @var{lst}. Tests for equality using
-@code{equal?}. See also @code{delq1!} and @code{delv1!}.
-@end deffn
-
-@deffn {Scheme Procedure} filter pred lst
-@deffnx {Scheme Procedure} filter! pred lst
-Return a list containing all elements from @var{lst} which satisfy the
-predicate @var{pred}. The elements in the result list have the same
-order as in @var{lst}. The order in which @var{pred} is applied to
-the list elements is not specified.
-
-@code{filter} does not change @var{lst}, but the result may share a
-tail with it. @code{filter!} may modify @var{lst} to construct its
-return.
-@end deffn
-
-@node List Searching
-@subsubsection List Searching
-
-The following procedures search lists for particular elements. They use
-different comparison predicates for comparing list elements with the
-object to be searched. When they fail, they return @code{#f}, otherwise
-they return the sublist whose car is equal to the search object, where
-equality depends on the equality predicate used.
-
-@rnindex memq
-@deffn {Scheme Procedure} memq x lst
-@deffnx {C Function} scm_memq (x, lst)
-Return the first sublist of @var{lst} whose car is @code{eq?}
-to @var{x} where the sublists of @var{lst} are the non-empty
-lists returned by @code{(list-tail @var{lst} @var{k})} for
-@var{k} less than the length of @var{lst}. If @var{x} does not
-occur in @var{lst}, then @code{#f} (not the empty list) is
-returned.
-@end deffn
-
-@rnindex memv
-@deffn {Scheme Procedure} memv x lst
-@deffnx {C Function} scm_memv (x, lst)
-Return the first sublist of @var{lst} whose car is @code{eqv?}
-to @var{x} where the sublists of @var{lst} are the non-empty
-lists returned by @code{(list-tail @var{lst} @var{k})} for
-@var{k} less than the length of @var{lst}. If @var{x} does not
-occur in @var{lst}, then @code{#f} (not the empty list) is
-returned.
-@end deffn
-
-@rnindex member
-@deffn {Scheme Procedure} member x lst
-@deffnx {C Function} scm_member (x, lst)
-Return the first sublist of @var{lst} whose car is
-@code{equal?} to @var{x} where the sublists of @var{lst} are
-the non-empty lists returned by @code{(list-tail @var{lst}
-@var{k})} for @var{k} less than the length of @var{lst}. If
-@var{x} does not occur in @var{lst}, then @code{#f} (not the
-empty list) is returned.
-
-See also SRFI-1 which has an extended @code{member} function
-(@ref{SRFI-1 Searching}).
-@end deffn
-
-
-@node List Mapping
-@subsubsection List Mapping
-
-List processing is very convenient in Scheme because the process of
-iterating over the elements of a list can be highly abstracted. The
-procedures in this section are the most basic iterating procedures for
-lists. They take a procedure and one or more lists as arguments, and
-apply the procedure to each element of the list. They differ in their
-return value.
-
-@rnindex map
-@c begin (texi-doc-string "guile" "map")
-@deffn {Scheme Procedure} map proc arg1 arg2 @dots{}
-@deffnx {Scheme Procedure} map-in-order proc arg1 arg2 @dots{}
-@deffnx {C Function} scm_map (proc, arg1, args)
-Apply @var{proc} to each element of the list @var{arg1} (if only two
-arguments are given), or to the corresponding elements of the argument
-lists (if more than two arguments are given). The result(s) of the
-procedure applications are saved and returned in a list. For
-@code{map}, the order of procedure applications is not specified,
-@code{map-in-order} applies the procedure from left to right to the list
-elements.
-@end deffn
-
-@rnindex for-each
-@c begin (texi-doc-string "guile" "for-each")
-@deffn {Scheme Procedure} for-each proc arg1 arg2 @dots{}
-Like @code{map}, but the procedure is always applied from left to right,
-and the result(s) of the procedure applications are thrown away. The
-return value is not specified.
-@end deffn
-
-See also SRFI-1 which extends these functions to take lists of unequal
-lengths (@ref{SRFI-1 Fold and Map}).
-
-@node Vectors
-@subsection Vectors
-@tpindex Vectors
-
-Vectors are sequences of Scheme objects. Unlike lists, the length of a
-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
-given its @dfn{position} (synonymous with @dfn{index}), a zero-origin number,
-is constant, whereas lists have an access time linear to the position of the
-accessed element in the list.
-
-Vectors can contain any kind of Scheme object; it is even possible to
-have different types of objects in the same vector. For vectors
-containing vectors, you may wish to use arrays, instead. Note, too,
-that vectors are the special case of one dimensional non-uniform arrays
-and that most array procedures operate happily on vectors
-(@pxref{Arrays}).
-
-Also see @ref{SRFI-43}, for a comprehensive vector library.
-
-@menu
-* Vector Syntax:: Read syntax for vectors.
-* Vector Creation:: Dynamic vector creation and validation.
-* Vector Accessors:: Accessing and modifying vector contents.
-* Vector Accessing from C:: Ways to work with vectors from C.
-* Uniform Numeric Vectors:: Vectors of unboxed numeric values.
-@end menu
-
-
-@node Vector Syntax
-@subsubsection Read Syntax for Vectors
-
-Vectors can literally be entered in source code, just like strings,
-characters or some of the other data types. The read syntax for vectors
-is as follows: A sharp sign (@code{#}), followed by an opening
-parentheses, all elements of the vector in their respective read syntax,
-and finally a closing parentheses. Like strings, vectors do not have to
-be quoted.
-
-The following are examples of the read syntax for vectors; where the
-first vector only contains numbers and the second three different object
-types: a string, a symbol and a number in hexadecimal notation.
-
-@lisp
-#(1 2 3)
-#("Hello" foo #xdeadbeef)
-@end lisp
-
-@node Vector Creation
-@subsubsection Dynamic Vector Creation and Validation
-
-Instead of creating a vector implicitly by using the read syntax just
-described, you can create a vector dynamically by calling one of the
-@code{vector} and @code{list->vector} primitives with the list of Scheme
-values that you want to place into a vector. The size of the vector
-thus created is determined implicitly by the number of arguments given.
-
-@rnindex vector
-@rnindex list->vector
-@deffn {Scheme Procedure} vector arg @dots{}
-@deffnx {Scheme Procedure} list->vector l
-@deffnx {C Function} scm_vector (l)
-Return a newly allocated vector composed of the
-given arguments. Analogous to @code{list}.
-
-@lisp
-(vector 'a 'b 'c) @result{} #(a b c)
-@end lisp
-@end deffn
-
-The inverse operation is @code{vector->list}:
-
-@rnindex vector->list
-@deffn {Scheme Procedure} vector->list v
-@deffnx {C Function} scm_vector_to_list (v)
-Return a newly allocated list composed of the elements of @var{v}.
-
-@lisp
-(vector->list #(dah dah didah)) @result{} (dah dah didah)
-(list->vector '(dididit dah)) @result{} #(dididit dah)
-@end lisp
-@end deffn
-
-To allocate a vector with an explicitly specified size, use
-@code{make-vector}. With this primitive you can also specify an initial
-value for the vector elements (the same value for all elements, that
-is):
-
-@rnindex make-vector
-@deffn {Scheme Procedure} make-vector len [fill]
-@deffnx {C Function} scm_make_vector (len, fill)
-Return a newly allocated vector of @var{len} elements. If a
-second argument is given, then each position is initialized to
-@var{fill}. Otherwise the initial contents of each position is
-unspecified.
-@end deffn
-
-@deftypefn {C Function} SCM scm_c_make_vector (size_t k, SCM fill)
-Like @code{scm_make_vector}, but the length is given as a @code{size_t}.
-@end deftypefn
-
-To check whether an arbitrary Scheme value @emph{is} a vector, use the
-@code{vector?} primitive:
-
-@rnindex vector?
-@deffn {Scheme Procedure} vector? obj
-@deffnx {C Function} scm_vector_p (obj)
-Return @code{#t} if @var{obj} is a vector, otherwise return
-@code{#f}.
-@end deffn
-
-@deftypefn {C Function} int scm_is_vector (SCM obj)
-Return non-zero when @var{obj} is a vector, otherwise return
-@code{zero}.
-@end deftypefn
-
-@node Vector Accessors
-@subsubsection Accessing and Modifying Vector Contents
-
-@code{vector-length} and @code{vector-ref} return information about a
-given vector, respectively its size and the elements that are contained
-in the vector.
-
-@rnindex vector-length
-@deffn {Scheme Procedure} vector-length vector
-@deffnx {C Function} scm_vector_length (vector)
-Return the number of elements in @var{vector} as an exact integer.
-@end deffn
-
-@deftypefn {C Function} size_t scm_c_vector_length (SCM vec)
-Return the number of elements in @var{vec} as a @code{size_t}.
-@end deftypefn
-
-@rnindex vector-ref
-@deffn {Scheme Procedure} vector-ref vec k
-@deffnx {C Function} scm_vector_ref (vec, k)
-Return the contents of position @var{k} of @var{vec}.
-@var{k} must be a valid index of @var{vec}.
-@lisp
-(vector-ref #(1 1 2 3 5 8 13 21) 5) @result{} 8
-(vector-ref #(1 1 2 3 5 8 13 21)
- (let ((i (round (* 2 (acos -1)))))
- (if (inexact? i)
- (inexact->exact i)
- i))) @result{} 13
-@end lisp
-@end deffn
-
-@deftypefn {C Function} SCM scm_c_vector_ref (SCM vec, size_t k)
-Return the contents of position @var{k} (a @code{size_t}) of
-@var{vec}.
-@end deftypefn
-
-A vector created by one of the dynamic vector constructor procedures
-(@pxref{Vector Creation}) can be modified using the following
-procedures.
-
-@emph{NOTE:} According to R5RS, it is an error to use any of these
-procedures on a literally read vector, because such vectors should be
-considered as constants. Currently, however, Guile does not detect this
-error.
-
-@rnindex vector-set!
-@deffn {Scheme Procedure} vector-set! vec k obj
-@deffnx {C Function} scm_vector_set_x (vec, k, obj)
-Store @var{obj} in position @var{k} of @var{vec}.
-@var{k} must be a valid index of @var{vec}.
-The value returned by @samp{vector-set!} is unspecified.
-@lisp
-(let ((vec (vector 0 '(2 2 2 2) "Anna")))
- (vector-set! vec 1 '("Sue" "Sue"))
- vec) @result{} #(0 ("Sue" "Sue") "Anna")
-@end lisp
-@end deffn
-
-@deftypefn {C Function} void scm_c_vector_set_x (SCM vec, size_t k, SCM obj)
-Store @var{obj} in position @var{k} (a @code{size_t}) of @var{vec}.
-@end deftypefn
-
-@rnindex vector-fill!
-@deffn {Scheme Procedure} vector-fill! vec fill
-@deffnx {C Function} scm_vector_fill_x (vec, fill)
-Store @var{fill} in every position of @var{vec}. The value
-returned by @code{vector-fill!} is unspecified.
-@end deffn
-
-@deffn {Scheme Procedure} vector-copy vec
-@deffnx {C Function} scm_vector_copy (vec)
-Return a copy of @var{vec}.
-@end deffn
-
-@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2
-@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2)
-Copy elements from @var{vec1}, positions @var{start1} to @var{end1},
-to @var{vec2} starting at position @var{start2}. @var{start1} and
-@var{start2} are inclusive indices; @var{end1} is exclusive.
-
-@code{vector-move-left!} copies elements in leftmost order.
-Therefore, in the case where @var{vec1} and @var{vec2} refer to the
-same vector, @code{vector-move-left!} is usually appropriate when
-@var{start1} is greater than @var{start2}.
-@end deffn
-
-@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2
-@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2)
-Copy elements from @var{vec1}, positions @var{start1} to @var{end1},
-to @var{vec2} starting at position @var{start2}. @var{start1} and
-@var{start2} are inclusive indices; @var{end1} is exclusive.
-
-@code{vector-move-right!} copies elements in rightmost order.
-Therefore, in the case where @var{vec1} and @var{vec2} refer to the
-same vector, @code{vector-move-right!} is usually appropriate when
-@var{start1} is less than @var{start2}.
-@end deffn
-
-@node Vector Accessing from C
-@subsubsection Vector Accessing from C
-
-A vector can be read and modified from C with the functions
-@code{scm_c_vector_ref} and @code{scm_c_vector_set_x}, for example. In
-addition to these functions, there are two more ways to access vectors
-from C that might be more efficient in certain situations: you can
-restrict yourself to @dfn{simple vectors} and then use the very fast
-@emph{simple vector macros}; or you can use the very general framework
-for accessing all kinds of arrays (@pxref{Accessing Arrays from C}),
-which is more verbose, but can deal efficiently with all kinds of
-vectors (and arrays). For vectors, you can use the
-@code{scm_vector_elements} and @code{scm_vector_writable_elements}
-functions as shortcuts.
-
-@deftypefn {C Function} int scm_is_simple_vector (SCM obj)
-Return non-zero if @var{obj} is a simple vector, else return zero. A
-simple vector is a vector that can be used with the @code{SCM_SIMPLE_*}
-macros below.
-
-The following functions are guaranteed to return simple vectors:
-@code{scm_make_vector}, @code{scm_c_make_vector}, @code{scm_vector},
-@code{scm_list_to_vector}.
-@end deftypefn
-
-@deftypefn {C Macro} size_t SCM_SIMPLE_VECTOR_LENGTH (SCM vec)
-Evaluates to the length of the simple vector @var{vec}. No type
-checking is done.
-@end deftypefn
-
-@deftypefn {C Macro} SCM SCM_SIMPLE_VECTOR_REF (SCM vec, size_t idx)
-Evaluates to the element at position @var{idx} in the simple vector
-@var{vec}. No type or range checking is done.
-@end deftypefn
-
-@deftypefn {C Macro} void SCM_SIMPLE_VECTOR_SET (SCM vec, size_t idx, SCM val)
-Sets the element at position @var{idx} in the simple vector
-@var{vec} to @var{val}. No type or range checking is done.
-@end deftypefn
-
-@deftypefn {C Function} {const SCM *} scm_vector_elements (SCM vec, scm_t_array_handle *handle, size_t *lenp, ssize_t *incp)
-Acquire a handle for the vector @var{vec} and return a pointer to the
-elements of it. This pointer can only be used to read the elements of
-@var{vec}. When @var{vec} is not a vector, an error is signaled. The
-handle must eventually be released with
-@code{scm_array_handle_release}.
-
-The variables pointed to by @var{lenp} and @var{incp} are filled with
-the number of elements of the vector and the increment (number of
-elements) between successive elements, respectively. Successive
-elements of @var{vec} need not be contiguous in their underlying
-``root vector'' returned here; hence the increment is not necessarily
-equal to 1 and may well be negative too (@pxref{Shared Arrays}).
-
-The following example shows the typical way to use this function. It
-creates a list of all elements of @var{vec} (in reverse order).
-
-@example
-scm_t_array_handle handle;
-size_t i, len;
-ssize_t inc;
-const SCM *elt;
-SCM list;
-
-elt = scm_vector_elements (vec, &handle, &len, &inc);
-list = SCM_EOL;
-for (i = 0; i < len; i++, elt += inc)
- list = scm_cons (*elt, list);
-scm_array_handle_release (&handle);
-@end example
-
-@end deftypefn
-
-@deftypefn {C Function} {SCM *} scm_vector_writable_elements (SCM vec, scm_t_array_handle *handle, size_t *lenp, ssize_t *incp)
-Like @code{scm_vector_elements} but the pointer can be used to modify
-the vector.
-
-The following example shows the typical way to use this function. It
-fills a vector with @code{#t}.
-
-@example
-scm_t_array_handle handle;
-size_t i, len;
-ssize_t inc;
-SCM *elt;
-
-elt = scm_vector_writable_elements (vec, &handle, &len, &inc);
-for (i = 0; i < len; i++, elt += inc)
- *elt = SCM_BOOL_T;
-scm_array_handle_release (&handle);
-@end example
-
-@end deftypefn
-
-@node Uniform Numeric Vectors
-@subsubsection Uniform Numeric Vectors
-
-A uniform numeric vector is a vector whose elements are all of a single
-numeric type. Guile offers uniform numeric vectors for signed and
-unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of
-floating point values, and complex floating-point numbers of these two
-sizes. @xref{SRFI-4}, for more information.
-
-For many purposes, bytevectors work just as well as uniform vectors, and have
-the advantage that they integrate well with binary input and output.
-@xref{Bytevectors}, for more information on bytevectors.
-
-@node Bit Vectors
-@subsection Bit Vectors
-
-@noindent
-Bit vectors are zero-origin, one-dimensional arrays of booleans. They
-are displayed as a sequence of @code{0}s and @code{1}s prefixed by
-@code{#*}, e.g.,
-
-@example
-(make-bitvector 8 #f) @result{}
-#*00000000
-@end example
-
-Bit vectors are the special case of one dimensional bit arrays, and can
-thus be used with the array procedures, @xref{Arrays}.
-
-@deffn {Scheme Procedure} bitvector? obj
-@deffnx {C Function} scm_bitvector_p (obj)
-Return @code{#t} when @var{obj} is a bitvector, else
-return @code{#f}.
-@end deffn
-
-@deftypefn {C Function} int scm_is_bitvector (SCM obj)
-Return @code{1} when @var{obj} is a bitvector, else return @code{0}.
-@end deftypefn
-
-@deffn {Scheme Procedure} make-bitvector len [fill]
-@deffnx {C Function} scm_make_bitvector (len, fill)
-Create a new bitvector of length @var{len} and
-optionally initialize all elements to @var{fill}.
-@end deffn
-
-@deftypefn {C Function} SCM scm_c_make_bitvector (size_t len, SCM fill)
-Like @code{scm_make_bitvector}, but the length is given as a
-@code{size_t}.
-@end deftypefn
-
-@deffn {Scheme Procedure} bitvector bit @dots{}
-@deffnx {C Function} scm_bitvector (bits)
-Create a new bitvector with the arguments as elements.
-@end deffn
-
-@deffn {Scheme Procedure} bitvector-length vec
-@deffnx {C Function} scm_bitvector_length (vec)
-Return the length of the bitvector @var{vec}.
-@end deffn
-
-@deftypefn {C Function} size_t scm_c_bitvector_length (SCM vec)
-Like @code{scm_bitvector_length}, but the length is returned as a
-@code{size_t}.
-@end deftypefn
-
-@deffn {Scheme Procedure} bitvector-ref vec idx
-@deffnx {C Function} scm_bitvector_ref (vec, idx)
-Return the element at index @var{idx} of the bitvector
-@var{vec}.
-@end deffn
-
-@deftypefn {C Function} SCM scm_c_bitvector_ref (SCM vec, size_t idx)
-Return the element at index @var{idx} of the bitvector
-@var{vec}.
-@end deftypefn
-
-@deffn {Scheme Procedure} bitvector-set! vec idx val
-@deffnx {C Function} scm_bitvector_set_x (vec, idx, val)
-Set the element at index @var{idx} of the bitvector
-@var{vec} when @var{val} is true, else clear it.
-@end deffn
-
-@deftypefn {C Function} SCM scm_c_bitvector_set_x (SCM vec, size_t idx, SCM val)
-Set the element at index @var{idx} of the bitvector
-@var{vec} when @var{val} is true, else clear it.
-@end deftypefn
-
-@deffn {Scheme Procedure} bitvector-fill! vec val
-@deffnx {C Function} scm_bitvector_fill_x (vec, val)
-Set all elements of the bitvector
-@var{vec} when @var{val} is true, else clear them.
-@end deffn
-
-@deffn {Scheme Procedure} list->bitvector list
-@deffnx {C Function} scm_list_to_bitvector (list)
-Return a new bitvector initialized with the elements
-of @var{list}.
-@end deffn
-
-@deffn {Scheme Procedure} bitvector->list vec
-@deffnx {C Function} scm_bitvector_to_list (vec)
-Return a new list initialized with the elements
-of the bitvector @var{vec}.
-@end deffn
-
-@deffn {Scheme Procedure} bit-count bool bitvector
-@deffnx {C Function} scm_bit_count (bool, bitvector)
-Return a count of how many entries in @var{bitvector} are equal to
-@var{bool}. For example,
-
-@example
-(bit-count #f #*000111000) @result{} 6
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} bit-position bool bitvector start
-@deffnx {C Function} scm_bit_position (bool, bitvector, start)
-Return the index of the first occurrence of @var{bool} in
-@var{bitvector}, starting from @var{start}. If there is no @var{bool}
-entry between @var{start} and the end of @var{bitvector}, then return
-@code{#f}. For example,
-
-@example
-(bit-position #t #*000101 0) @result{} 3
-(bit-position #f #*0001111 3) @result{} #f
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} bit-invert! bitvector
-@deffnx {C Function} scm_bit_invert_x (bitvector)
-Modify @var{bitvector} by replacing each element with its negation.
-@end deffn
-
-@deffn {Scheme Procedure} bit-set*! bitvector uvec bool
-@deffnx {C Function} scm_bit_set_star_x (bitvector, uvec, bool)
-Set entries of @var{bitvector} to @var{bool}, with @var{uvec}
-selecting the entries to change. The return value is unspecified.
-
-If @var{uvec} is a bit vector, then those entries where it has
-@code{#t} are the ones in @var{bitvector} which are set to @var{bool}.
-@var{uvec} and @var{bitvector} must be the same length. When
-@var{bool} is @code{#t} it's like @var{uvec} is OR'ed into
-@var{bitvector}. Or when @var{bool} is @code{#f} it can be seen as an
-ANDNOT.
-
-@example
-(define bv #*01000010)
-(bit-set*! bv #*10010001 #t)
-bv
-@result{} #*11010011
-@end example
-
-If @var{uvec} is a uniform vector of unsigned long integers, then
-they're indexes into @var{bitvector} which are set to @var{bool}.
-
-@example
-(define bv #*01000010)
-(bit-set*! bv #u(5 2 7) #t)
-bv
-@result{} #*01100111
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} bit-count* bitvector uvec bool
-@deffnx {C Function} scm_bit_count_star (bitvector, uvec, bool)
-Return a count of how many entries in @var{bitvector} are equal to
-@var{bool}, with @var{uvec} selecting the entries to consider.
-
-@var{uvec} is interpreted in the same way as for @code{bit-set*!}
-above. Namely, if @var{uvec} is a bit vector then entries which have
-@code{#t} there are considered in @var{bitvector}. Or if @var{uvec}
-is a uniform vector of unsigned long integers then it's the indexes in
-@var{bitvector} to consider.
-
-For example,
-
-@example
-(bit-count* #*01110111 #*11001101 #t) @result{} 3
-(bit-count* #*01110111 #u32(7 0 4) #f) @result{} 2
-@end example
-@end deffn
-
-@deftypefn {C Function} {const scm_t_uint32 *} scm_bitvector_elements (SCM vec, scm_t_array_handle *handle, size_t *offp, size_t *lenp, ssize_t *incp)
-Like @code{scm_vector_elements} (@pxref{Vector Accessing from C}), but
-for bitvectors. The variable pointed to by @var{offp} is set to the
-value returned by @code{scm_array_handle_bit_elements_offset}. See
-@code{scm_array_handle_bit_elements} for how to use the returned
-pointer and the offset.
-@end deftypefn
-
-@deftypefn {C Function} {scm_t_uint32 *} scm_bitvector_writable_elements (SCM vec, scm_t_array_handle *handle, size_t *offp, size_t *lenp, ssize_t *incp)
-Like @code{scm_bitvector_elements}, but the pointer is good for reading
-and writing.
-@end deftypefn
-
-@node Arrays
-@subsection Arrays
-@tpindex Arrays
-
-@dfn{Arrays} are a collection of cells organized into an arbitrary
-number of dimensions. Each cell can be accessed in constant time by
-supplying an index for each dimension.
-
-In the current implementation, an array uses a vector of some kind for
-the actual storage of its elements. Any kind of vector will do, so you
-can have arrays of uniform numeric values, arrays of characters, arrays
-of bits, and of course, arrays of arbitrary Scheme values. For example,
-arrays with an underlying @code{c64vector} might be nice for digital
-signal processing, while arrays made from a @code{u8vector} might be
-used to hold gray-scale images.
-
-The number of dimensions of an array is called its @dfn{rank}. Thus,
-a matrix is an array of rank 2, while a vector has rank 1. When
-accessing an array element, you have to specify one exact integer for
-each dimension. These integers are called the @dfn{indices} of the
-element. An array specifies the allowed range of indices for each
-dimension via an inclusive lower and upper bound. These bounds can
-well be negative, but the upper bound must be greater than or equal to
-the lower bound minus one. When all lower bounds of an array are
-zero, it is called a @dfn{zero-origin} array.
-
-Arrays can be of rank 0, which could be interpreted as a scalar.
-Thus, a zero-rank array can store exactly one object and the list of
-indices of this element is the empty list.
-
-Arrays contain zero elements when one of their dimensions has a zero
-length. These empty arrays maintain information about their shape: a
-matrix with zero columns and 3 rows is different from a matrix with 3
-columns and zero rows, which again is different from a vector of
-length zero.
-
-The array procedures are all polymorphic, treating strings, uniform
-numeric vectors, bytevectors, bit vectors and ordinary vectors as one
-dimensional arrays.
-
-@menu
-* Array Syntax::
-* Array Procedures::
-* Shared Arrays::
-* Accessing Arrays from C::
-@end menu
-
-@node Array Syntax
-@subsubsection Array Syntax
-
-An array is displayed as @code{#} followed by its rank, followed by a
-tag that describes the underlying vector, optionally followed by
-information about its shape, and finally followed by the cells,
-organized into dimensions using parentheses.
-
-In more words, the array tag is of the form
-
-@example
- #<@@lower><:len><@@lower><:len>...
-@end example
-
-where @code{} is a positive integer in decimal giving the rank of
-the array. It is omitted when the rank is 1 and the array is non-shared
-and has zero-origin (see below). For shared arrays and for a non-zero
-origin, the rank is always printed even when it is 1 to distinguish
-them from ordinary vectors.
-
-The @code{} part is the tag for a uniform numeric vector, like
-@code{u8}, @code{s16}, etc, @code{b} for bitvectors, or @code{a} for
-strings. It is empty for ordinary vectors.
-
-The @code{<@@lower>} part is a @samp{@@} character followed by a signed
-integer in decimal giving the lower bound of a dimension. There is one
-@code{<@@lower>} for each dimension. When all lower bounds are zero,
-all @code{<@@lower>} parts are omitted.
-
-The @code{<:len>} part is a @samp{:} character followed by an unsigned
-integer in decimal giving the length of a dimension. Like for the lower
-bounds, there is one @code{<:len>} for each dimension, and the
-@code{<:len>} part always follows the @code{<@@lower>} part for a
-dimension. Lengths are only then printed when they can't be deduced
-from the nested lists of elements of the array literal, which can happen
-when at least one length is zero.
-
-As a special case, an array of rank 0 is printed as
-@code{#0()}, where @code{} is the result of
-printing the single element of the array.
-
-Thus,
-
-@table @code
-@item #(1 2 3)
-is an ordinary array of rank 1 with lower bound 0 in dimension 0.
-(I.e., a regular vector.)
-
-@item #@@2(1 2 3)
-is an ordinary array of rank 1 with lower bound 2 in dimension 0.
-
-@item #2((1 2 3) (4 5 6))
-is a non-uniform array of rank 2; a 3@cross{}3 matrix with index ranges 0..2
-and 0..2.
-
-@item #u32(0 1 2)
-is a uniform u8 array of rank 1.
-
-@item #2u32@@2@@3((1 2) (2 3))
-is a uniform u8 array of rank 2 with index ranges 2..3 and 3..4.
-
-@item #2()
-is a two-dimensional array with index ranges 0..-1 and 0..-1, i.e.@:
-both dimensions have length zero.
-
-@item #2:0:2()
-is a two-dimensional array with index ranges 0..-1 and 0..1, i.e.@: the
-first dimension has length zero, but the second has length 2.
-
-@item #0(12)
-is a rank-zero array with contents 12.
-
-@end table
-
-In addition, bytevectors are also arrays, but use a different syntax
-(@pxref{Bytevectors}):
-
-@table @code
-
-@item #vu8(1 2 3)
-is a 3-byte long bytevector, with contents 1, 2, 3.
-
-@end table
-
-@node Array Procedures
-@subsubsection Array Procedures
-
-When an array is created, the range of each dimension must be
-specified, e.g., to create a 2@cross{}3 array with a zero-based index:
-
-@example
-(make-array 'ho 2 3) @result{} #2((ho ho ho) (ho ho ho))
-@end example
-
-The range of each dimension can also be given explicitly, e.g., another
-way to create the same array:
-
-@example
-(make-array 'ho '(0 1) '(0 2)) @result{} #2((ho ho ho) (ho ho ho))
-@end example
-
-The following procedures can be used with arrays (or vectors). An
-argument shown as @var{idx}@dots{} means one parameter for each
-dimension in the array. A @var{idxlist} argument means a list of such
-values, one for each dimension.
-
-
-@deffn {Scheme Procedure} array? obj
-@deffnx {C Function} scm_array_p (obj, unused)
-Return @code{#t} if the @var{obj} is an array, and @code{#f} if
-not.
-
-The second argument to scm_array_p is there for historical reasons,
-but it is not used. You should always pass @code{SCM_UNDEFINED} as
-its value.
-@end deffn
-
-@deffn {Scheme Procedure} typed-array? obj type
-@deffnx {C Function} scm_typed_array_p (obj, type)
-Return @code{#t} if the @var{obj} is an array of type @var{type}, and
-@code{#f} if not.
-@end deffn
-
-@deftypefn {C Function} int scm_is_array (SCM obj)
-Return @code{1} if the @var{obj} is an array and @code{0} if not.
-@end deftypefn
-
-@deftypefn {C Function} int scm_is_typed_array (SCM obj, SCM type)
-Return @code{0} if the @var{obj} is an array of type @var{type}, and
-@code{1} if not.
-@end deftypefn
-
-@deffn {Scheme Procedure} make-array fill bound @dots{}
-@deffnx {C Function} scm_make_array (fill, bounds)
-Equivalent to @code{(make-typed-array #t @var{fill} @var{bound} ...)}.
-@end deffn
-
-@deffn {Scheme Procedure} make-typed-array type fill bound @dots{}
-@deffnx {C Function} scm_make_typed_array (type, fill, bounds)
-Create and return an array that has as many dimensions as there are
-@var{bound}s and (maybe) fill it with @var{fill}.
-
-The underlying storage vector is created according to @var{type},
-which must be a symbol whose name is the `vectag' of the array as
-explained above, or @code{#t} for ordinary, non-specialized arrays.
-
-For example, using the symbol @code{f64} for @var{type} will create an
-array that uses a @code{f64vector} for storing its elements, and
-@code{a} will use a string.
-
-When @var{fill} is not the special @emph{unspecified} value, the new
-array is filled with @var{fill}. Otherwise, the initial contents of
-the array is unspecified. The special @emph{unspecified} value is
-stored in the variable @code{*unspecified*} so that for example
-@code{(make-typed-array 'u32 *unspecified* 4)} creates a uninitialized
-@code{u32} vector of length 4.
-
-Each @var{bound} may be a positive non-zero integer @var{n}, in which
-case the index for that dimension can range from 0 through @var{n}-1; or
-an explicit index range specifier in the form @code{(LOWER UPPER)},
-where both @var{lower} and @var{upper} are integers, possibly less than
-zero, and possibly the same number (however, @var{lower} cannot be
-greater than @var{upper}).
-@end deffn
-
-@deffn {Scheme Procedure} list->array dimspec list
-Equivalent to @code{(list->typed-array #t @var{dimspec}
-@var{list})}.
-@end deffn
-
-@deffn {Scheme Procedure} list->typed-array type dimspec list
-@deffnx {C Function} scm_list_to_typed_array (type, dimspec, list)
-Return an array of the type indicated by @var{type} with elements the
-same as those of @var{list}.
-
-The argument @var{dimspec} determines the number of dimensions of the
-array and their lower bounds. When @var{dimspec} is an exact integer,
-it gives the number of dimensions directly and all lower bounds are
-zero. When it is a list of exact integers, then each element is the
-lower index bound of a dimension, and there will be as many dimensions
-as elements in the list.
-@end deffn
-
-@deffn {Scheme Procedure} array-type array
-@deffnx {C Function} scm_array_type (array)
-Return the type of @var{array}. This is the `vectag' used for
-printing @var{array} (or @code{#t} for ordinary arrays) and can be
-used with @code{make-typed-array} to create an array of the same kind
-as @var{array}.
-@end deffn
-
-@deffn {Scheme Procedure} array-ref array idx @dots{}
-@deffnx {C Function} scm_array_ref (array, idxlist)
-Return the element at @code{(idx @dots{})} in @var{array}.
-
-@example
-(define a (make-array 999 '(1 2) '(3 4)))
-(array-ref a 2 4) @result{} 999
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} array-in-bounds? array idx @dots{}
-@deffnx {C Function} scm_array_in_bounds_p (array, idxlist)
-Return @code{#t} if the given indices would be acceptable to
-@code{array-ref}.
-
-@example
-(define a (make-array #f '(1 2) '(3 4)))
-(array-in-bounds? a 2 3) @result{} #t
-(array-in-bounds? a 0 0) @result{} #f
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} array-set! array obj idx @dots{}
-@deffnx {C Function} scm_array_set_x (array, obj, idxlist)
-Set the element at @code{(idx @dots{})} in @var{array} to @var{obj}.
-The return value is unspecified.
-
-@example
-(define a (make-array #f '(0 1) '(0 1)))
-(array-set! a #t 1 1)
-a @result{} #2((#f #f) (#f #t))
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} array-shape array
-@deffnx {Scheme Procedure} array-dimensions array
-@deffnx {C Function} scm_array_dimensions (array)
-Return a list of the bounds for each dimension of @var{array}.
-
-@code{array-shape} gives @code{(@var{lower} @var{upper})} for each
-dimension. @code{array-dimensions} instead returns just
-@math{@var{upper}+1} for dimensions with a 0 lower bound. Both are
-suitable as input to @code{make-array}.
-
-For example,
-
-@example
-(define a (make-array 'foo '(-1 3) 5))
-(array-shape a) @result{} ((-1 3) (0 4))
-(array-dimensions a) @result{} ((-1 3) 5)
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} array-length array
-@deffnx {C Function} scm_array_length (array)
-@deffnx {C Function} size_t scm_c_array_length (array)
-Return the length of an array: its first dimension. It is an error to
-ask for the length of an array of rank 0.
-@end deffn
-
-@deffn {Scheme Procedure} array-rank array
-@deffnx {C Function} scm_array_rank (array)
-Return the rank of @var{array}.
-@end deffn
-
-@deftypefn {C Function} size_t scm_c_array_rank (SCM array)
-Return the rank of @var{array} as a @code{size_t}.
-@end deftypefn
-
-@deffn {Scheme Procedure} array->list array
-@deffnx {C Function} scm_array_to_list (array)
-Return a list consisting of all the elements, in order, of
-@var{array}.
-@end deffn
-
-@c FIXME: Describe how the order affects the copying (it matters for
-@c shared arrays with the same underlying root vector, presumably).
-@c
-@deffn {Scheme Procedure} array-copy! src dst
-@deffnx {Scheme Procedure} array-copy-in-order! src dst
-@deffnx {C Function} scm_array_copy_x (src, dst)
-Copy every element from vector or array @var{src} to the corresponding
-element of @var{dst}. @var{dst} must have the same rank as @var{src},
-and be at least as large in each dimension. The return value is
-unspecified.
-@end deffn
-
-@deffn {Scheme Procedure} array-fill! array fill
-@deffnx {C Function} scm_array_fill_x (array, fill)
-Store @var{fill} in every element of @var{array}. The value returned
-is unspecified.
-@end deffn
-
-@c begin (texi-doc-string "guile" "array-equal?")
-@deffn {Scheme Procedure} array-equal? array @dots{}
-Return @code{#t} if all arguments are arrays with the same shape, the
-same type, and have corresponding elements which are either
-@code{equal?} or @code{array-equal?}. This function differs from
-@code{equal?} (@pxref{Equality}) in that all arguments must be arrays.
-@end deffn
-
-@c FIXME: array-map! accepts no source arrays at all, and in that
-@c case makes calls "(proc)". Is that meant to be a documented
-@c feature?
-@c
-@c FIXME: array-for-each doesn't say what happens if the sources have
-@c different index ranges. The code currently iterates over the
-@c indices of the first and expects the others to cover those. That
-@c at least vaguely matches array-map!, but is it meant to be a
-@c documented feature?
-
-@deffn {Scheme Procedure} array-map! dst proc src @dots{}
-@deffnx {Scheme Procedure} array-map-in-order! dst proc src1 @dots{} srcN
-@deffnx {C Function} scm_array_map_x (dst, proc, srclist)
-Set each element of the @var{dst} array to values obtained from calls
-to @var{proc}. The value returned is unspecified.
-
-Each call is @code{(@var{proc} @var{elem1} @dots{} @var{elemN})},
-where each @var{elem} is from the corresponding @var{src} array, at
-the @var{dst} index. @code{array-map-in-order!} makes the calls in
-row-major order, @code{array-map!} makes them in an unspecified order.
-
-The @var{src} arrays must have the same number of dimensions as
-@var{dst}, and must have a range for each dimension which covers the
-range in @var{dst}. This ensures all @var{dst} indices are valid in
-each @var{src}.
-@end deffn
-
-@deffn {Scheme Procedure} array-for-each proc src1 src2 @dots{}
-@deffnx {C Function} scm_array_for_each (proc, src1, srclist)
-Apply @var{proc} to each tuple of elements of @var{src1} @var{src2}
-@dots{}, in row-major order. The value returned is unspecified.
-@end deffn
-
-@deffn {Scheme Procedure} array-index-map! dst proc
-@deffnx {C Function} scm_array_index_map_x (dst, proc)
-Set each element of the @var{dst} array to values returned by calls to
-@var{proc}. The value returned is unspecified.
-
-Each call is @code{(@var{proc} @var{i1} @dots{} @var{iN})}, where
-@var{i1}@dots{}@var{iN} is the destination index, one parameter for
-each dimension. The order in which the calls are made is unspecified.
-
-For example, to create a @m{4\times4, 4x4} matrix representing a
-cyclic group,
-
-@tex
-\advance\leftskip by 2\lispnarrowing {
-$\left(\matrix{%
-0 & 1 & 2 & 3 \cr
-1 & 2 & 3 & 0 \cr
-2 & 3 & 0 & 1 \cr
-3 & 0 & 1 & 2 \cr
-}\right)$} \par
-@end tex
-@ifnottex
-@example
- / 0 1 2 3 \
- | 1 2 3 0 |
- | 2 3 0 1 |
- \ 3 0 1 2 /
-@end example
-@end ifnottex
-
-@example
-(define a (make-array #f 4 4))
-(array-index-map! a (lambda (i j)
- (modulo (+ i j) 4)))
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]]
-@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end)
-Attempt to read all elements of array @var{ra}, in lexicographic order, as
-binary objects from @var{port_or_fd}.
-If an end of file is encountered,
-the objects up to that point are put into @var{ra}
-(starting at the beginning) and the remainder of the array is
-unchanged.
-
-The optional arguments @var{start} and @var{end} allow
-a specified region of a vector (or linearized array) to be read,
-leaving the remainder of the vector unchanged.
-
-@code{uniform-array-read!} returns the number of objects read.
-@var{port_or_fd} may be omitted, in which case it defaults to the value
-returned by @code{(current-input-port)}.
-@end deffn
-
-@deffn {Scheme Procedure} uniform-array-write ra [port_or_fd [start [end]]]
-@deffnx {C Function} scm_uniform_array_write (ra, port_or_fd, start, end)
-Writes all elements of @var{ra} as binary objects to
-@var{port_or_fd}.
-
-The optional arguments @var{start}
-and @var{end} allow
-a specified region of a vector (or linearized array) to be written.
-
-The number of objects actually written is returned.
-@var{port_or_fd} may be
-omitted, in which case it defaults to the value returned by
-@code{(current-output-port)}.
-@end deffn
-
-@node Shared Arrays
-@subsubsection Shared Arrays
-
-@deffn {Scheme Procedure} make-shared-array oldarray mapfunc bound @dots{}
-@deffnx {C Function} scm_make_shared_array (oldarray, mapfunc, boundlist)
-Return a new array which shares the storage of @var{oldarray}.
-Changes made through either affect the same underlying storage. The
-@var{bound} @dots{} arguments are the shape of the new array, the same
-as @code{make-array} (@pxref{Array Procedures}).
-
-@var{mapfunc} translates coordinates from the new array to the
-@var{oldarray}. It's called as @code{(@var{mapfunc} newidx1 @dots{})}
-with one parameter for each dimension of the new array, and should
-return a list of indices for @var{oldarray}, one for each dimension of
-@var{oldarray}.
-
-@var{mapfunc} must be affine linear, meaning that each @var{oldarray}
-index must be formed by adding integer multiples (possibly negative)
-of some or all of @var{newidx1} etc, plus a possible integer offset.
-The multiples and offset must be the same in each call.
-
-@sp 1
-One good use for a shared array is to restrict the range of some
-dimensions, so as to apply say @code{array-for-each} or
-@code{array-fill!} to only part of an array. The plain @code{list}
-function can be used for @var{mapfunc} in this case, making no changes
-to the index values. For example,
-
-@example
-(make-shared-array #2((a b c) (d e f) (g h i)) list 3 2)
-@result{} #2((a b) (d e) (g h))
-@end example
-
-The new array can have fewer dimensions than @var{oldarray}, for
-example to take a column from an array.
-
-@example
-(make-shared-array #2((a b c) (d e f) (g h i))
- (lambda (i) (list i 2))
- '(0 2))
-@result{} #1(c f i)
-@end example
-
-A diagonal can be taken by using the single new array index for both
-row and column in the old array. For example,
-
-@example
-(make-shared-array #2((a b c) (d e f) (g h i))
- (lambda (i) (list i i))
- '(0 2))
-@result{} #1(a e i)
-@end example
-
-Dimensions can be increased by for instance considering portions of a
-one dimensional array as rows in a two dimensional array.
-(@code{array-contents} below can do the opposite, flattening an
-array.)
-
-@example
-(make-shared-array #1(a b c d e f g h i j k l)
- (lambda (i j) (list (+ (* i 3) j)))
- 4 3)
-@result{} #2((a b c) (d e f) (g h i) (j k l))
-@end example
-
-By negating an index the order that elements appear can be reversed.
-The following just reverses the column order,
-
-@example
-(make-shared-array #2((a b c) (d e f) (g h i))
- (lambda (i j) (list i (- 2 j)))
- 3 3)
-@result{} #2((c b a) (f e d) (i h g))
-@end example
-
-A fixed offset on indexes allows for instance a change from a 0 based
-to a 1 based array,
-
-@example
-(define x #2((a b c) (d e f) (g h i)))
-(define y (make-shared-array x
- (lambda (i j) (list (1- i) (1- j)))
- '(1 3) '(1 3)))
-(array-ref x 0 0) @result{} a
-(array-ref y 1 1) @result{} a
-@end example
-
-A multiple on an index allows every Nth element of an array to be
-taken. The following is every third element,
-
-@example
-(make-shared-array #1(a b c d e f g h i j k l)
- (lambda (i) (list (* i 3)))
- 4)
-@result{} #1(a d g j)
-@end example
-
-The above examples can be combined to make weird and wonderful
-selections from an array, but it's important to note that because
-@var{mapfunc} must be affine linear, arbitrary permutations are not
-possible.
-
-In the current implementation, @var{mapfunc} is not called for every
-access to the new array but only on some sample points to establish a
-base and stride for new array indices in @var{oldarray} data. A few
-sample points are enough because @var{mapfunc} is linear.
-@end deffn
-
-@deffn {Scheme Procedure} shared-array-increments array
-@deffnx {C Function} scm_shared_array_increments (array)
-For each dimension, return the distance between elements in the root vector.
-@end deffn
-
-@deffn {Scheme Procedure} shared-array-offset array
-@deffnx {C Function} scm_shared_array_offset (array)
-Return the root vector index of the first element in the array.
-@end deffn
-
-@deffn {Scheme Procedure} shared-array-root array
-@deffnx {C Function} scm_shared_array_root (array)
-Return the root vector of a shared array.
-@end deffn
-
-@deffn {Scheme Procedure} array-contents array [strict]
-@deffnx {C Function} scm_array_contents (array, strict)
-If @var{array} may be @dfn{unrolled} into a one dimensional shared array
-without changing their order (last subscript changing fastest), then
-@code{array-contents} returns that shared array, otherwise it returns
-@code{#f}. All arrays made by @code{make-array} and
-@code{make-typed-array} may be unrolled, some arrays made by
-@code{make-shared-array} may not be.
-
-If the optional argument @var{strict} is provided, a shared array will
-be returned only if its elements are stored internally contiguous in
-memory.
-@end deffn
-
-@deffn {Scheme Procedure} transpose-array array dim1 dim2 @dots{}
-@deffnx {C Function} scm_transpose_array (array, dimlist)
-Return an array sharing contents with @var{array}, but with
-dimensions arranged in a different order. There must be one
-@var{dim} argument for each dimension of @var{array}.
-@var{dim1}, @var{dim2}, @dots{} should be integers between 0
-and the rank of the array to be returned. Each integer in that
-range must appear at least once in the argument list.
-
-The values of @var{dim1}, @var{dim2}, @dots{} correspond to
-dimensions in the array to be returned, and their positions in the
-argument list to dimensions of @var{array}. Several @var{dim}s
-may have the same value, in which case the returned array will
-have smaller rank than @var{array}.
-
-@lisp
-(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d))
-(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d)
-(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{}
- #2((a 4) (b 5) (c 6))
-@end lisp
-@end deffn
-
-@node Accessing Arrays from C
-@subsubsection Accessing Arrays from C
-
-For interworking with external C code, Guile provides an API to allow C
-code to access the elements of a Scheme array. In particular, for
-uniform numeric arrays, the API exposes the underlying uniform data as a
-C array of numbers of the relevant type.
-
-While pointers to the elements of an array are in use, the array itself
-must be protected so that the pointer remains valid. Such a protected
-array is said to be @dfn{reserved}. A reserved array can be read but
-modifications to it that would cause the pointer to its elements to
-become invalid are prevented. When you attempt such a modification, an
-error is signalled.
-
-(This is similar to locking the array while it is in use, but without
-the danger of a deadlock. In a multi-threaded program, you will need
-additional synchronization to avoid modifying reserved arrays.)
-
-You must take care to always unreserve an array after reserving it,
-even in the presence of non-local exits. If a non-local exit can
-happen between these two calls, you should install a dynwind context
-that releases the array when it is left (@pxref{Dynamic Wind}).
-
-In addition, array reserving and unreserving must be properly
-paired. For instance, when reserving two or more arrays in a certain
-order, you need to unreserve them in the opposite order.
-
-Once you have reserved an array and have retrieved the pointer to its
-elements, you must figure out the layout of the elements in memory.
-Guile allows slices to be taken out of arrays without actually making a
-copy, such as making an alias for the diagonal of a matrix that can be
-treated as a vector. Arrays that result from such an operation are not
-stored contiguously in memory and when working with their elements
-directly, you need to take this into account.
-
-The layout of array elements in memory can be defined via a
-@emph{mapping function} that computes a scalar position from a vector of
-indices. The scalar position then is the offset of the element with the
-given indices from the start of the storage block of the array.
-
-In Guile, this mapping function is restricted to be @dfn{affine}: all
-mapping functions of Guile arrays can be written as @code{p = b +
-c[0]*i[0] + c[1]*i[1] + ... + c[n-1]*i[n-1]} where @code{i[k]} is the
-@nicode{k}th index and @code{n} is the rank of the array. For
-example, a matrix of size 3x3 would have @code{b == 0}, @code{c[0] ==
-3} and @code{c[1] == 1}. When you transpose this matrix (with
-@code{transpose-array}, say), you will get an array whose mapping
-function has @code{b == 0}, @code{c[0] == 1} and @code{c[1] == 3}.
-
-The function @code{scm_array_handle_dims} gives you (indirect) access to
-the coefficients @code{c[k]}.
-
-@c XXX
-Note that there are no functions for accessing the elements of a
-character array yet. Once the string implementation of Guile has been
-changed to use Unicode, we will provide them.
-
-@deftp {C Type} scm_t_array_handle
-This is a structure type that holds all information necessary to manage
-the reservation of arrays as explained above. Structures of this type
-must be allocated on the stack and must only be accessed by the
-functions listed below.
-@end deftp
-
-@deftypefn {C Function} void scm_array_get_handle (SCM array, scm_t_array_handle *handle)
-Reserve @var{array}, which must be an array, and prepare @var{handle} to
-be used with the functions below. You must eventually call
-@code{scm_array_handle_release} on @var{handle}, and do this in a
-properly nested fashion, as explained above. The structure pointed to
-by @var{handle} does not need to be initialized before calling this
-function.
-@end deftypefn
-
-@deftypefn {C Function} void scm_array_handle_release (scm_t_array_handle *handle)
-End the array reservation represented by @var{handle}. After a call to
-this function, @var{handle} might be used for another reservation.
-@end deftypefn
-
-@deftypefn {C Function} size_t scm_array_handle_rank (scm_t_array_handle *handle)
-Return the rank of the array represented by @var{handle}.
-@end deftypefn
-
-@deftp {C Type} scm_t_array_dim
-This structure type holds information about the layout of one dimension
-of an array. It includes the following fields:
-
-@table @code
-@item ssize_t lbnd
-@itemx ssize_t ubnd
-The lower and upper bounds (both inclusive) of the permissible index
-range for the given dimension. Both values can be negative, but
-@var{lbnd} is always less than or equal to @var{ubnd}.
-
-@item ssize_t inc
-The distance from one element of this dimension to the next. Note, too,
-that this can be negative.
-@end table
-@end deftp
-
-@deftypefn {C Function} {const scm_t_array_dim *} scm_array_handle_dims (scm_t_array_handle *handle)
-Return a pointer to a C vector of information about the dimensions of
-the array represented by @var{handle}. This pointer is valid as long as
-the array remains reserved. As explained above, the
-@code{scm_t_array_dim} structures returned by this function can be used
-calculate the position of an element in the storage block of the array
-from its indices.
-
-This position can then be used as an index into the C array pointer
-returned by the various @code{scm_array_handle__elements}
-functions, or with @code{scm_array_handle_ref} and
-@code{scm_array_handle_set}.
-
-Here is how one can compute the position @var{pos} of an element given
-its indices in the vector @var{indices}:
-
-@example
-ssize_t indices[RANK];
-scm_t_array_dim *dims;
-ssize_t pos;
-size_t i;
-
-pos = 0;
-for (i = 0; i < RANK; i++)
- @{
- if (indices[i] < dims[i].lbnd || indices[i] > dims[i].ubnd)
- out_of_range ();
- pos += (indices[i] - dims[i].lbnd) * dims[i].inc;
- @}
-@end example
-@end deftypefn
-
-@deftypefn {C Function} ssize_t scm_array_handle_pos (scm_t_array_handle *handle, SCM indices)
-Compute the position corresponding to @var{indices}, a list of
-indices. The position is computed as described above for
-@code{scm_array_handle_dims}. The number of the indices and their
-range is checked and an appropriate error is signalled for invalid
-indices.
-@end deftypefn
-
-@deftypefn {C Function} SCM scm_array_handle_ref (scm_t_array_handle *handle, ssize_t pos)
-Return the element at position @var{pos} in the storage block of the
-array represented by @var{handle}. Any kind of array is acceptable. No
-range checking is done on @var{pos}.
-@end deftypefn
-
-@deftypefn {C Function} void scm_array_handle_set (scm_t_array_handle *handle, ssize_t pos, SCM val)
-Set the element at position @var{pos} in the storage block of the array
-represented by @var{handle} to @var{val}. Any kind of array is
-acceptable. No range checking is done on @var{pos}. An error is
-signalled when the array can not store @var{val}.
-@end deftypefn
-
-@deftypefn {C Function} {const SCM *} scm_array_handle_elements (scm_t_array_handle *handle)
-Return a pointer to the elements of a ordinary array of general Scheme
-values (i.e., a non-uniform array) for reading. This pointer is valid
-as long as the array remains reserved.
-@end deftypefn
-
-@deftypefn {C Function} {SCM *} scm_array_handle_writable_elements (scm_t_array_handle *handle)
-Like @code{scm_array_handle_elements}, but the pointer is good for
-reading and writing.
-@end deftypefn
-
-@deftypefn {C Function} {const void *} scm_array_handle_uniform_elements (scm_t_array_handle *handle)
-Return a pointer to the elements of a uniform numeric array for reading.
-This pointer is valid as long as the array remains reserved. The size
-of each element is given by @code{scm_array_handle_uniform_element_size}.
-@end deftypefn
-
-@deftypefn {C Function} {void *} scm_array_handle_uniform_writable_elements (scm_t_array_handle *handle)
-Like @code{scm_array_handle_uniform_elements}, but the pointer is good
-reading and writing.
-@end deftypefn
-
-@deftypefn {C Function} size_t scm_array_handle_uniform_element_size (scm_t_array_handle *handle)
-Return the size of one element of the uniform numeric array represented
-by @var{handle}.
-@end deftypefn
-
-@deftypefn {C Function} {const scm_t_uint8 *} scm_array_handle_u8_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_int8 *} scm_array_handle_s8_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_uint16 *} scm_array_handle_u16_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_int16 *} scm_array_handle_s16_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_uint32 *} scm_array_handle_u32_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_int32 *} scm_array_handle_s32_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_uint64 *} scm_array_handle_u64_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const scm_t_int64 *} scm_array_handle_s64_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const float *} scm_array_handle_f32_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const double *} scm_array_handle_f64_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const float *} scm_array_handle_c32_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {const double *} scm_array_handle_c64_elements (scm_t_array_handle *handle)
-Return a pointer to the elements of a uniform numeric array of the
-indicated kind for reading. This pointer is valid as long as the array
-remains reserved.
-
-The pointers for @code{c32} and @code{c64} uniform numeric arrays point
-to pairs of floating point numbers. The even index holds the real part,
-the odd index the imaginary part of the complex number.
-@end deftypefn
-
-@deftypefn {C Function} {scm_t_uint8 *} scm_array_handle_u8_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_int8 *} scm_array_handle_s8_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_uint16 *} scm_array_handle_u16_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_int16 *} scm_array_handle_s16_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_uint32 *} scm_array_handle_u32_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_int32 *} scm_array_handle_s32_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_uint64 *} scm_array_handle_u64_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {scm_t_int64 *} scm_array_handle_s64_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {float *} scm_array_handle_f32_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {double *} scm_array_handle_f64_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {float *} scm_array_handle_c32_writable_elements (scm_t_array_handle *handle)
-@deftypefnx {C Function} {double *} scm_array_handle_c64_writable_elements (scm_t_array_handle *handle)
-Like @code{scm_array_handle__elements}, but the pointer is good
-for reading and writing.
-@end deftypefn
-
-@deftypefn {C Function} {const scm_t_uint32 *} scm_array_handle_bit_elements (scm_t_array_handle *handle)
-Return a pointer to the words that store the bits of the represented
-array, which must be a bit array.
-
-Unlike other arrays, bit arrays have an additional offset that must be
-figured into index calculations. That offset is returned by
-@code{scm_array_handle_bit_elements_offset}.
-
-To find a certain bit you first need to calculate its position as
-explained above for @code{scm_array_handle_dims} and then add the
-offset. This gives the absolute position of the bit, which is always a
-non-negative integer.
-
-Each word of the bit array storage block contains exactly 32 bits, with
-the least significant bit in that word having the lowest absolute
-position number. The next word contains the next 32 bits.
-
-Thus, the following code can be used to access a bit whose position
-according to @code{scm_array_handle_dims} is given in @var{pos}:
-
-@example
-SCM bit_array;
-scm_t_array_handle handle;
-scm_t_uint32 *bits;
-ssize_t pos;
-size_t abs_pos;
-size_t word_pos, mask;
-
-scm_array_get_handle (&bit_array, &handle);
-bits = scm_array_handle_bit_elements (&handle);
-
-pos = ...
-abs_pos = pos + scm_array_handle_bit_elements_offset (&handle);
-word_pos = abs_pos / 32;
-mask = 1L << (abs_pos % 32);
-
-if (bits[word_pos] & mask)
- /* bit is set. */
-
-scm_array_handle_release (&handle);
-@end example
-
-@end deftypefn
-
-@deftypefn {C Function} {scm_t_uint32 *} scm_array_handle_bit_writable_elements (scm_t_array_handle *handle)
-Like @code{scm_array_handle_bit_elements} but the pointer is good for
-reading and writing. You must take care not to modify bits outside of
-the allowed index range of the array, even for contiguous arrays.
-@end deftypefn
-
-@node VLists
-@subsection VLists
-
-@cindex vlist
-
-The @code{(ice-9 vlist)} module provides an implementation of the @dfn{VList}
-data structure designed by Phil Bagwell in 2002. VLists are immutable lists,
-which can contain any Scheme object. They improve on standard Scheme linked
-lists in several areas:
-
-@itemize
-@item
-Random access has typically constant-time complexity.
-
-@item
-Computing the length of a VList has time complexity logarithmic in the number of
-elements.
-
-@item
-VLists use less storage space than standard lists.
-
-@item
-VList elements are stored in contiguous regions, which improves memory locality
-and leads to more efficient use of hardware caches.
-@end itemize
-
-The idea behind VLists is to store vlist elements in increasingly large
-contiguous blocks (implemented as vectors here). These blocks are linked to one
-another using a pointer to the next block and an offset within that block. The
-size of these blocks form a geometric series with ratio
-@code{block-growth-factor} (2 by default).
-
-The VList structure also serves as the basis for the @dfn{VList-based hash
-lists} or ``vhashes'', an immutable dictionary type (@pxref{VHashes}).
-
-However, the current implementation in @code{(ice-9 vlist)} has several
-noteworthy shortcomings:
-
-@itemize
-
-@item
-It is @emph{not} thread-safe. Although operations on vlists are all
-@dfn{referentially transparent} (i.e., purely functional), adding elements to a
-vlist with @code{vlist-cons} mutates part of its internal structure, which makes
-it non-thread-safe. This could be fixed, but it would slow down
-@code{vlist-cons}.
-
-@item
-@code{vlist-cons} always allocates at least as much memory as @code{cons}.
-Again, Phil Bagwell describes how to fix it, but that would require tuning the
-garbage collector in a way that may not be generally beneficial.
-
-@item
-@code{vlist-cons} is a Scheme procedure compiled to bytecode, and it does not
-compete with the straightforward C implementation of @code{cons}, and with the
-fact that the VM has a special @code{cons} instruction.
-
-@end itemize
-
-We hope to address these in the future.
-
-The programming interface exported by @code{(ice-9 vlist)} is defined below.
-Most of it is the same as SRFI-1 with an added @code{vlist-} prefix to function
-names.
-
-@deffn {Scheme Procedure} vlist? obj
-Return true if @var{obj} is a VList.
-@end deffn
-
-@defvr {Scheme Variable} vlist-null
-The empty VList. Note that it's possible to create an empty VList not
-@code{eq?} to @code{vlist-null}; thus, callers should always use
-@code{vlist-null?} when testing whether a VList is empty.
-@end defvr
-
-@deffn {Scheme Procedure} vlist-null? vlist
-Return true if @var{vlist} is empty.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-cons item vlist
-Return a new vlist with @var{item} as its head and @var{vlist} as its tail.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-head vlist
-Return the head of @var{vlist}.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-tail vlist
-Return the tail of @var{vlist}.
-@end deffn
-
-@defvr {Scheme Variable} block-growth-factor
-A fluid that defines the growth factor of VList blocks, 2 by default.
-@end defvr
-
-The functions below provide the usual set of higher-level list operations.
-
-@deffn {Scheme Procedure} vlist-fold proc init vlist
-@deffnx {Scheme Procedure} vlist-fold-right proc init vlist
-Fold over @var{vlist}, calling @var{proc} for each element, as for SRFI-1
-@code{fold} and @code{fold-right} (@pxref{SRFI-1, @code{fold}}).
-@end deffn
-
-@deffn {Scheme Procedure} vlist-ref vlist index
-Return the element at index @var{index} in @var{vlist}. This is typically a
-constant-time operation.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-length vlist
-Return the length of @var{vlist}. This is typically logarithmic in the number
-of elements in @var{vlist}.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-reverse vlist
-Return a new @var{vlist} whose content are those of @var{vlist} in reverse
-order.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-map proc vlist
-Map @var{proc} over the elements of @var{vlist} and return a new vlist.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-for-each proc vlist
-Call @var{proc} on each element of @var{vlist}. The result is unspecified.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-drop vlist count
-Return a new vlist that does not contain the @var{count} first elements of
-@var{vlist}. This is typically a constant-time operation.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-take vlist count
-Return a new vlist that contains only the @var{count} first elements of
-@var{vlist}.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-filter pred vlist
-Return a new vlist containing all the elements from @var{vlist} that satisfy
-@var{pred}.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-delete x vlist [equal?]
-Return a new vlist corresponding to @var{vlist} without the elements
-@var{equal?} to @var{x}.
-@end deffn
-
-@deffn {Scheme Procedure} vlist-unfold p f g seed [tail-gen]
-@deffnx {Scheme Procedure} vlist-unfold-right p f g seed [tail]
-Return a new vlist, as for SRFI-1 @code{unfold} and @code{unfold-right}
-(@pxref{SRFI-1, @code{unfold}}).
-@end deffn
-
-@deffn {Scheme Procedure} vlist-append vlist @dots{}
-Append the given vlists and return the resulting vlist.
-@end deffn
-
-@deffn {Scheme Procedure} list->vlist lst
-Return a new vlist whose contents correspond to @var{lst}.
-@end deffn
-
-@deffn {Scheme Procedure} vlist->list vlist
-Return a new list whose contents match those of @var{vlist}.
-@end deffn
-
-@node Record Overview
-@subsection Record Overview
-
-@cindex record
-@cindex structure
-
-@dfn{Records}, also called @dfn{structures}, are Scheme's primary
-mechanism to define new disjoint types. A @dfn{record type} defines a
-list of @dfn{fields} that instances of the type consist of. This is like
-C's @code{struct}.
-
-Historically, Guile has offered several different ways to define record
-types and to create records, offering different features, and making
-different trade-offs. Over the years, each ``standard'' has also come
-with its own new record interface, leading to a maze of record APIs.
-
-At the highest level is SRFI-9, a high-level record interface
-implemented by most Scheme implementations (@pxref{SRFI-9 Records}). It
-defines a simple and efficient syntactic abstraction of record types and
-their associated type predicate, fields, and field accessors. SRFI-9 is
-suitable for most uses, and this is the recommended way to create record
-types in Guile. Similar high-level record APIs include SRFI-35
-(@pxref{SRFI-35}) and R6RS records (@pxref{rnrs records syntactic}).
-
-Then comes Guile's historical ``records'' API (@pxref{Records}). Record
-types defined this way are first-class objects. Introspection
-facilities are available, allowing users to query the list of fields or
-the value of a specific field at run-time, without prior knowledge of
-the type.
-
-Finally, the common denominator of these interfaces is Guile's
-@dfn{structure} API (@pxref{Structures}). Guile's structures are the
-low-level building block for all other record APIs. Application writers
-will normally not need to use it.
-
-Records created with these APIs may all be pattern-matched using Guile's
-standard pattern matcher (@pxref{Pattern Matching}).
-
-
-@node SRFI-9 Records
-@subsection SRFI-9 Records
-
-@cindex SRFI-9
-@cindex record
-
-SRFI-9 standardizes a syntax for defining new record types and creating
-predicate, constructor, and field getter and setter functions. In Guile
-this is the recommended option to create new record types (@pxref{Record
-Overview}). It can be used with:
-
-@example
-(use-modules (srfi srfi-9))
-@end example
-
-@deffn {Scheme Syntax} define-record-type type @* (constructor fieldname @dots{}) @* predicate @* (fieldname accessor [modifier]) @dots{}
-@sp 1
-Create a new record type, and make various @code{define}s for using
-it. This syntax can only occur at the top-level, not nested within
-some other form.
-
-@var{type} is bound to the record type, which is as per the return
-from the core @code{make-record-type}. @var{type} also provides the
-name for the record, as per @code{record-type-name}.
-
-@var{constructor} is bound to a function to be called as
-@code{(@var{constructor} fieldval @dots{})} to create a new record of
-this type. The arguments are initial values for the fields, one
-argument for each field, in the order they appear in the
-@code{define-record-type} form.
-
-The @var{fieldname}s provide the names for the record fields, as per
-the core @code{record-type-fields} etc, and are referred to in the
-subsequent accessor/modifier forms.
-
-@var{predicate} is bound to a function to be called as
-@code{(@var{predicate} obj)}. It returns @code{#t} or @code{#f}
-according to whether @var{obj} is a record of this type.
-
-Each @var{accessor} is bound to a function to be called
-@code{(@var{accessor} record)} to retrieve the respective field from a
-@var{record}. Similarly each @var{modifier} is bound to a function to
-be called @code{(@var{modifier} record val)} to set the respective
-field in a @var{record}.
-@end deffn
-
-@noindent
-An example will illustrate typical usage,
-
-@example
-(define-record-type
- (make-employee name age salary)
- employee?
- (name employee-name)
- (age employee-age set-employee-age!)
- (salary employee-salary set-employee-salary!))
-@end example
-
-This creates a new employee data type, with name, age and salary
-fields. Accessor functions are created for each field, but no
-modifier function for the name (the intention in this example being
-that it's established only when an employee object is created). These
-can all then be used as for example,
-
-@example
- @result{} #>
-
-(define fred (make-employee "Fred" 45 20000.00))
-
-(employee? fred) @result{} #t
-(employee-age fred) @result{} 45
-(set-employee-salary! fred 25000.00) ;; pay rise
-@end example
-
-The functions created by @code{define-record-type} are ordinary
-top-level @code{define}s. They can be redefined or @code{set!} as
-desired, exported from a module, etc.
-
-@unnumberedsubsubsec Non-toplevel Record Definitions
-
-The SRFI-9 specification explicitly disallows record definitions in a
-non-toplevel context, such as inside @code{lambda} body or inside a
-@var{let} block. However, Guile's implementation does not enforce that
-restriction.
-
-@unnumberedsubsubsec Custom Printers
-
-You may use @code{set-record-type-printer!} to customize the default printing
-behavior of records. This is a Guile extension and is not part of SRFI-9. It
-is located in the @nicode{(srfi srfi-9 gnu)} module.
-
-@deffn {Scheme Syntax} set-record-type-printer! name proc
-Where @var{type} corresponds to the first argument of @code{define-record-type},
-and @var{proc} is a procedure accepting two arguments, the record to print, and
-an output port.
-@end deffn
-
-@noindent
-This example prints the employee's name in brackets, for instance @code{[Fred]}.
-
-@example
-(set-record-type-printer!
- (lambda (record port)
- (write-char #\[ port)
- (display (employee-name record) port)
- (write-char #\] port)))
-@end example
-
-@unnumberedsubsubsec Functional ``Setters''
-
-@cindex functional setters
-
-When writing code in a functional style, it is desirable to never alter
-the contents of records. For such code, a simple way to return new
-record instances based on existing ones is highly desirable.
-
-The @code{(srfi srfi-9 gnu)} module extends SRFI-9 with facilities to
-return new record instances based on existing ones, only with one or
-more field values changed---@dfn{functional setters}. First, the
-@code{define-immutable-record-type} works like
-@code{define-record-type}, except that fields are immutable and setters
-are defined as functional setters.
-
-@deffn {Scheme Syntax} define-immutable-record-type type @* (constructor fieldname @dots{}) @* predicate @* (fieldname accessor [modifier]) @dots{}
-Define @var{type} as a new record type, like @code{define-record-type}.
-However, the record type is made @emph{immutable} (records may not be
-mutated, even with @code{struct-set!}), and any @var{modifier} is
-defined to be a functional setter---a procedure that returns a new
-record instance with the specified field changed, and leaves the
-original unchanged (see example below.)
-@end deffn
-
-@noindent
-In addition, the generic @code{set-field} and @code{set-fields} macros
-may be applied to any SRFI-9 record.
-
-@deffn {Scheme Syntax} set-field record (field sub-fields ...) value
-Return a new record of @var{record}'s type whose fields are equal to
-the corresponding fields of @var{record} except for the one specified by
-@var{field}.
-
-@var{field} must be the name of the getter corresponding to the field of
-@var{record} being ``set''. Subsequent @var{sub-fields} must be record
-getters designating sub-fields within that field value to be set (see
-example below.)
-@end deffn
-
-@deffn {Scheme Syntax} set-fields record ((field sub-fields ...) value) ...
-Like @code{set-field}, but can be used to set more than one field at a
-time. This expands to code that is more efficient than a series of
-single @code{set-field} calls.
-@end deffn
-
-To illustrate the use of functional setters, let's assume these two
-record type definitions:
-
-@example
-(define-record-type
- (address street city country)
- address?
- (street address-street)
- (city address-city)
- (country address-country))
-
-(define-immutable-record-type
- (person age email address)
- person?
- (age person-age set-person-age)
- (email person-email set-person-email)
- (address person-address set-person-address))
-@end example
-
-@noindent
-First, note that the @code{} record type definition introduces
-named functional setters. These may be used like this:
-
-@example
-(define fsf-address
- (address "Franklin Street" "Boston" "USA"))
-
-(define rms
- (person 30 "rms@@gnu.org" fsf-address))
-
-(and (equal? (set-person-age rms 60)
- (person 60 "rms@@gnu.org" fsf-address))
- (= (person-age rms) 30))
-@result{} #t
-@end example
-
-@noindent
-Here, the original @code{} record, to which @var{rms} is bound,
-is left unchanged.
-
-Now, suppose we want to change both the street and age of @var{rms}.
-This can be achieved using @code{set-fields}:
-
-@example
-(set-fields rms
- ((person-age) 60)
- ((person-address address-street) "Temple Place"))
-@result{} #< age: 60 email: "rms@@gnu.org"
- address: #< street: "Temple Place" city: "Boston" country: "USA">>
-@end example
-
-@noindent
-Notice how the above changed two fields of @var{rms}, including the
-@code{street} field of its @code{address} field, in a concise way. Also
-note that @code{set-fields} works equally well for types defined with
-just @code{define-record-type}.
-
-@node Records
-@subsection Records
-
-A @dfn{record type} is a first class object representing a user-defined
-data type. A @dfn{record} is an instance of a record type.
-
-Note that in many ways, this interface is too low-level for every-day
-use. Most uses of records are better served by SRFI-9 records.
-@xref{SRFI-9 Records}.
-
-@deffn {Scheme Procedure} record? obj
-Return @code{#t} if @var{obj} is a record of any type and @code{#f}
-otherwise.
-
-Note that @code{record?} may be true of any Scheme value; there is no
-promise that records are disjoint with other Scheme types.
-@end deffn
-
-@deffn {Scheme Procedure} make-record-type type-name field-names [print]
-Create and return a new @dfn{record-type descriptor}.
-
-@var{type-name} is a string naming the type. Currently it's only used
-in the printed representation of records, and in diagnostics.
-@var{field-names} is a list of symbols naming the fields of a record
-of the type. Duplicates are not allowed among these symbols.
-
-@example
-(make-record-type "employee" '(name age salary))
-@end example
-
-The optional @var{print} argument is a function used by
-@code{display}, @code{write}, etc, for printing a record of the new
-type. It's called as @code{(@var{print} record port)} and should look
-at @var{record} and write to @var{port}.
-@end deffn
-
-@deffn {Scheme Procedure} record-constructor rtd [field-names]
-Return a procedure for constructing new members of the type represented
-by @var{rtd}. The returned procedure accepts exactly as many arguments
-as there are symbols in the given list, @var{field-names}; these are
-used, in order, as the initial values of those fields in a new record,
-which is returned by the constructor procedure. The values of any
-fields not named in that list are unspecified. The @var{field-names}
-argument defaults to the list of field names in the call to
-@code{make-record-type} that created the type represented by @var{rtd};
-if the @var{field-names} argument is provided, it is an error if it
-contains any duplicates or any symbols not in the default list.
-@end deffn
-
-@deffn {Scheme Procedure} record-predicate rtd
-Return a procedure for testing membership in the type represented by
-@var{rtd}. The returned procedure accepts exactly one argument and
-returns a true value if the argument is a member of the indicated record
-type; it returns a false value otherwise.
-@end deffn
-
-@deffn {Scheme Procedure} record-accessor rtd field-name
-Return a procedure for reading the value of a particular field of a
-member of the type represented by @var{rtd}. The returned procedure
-accepts exactly one argument which must be a record of the appropriate
-type; it returns the current value of the field named by the symbol
-@var{field-name} in that record. The symbol @var{field-name} must be a
-member of the list of field-names in the call to @code{make-record-type}
-that created the type represented by @var{rtd}.
-@end deffn
-
-@deffn {Scheme Procedure} record-modifier rtd field-name
-Return a procedure for writing the value of a particular field of a
-member of the type represented by @var{rtd}. The returned procedure
-accepts exactly two arguments: first, a record of the appropriate type,
-and second, an arbitrary Scheme value; it modifies the field named by
-the symbol @var{field-name} in that record to contain the given value.
-The returned value of the modifier procedure is unspecified. The symbol
-@var{field-name} must be a member of the list of field-names in the call
-to @code{make-record-type} that created the type represented by
-@var{rtd}.
-@end deffn
-
-@deffn {Scheme Procedure} record-type-descriptor record
-Return a record-type descriptor representing the type of the given
-record. That is, for example, if the returned descriptor were passed to
-@code{record-predicate}, the resulting predicate would return a true
-value when passed the given record. Note that it is not necessarily the
-case that the returned descriptor is the one that was passed to
-@code{record-constructor} in the call that created the constructor
-procedure that created the given record.
-@end deffn
-
-@deffn {Scheme Procedure} record-type-name rtd
-Return the type-name associated with the type represented by rtd. The
-returned value is @code{eqv?} to the @var{type-name} argument given in
-the call to @code{make-record-type} that created the type represented by
-@var{rtd}.
-@end deffn
-
-@deffn {Scheme Procedure} record-type-fields rtd
-Return a list of the symbols naming the fields in members of the type
-represented by @var{rtd}. The returned value is @code{equal?} to the
-field-names argument given in the call to @code{make-record-type} that
-created the type represented by @var{rtd}.
-@end deffn
-
-
-@node Structures
-@subsection Structures
-@tpindex Structures
-
-A @dfn{structure} is a first class data type which holds Scheme values
-or C words in fields numbered 0 upwards. A @dfn{vtable} is a structure
-that represents a structure type, giving field types and permissions,
-and an optional print function for @code{write} etc.
-
-Structures are lower level than records (@pxref{Records}). Usually,
-when you need to represent structured data, you just want to use
-records. But sometimes you need to implement new kinds of structured
-data abstractions, and for that purpose structures are useful. Indeed,
-records in Guile are implemented with structures.
-
-@menu
-* Vtables::
-* Structure Basics::
-* Vtable Contents::
-* Meta-Vtables::
-* Vtable Example::
-* Tail Arrays::
-@end menu
-
-@node Vtables
-@subsubsection Vtables
-
-A vtable is a structure type, specifying its layout, and other
-information. A vtable is actually itself a structure, but there's no
-need to worry about that initially (@pxref{Vtable Contents}.)
-
-@deffn {Scheme Procedure} make-vtable fields [print]
-Create a new vtable.
-
-@var{fields} is a string describing the fields in the structures to be
-created. Each field is represented by two characters, a type letter
-and a permissions letter, for example @code{"pw"}. The types are as
-follows.
-
-@itemize @bullet{}
-@item
-@code{p} -- a Scheme value. ``p'' stands for ``protected'' meaning
-it's protected against garbage collection.
-
-@item
-@code{u} -- an arbitrary word of data (an @code{scm_t_bits}). At the
-Scheme level it's read and written as an unsigned integer. ``u''
-stands for ``uninterpreted'' (it's not treated as a Scheme value), or
-``unprotected'' (it's not marked during GC), or ``unsigned long'' (its
-size), or all of these things.
-
-@item
-@code{s} -- a self-reference. Such a field holds the @code{SCM} value
-of the structure itself (a circular reference). This can be useful in
-C code where you might have a pointer to the data array, and want to
-get the Scheme @code{SCM} handle for the structure. In Scheme code it
-has no use.
-@end itemize
-
-The second letter for each field is a permission code,
-
-@itemize @bullet{}
-@item
-@code{w} -- writable, the field can be read and written.
-@item
-@code{r} -- read-only, the field can be read but not written.
-@item
-@code{o} -- opaque, the field can be neither read nor written at the
-Scheme level. This can be used for fields which should only be used
-from C code.
-@end itemize
-
-Here are some examples. @xref{Tail Arrays}, for information on the
-legacy tail array facility.
-
-@example
-(make-vtable "pw") ;; one writable field
-(make-vtable "prpw") ;; one read-only and one writable
-(make-vtable "pwuwuw") ;; one scheme and two uninterpreted
-@end example
-
-The optional @var{print} argument is a function called by
-@code{display} and @code{write} (etc) to give a printed representation
-of a structure created from this vtable. It's called
-@code{(@var{print} struct port)} and should look at @var{struct} and
-write to @var{port}. The default print merely gives a form like
-@samp{#} with a pair of machine addresses.
-
-The following print function for example shows the two fields of its
-structure.
-
-@example
-(make-vtable "prpw"
- (lambda (struct port)
- (format port "#<~a and ~a>"
- (struct-ref struct 0)
- (struct-ref struct 1))))
-@end example
-@end deffn
-
-
-@node Structure Basics
-@subsubsection Structure Basics
-
-This section describes the basic procedures for working with
-structures. @code{make-struct} creates a structure, and
-@code{struct-ref} and @code{struct-set!} access its fields.
-
-@deffn {Scheme Procedure} make-struct vtable tail-size init @dots{}
-@deffnx {Scheme Procedure} make-struct/no-tail vtable init @dots{}
-Create a new structure, with layout per the given @var{vtable}
-(@pxref{Vtables}).
-
-The optional @var{init}@dots{} arguments are initial values for the
-fields of the structure. This is the only way to
-put values in read-only fields. If there are fewer @var{init}
-arguments than fields then the defaults are @code{#f} for a Scheme
-field (type @code{p}) or 0 for an uninterpreted field (type @code{u}).
-
-Structures also have the ability to allocate a variable number of
-additional cells at the end, at their tails. However, this legacy
-@dfn{tail array} facilty is confusing and inefficient, and so we do not
-recommend it. @xref{Tail Arrays}, for more on the legacy tail array
-interface.
-
-Type @code{s} self-reference fields, permission @code{o} opaque
-fields, and the count field of a tail array are all ignored for the
-@var{init} arguments, ie.@: an argument is not consumed by such a
-field. An @code{s} is always set to the structure itself, an @code{o}
-is always set to @code{#f} or 0 (with the intention that C code will
-do something to it later), and the tail count is always the given
-@var{tail-size}.
-
-For example,
-
-@example
-(define v (make-vtable "prpwpw"))
-(define s (make-struct v 0 123 "abc" 456))
-(struct-ref s 0) @result{} 123
-(struct-ref s 1) @result{} "abc"
-@end example
-@end deffn
-
-@deftypefn {C Function} SCM scm_make_struct (SCM vtable, SCM tail_size, SCM init_list)
-@deftypefnx {C Function} SCM scm_c_make_struct (SCM vtable, SCM tail_size, SCM init, ...)
-@deftypefnx {C Function} SCM scm_c_make_structv (SCM vtable, SCM tail_size, size_t n_inits, scm_t_bits init[])
-There are a few ways to make structures from C. @code{scm_make_struct}
-takes a list, @code{scm_c_make_struct} takes variable arguments
-terminated with SCM_UNDEFINED, and @code{scm_c_make_structv} takes a
-packed array.
-@end deftypefn
-
-@deffn {Scheme Procedure} struct? obj
-@deffnx {C Function} scm_struct_p (obj)
-Return @code{#t} if @var{obj} is a structure, or @code{#f} if not.
-@end deffn
-
-@deffn {Scheme Procedure} struct-ref struct n
-@deffnx {C Function} scm_struct_ref (struct, n)
-Return the contents of field number @var{n} in @var{struct}. The
-first field is number 0.
-
-An error is thrown if @var{n} is out of range, or if the field cannot
-be read because it's @code{o} opaque.
-@end deffn
-
-@deffn {Scheme Procedure} struct-set! struct n value
-@deffnx {C Function} scm_struct_set_x (struct, n, value)
-Set field number @var{n} in @var{struct} to @var{value}. The first
-field is number 0.
-
-An error is thrown if @var{n} is out of range, or if the field cannot
-be written because it's @code{r} read-only or @code{o} opaque.
-@end deffn
-
-@deffn {Scheme Procedure} struct-vtable struct
-@deffnx {C Function} scm_struct_vtable (struct)
-Return the vtable that describes @var{struct}.
-
-The vtable is effectively the type of the structure. See @ref{Vtable
-Contents}, for more on vtables.
-@end deffn
-
-
-@node Vtable Contents
-@subsubsection Vtable Contents
-
-A vtable is itself a structure. It has a specific set of fields
-describing various aspects of its @dfn{instances}: the structures
-created from a vtable. Some of the fields are internal to Guile, some
-of them are part of the public interface, and there may be additional
-fields added on by the user.
-
-Every vtable has a field for the layout of their instances, a field for
-the procedure used to print its instances, and a field for the name of
-the vtable itself. Access to the layout and printer is exposed directly
-via field indexes. Access to the vtable name is exposed via accessor
-procedures.
-
-@defvr {Scheme Variable} vtable-index-layout
-@defvrx {C Macro} scm_vtable_index_layout
-The field number of the layout specification in a vtable. The layout
-specification is a symbol like @code{pwpw} formed from the fields
-string passed to @code{make-vtable}, or created by
-@code{make-struct-layout} (@pxref{Meta-Vtables}).
-
-@example
-(define v (make-vtable "pwpw" 0))
-(struct-ref v vtable-index-layout) @result{} pwpw
-@end example
-
-This field is read-only, since the layout of structures using a vtable
-cannot be changed.
-@end defvr
-
-@defvr {Scheme Variable} vtable-index-printer
-@defvrx {C Macro} scm_vtable_index_printer
-The field number of the printer function. This field contains @code{#f}
-if the default print function should be used.
-
-@example
-(define (my-print-func struct port)
- ...)
-(define v (make-vtable "pwpw" my-print-func))
-(struct-ref v vtable-index-printer) @result{} my-print-func
-@end example
-
-This field is writable, allowing the print function to be changed
-dynamically.
-@end defvr
-
-@deffn {Scheme Procedure} struct-vtable-name vtable
-@deffnx {Scheme Procedure} set-struct-vtable-name! vtable name
-@deffnx {C Function} scm_struct_vtable_name (vtable)
-@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name)
-Get or set the name of @var{vtable}. @var{name} is a symbol and is
-used in the default print function when printing structures created
-from @var{vtable}.
-
-@example
-(define v (make-vtable "pw"))
-(set-struct-vtable-name! v 'my-name)
-
-(define s (make-struct v 0))
-(display s) @print{} #
-@end example
-@end deffn
-
-
-@node Meta-Vtables
-@subsubsection Meta-Vtables
-
-As a structure, a vtable also has a vtable, which is also a structure.
-Structures, their vtables, the vtables of the vtables, and so on form a
-tree of structures. Making a new structure adds a leaf to the tree, and
-if that structure is a vtable, it may be used to create other leaves.
-
-If you traverse up the tree of vtables, via calling
-@code{struct-vtable}, eventually you reach a root which is the vtable of
-itself:
-
-@example
-scheme@@(guile-user)> (current-module)
-$1 = #
-scheme@@(guile-user)> (struct-vtable $1)
-$2 = #
-scheme@@(guile-user)> (struct-vtable $2)
-$3 = #< 12c30a0>
-scheme@@(guile-user)> (struct-vtable $3)
-$4 = #< 12c3fa0>
-scheme@@(guile-user)> (struct-vtable $4)
-$5 = #< 12c3fa0>
-scheme@@(guile-user)>
-$6 = #< 12c3fa0>
-@end example
-
-In this example, we can say that @code{$1} is an instance of @code{$2},
-@code{$2} is an instance of @code{$3}, @code{$3} is an instance of
-@code{$4}, and @code{$4}, strangely enough, is an instance of itself.
-The value bound to @code{$4} in this console session also bound to
-@code{} in the default environment.
-
-@defvr {Scheme Variable}
-A meta-vtable, useful for making new vtables.
-@end defvr
-
-All of these values are structures. All but @code{$1} are vtables. As
-@code{$2} is an instance of @code{$3}, and @code{$3} is a vtable, we can
-say that @code{$3} is a @dfn{meta-vtable}: a vtable that can create
-vtables.
-
-With this definition, we can specify more precisely what a vtable is: a
-vtable is a structure made from a meta-vtable. Making a structure from
-a meta-vtable runs some special checks to ensure that the first field of
-the structure is a valid layout. Additionally, if these checks see that
-the layout of the child vtable contains all the required fields of a
-vtable, in the correct order, then the child vtable will also be a
-meta-table, inheriting a magical bit from the parent.
-
-@deffn {Scheme Procedure} struct-vtable? obj
-@deffnx {C Function} scm_struct_vtable_p (obj)
-Return @code{#t} if @var{obj} is a vtable structure: an instance of a
-meta-vtable.
-@end deffn
-
-@code{} is a root of the vtable tree. (Normally there
-is only one root in a given Guile process, but due to some legacy
-interfaces there may be more than one.)
-
-The set of required fields of a vtable is the set of fields in the
-@code{}, and is bound to @code{standard-vtable-fields}
-in the default environment. It is possible to create a meta-vtable that
-with additional fields in its layout, which can be used to create
-vtables with additional data:
-
-@example
-scheme@@(guile-user)> (struct-ref $3 vtable-index-layout)
-$6 = pruhsruhpwphuhuhprprpw
-scheme@@(guile-user)> (struct-ref $4 vtable-index-layout)
-$7 = pruhsruhpwphuhuh
-scheme@@(guile-user)> standard-vtable-fields
-$8 = "pruhsruhpwphuhuh"
-scheme@@(guile-user)> (struct-ref $2 vtable-offset-user)
-$9 = module
-@end example
-
-In this continuation of our earlier example, @code{$2} is a vtable that
-has extra fields, because its vtable, @code{$3}, was made from a
-meta-vtable with an extended layout. @code{vtable-offset-user} is a
-convenient definition that indicates the number of fields in
-@code{standard-vtable-fields}.
-
-@defvr {Scheme Variable} standard-vtable-fields
-A string containing the orderedq set of fields that a vtable must have.
-@end defvr
-
-@defvr {Scheme Variable} vtable-offset-user
-The first index in a vtable that is available for a user.
-@end defvr
-
-@deffn {Scheme Procedure} make-struct-layout fields
-@deffnx {C Function} scm_make_struct_layout (fields)
-Return a structure layout symbol, from a @var{fields} string.
-@var{fields} is as described under @code{make-vtable}
-(@pxref{Vtables}). An invalid @var{fields} string is an error.
-@end deffn
-
-With these definitions, one can define @code{make-vtable} in this way:
-
-@example
-(define* (make-vtable fields #:optional printer)
- (make-struct/no-tail
- (make-struct-layout fields)
- printer))
-@end example
-
-
-@node Vtable Example
-@subsubsection Vtable Example
-
-Let us bring these points together with an example. Consider a simple
-object system with single inheritance. Objects will be normal
-structures, and classes will be vtables with three extra class fields:
-the name of the class, the parent class, and the list of fields.
-
-So, first we need a meta-vtable that allocates instances with these
-extra class fields.
-
-@example
-(define
- (make-vtable
- (string-append standard-vtable-fields "pwpwpw")
- (lambda (x port)
- (format port "< ~a>" (class-name x)))))
-
-(define (class? x)
- (and (struct? x)
- (eq? (struct-vtable x) )))
-@end example
-
-To make a structure with a specific meta-vtable, we will use
-@code{make-struct/no-tail}, passing it the computed instance layout and
-printer, as with @code{make-vtable}, and additionally the extra three
-class fields.
-
-@example
-(define (make-class name parent fields)
- (let* ((fields (compute-fields parent fields))
- (layout (compute-layout fields)))
- (make-struct/no-tail
- layout
- (lambda (x port)
- (print-instance x port))
- name
- parent
- fields)))
-@end example
-
-Instances will store their associated data in slots in the structure: as
-many slots as there are fields. The @code{compute-layout} procedure
-below can compute a layout, and @code{field-index} returns the slot
-corresponding to a field.
-
-@example
-(define-syntax-rule (define-accessor name n)
- (define (name obj)
- (struct-ref obj n)))
-
-;; Accessors for classes
-(define-accessor class-name (+ vtable-offset-user 0))
-(define-accessor class-parent (+ vtable-offset-user 1))
-(define-accessor class-fields (+ vtable-offset-user 2))
-
-(define (compute-fields parent fields)
- (if parent
- (append (class-fields parent) fields)
- fields))
-
-(define (compute-layout fields)
- (make-struct-layout
- (string-concatenate (make-list (length fields) "pw"))))
-
-(define (field-index class field)
- (list-index (class-fields class) field))
-
-(define (print-instance x port)
- (format port "<~a" (class-name (struct-vtable x)))
- (for-each (lambda (field idx)
- (format port " ~a: ~a" field (struct-ref x idx)))
- (class-fields (struct-vtable x))
- (iota (length (class-fields (struct-vtable x)))))
- (format port ">"))
-@end example
-
-So, at this point we can actually make a few classes:
-
-@example
-(define-syntax-rule (define-class name parent field ...)
- (define name (make-class 'name parent '(field ...))))
-
-(define-class #f
- width height)
-
-(define-class
- x y)
-@end example
-
-And finally, make an instance:
-
-@example
-(make-struct/no-tail 400 300 10 20)
-@result{} < width: 400 height: 300 x: 10 y: 20>
-@end example
-
-And that's that. Note that there are many possible optimizations and
-feature enhancements that can be made to this object system, and the
-included GOOPS system does make most of them. For more simple use
-cases, the records facility is usually sufficient. But sometimes you
-need to make new kinds of data abstractions, and for that purpose,
-structs are here.
-
-@node Tail Arrays
-@subsubsection Tail Arrays
-
-Guile's structures have a facility whereby each instance of a vtable can
-contain a variable-length tail array of values. The length of the tail
-array is stored in the structure. This facility was originally intended
-to allow C code to expose raw C structures with word-sized tail arrays
-to Scheme.
-
-However, the tail array facility is confusing and doesn't work very
-well. It is very rarely used, but it insinuates itself into all
-invocations of @code{make-struct}. For this reason the clumsily-named
-@code{make-struct/no-tail} procedure can actually be more elegant in
-actual use, because it doesn't have a random @code{0} argument stuck in
-the middle.
-
-Tail arrays also inhibit optimization by allowing instances to affect
-their shapes. In the absence of tail arrays, all instances of a given
-vtable have the same number and kinds of fields. This uniformity can be
-exploited by the runtime and the optimizer. The presence of tail arrays
-make some of these optimizations more difficult.
-
-Finally, the tail array facility is ad-hoc and does not compose with the
-rest of Guile. If a Guile user wants an array with user-specified
-length, it's best to use a vector. It is more clear in the code, and
-the standard optimization techniques will do a good job with it.
-
-That said, we should mention some details about the interface. A vtable
-that has tail array has upper-case permission descriptors: @code{W},
-@code{R} or @code{O}, correspoding to tail arrays of writable,
-read-only, or opaque elements. A tail array permission descriptor may
-only appear in the last element of a vtable layout.
-
-For exampple, @samp{pW} indicates a tail of writable Scheme-valued
-fields. The @samp{pW} field itself holds the tail size, and the tail
-fields come after it.
-
-@example
-(define v (make-vtable "prpW")) ;; one fixed then a tail array
-(define s (make-struct v 6 "fixed field" 'x 'y))
-(struct-ref s 0) @result{} "fixed field"
-(struct-ref s 1) @result{} 2 ;; tail size
-(struct-ref s 2) @result{} x ;; tail array ...
-(struct-ref s 3) @result{} y
-(struct-ref s 4) @result{} #f
-@end example
-
-
-@node Dictionary Types
-@subsection Dictionary Types
-
-A @dfn{dictionary} object is a data structure used to index
-information in a user-defined way. In standard Scheme, the main
-aggregate data types are lists and vectors. Lists are not really
-indexed at all, and vectors are indexed only by number
-(e.g.@: @code{(vector-ref foo 5)}). Often you will find it useful
-to index your data on some other type; for example, in a library
-catalog you might want to look up a book by the name of its
-author. Dictionaries are used to help you organize information in
-such a way.
-
-An @dfn{association list} (or @dfn{alist} for short) is a list of
-key-value pairs. Each pair represents a single quantity or
-object; the @code{car} of the pair is a key which is used to
-identify the object, and the @code{cdr} is the object's value.
-
-A @dfn{hash table} also permits you to index objects with
-arbitrary keys, but in a way that makes looking up any one object
-extremely fast. A well-designed hash system makes hash table
-lookups almost as fast as conventional array or vector references.
-
-Alists are popular among Lisp programmers because they use only
-the language's primitive operations (lists, @dfn{car}, @dfn{cdr}
-and the equality primitives). No changes to the language core are
-necessary. Therefore, with Scheme's built-in list manipulation
-facilities, it is very convenient to handle data stored in an
-association list. Also, alists are highly portable and can be
-easily implemented on even the most minimal Lisp systems.
-
-However, alists are inefficient, especially for storing large
-quantities of data. Because we want Guile to be useful for large
-software systems as well as small ones, Guile provides a rich set
-of tools for using either association lists or hash tables.
-
-@node Association Lists
-@subsection Association Lists
-@tpindex Association Lists
-@tpindex Alist
-@cindex association List
-@cindex alist
-@cindex database
-
-An association list is a conventional data structure that is often used
-to implement simple key-value databases. It consists of a list of
-entries in which each entry is a pair. The @dfn{key} of each entry is
-the @code{car} of the pair and the @dfn{value} of each entry is the
-@code{cdr}.
-
-@example
-ASSOCIATION LIST ::= '( (KEY1 . VALUE1)
- (KEY2 . VALUE2)
- (KEY3 . VALUE3)
- @dots{}
- )
-@end example
-
-@noindent
-Association lists are also known, for short, as @dfn{alists}.
-
-The structure of an association list is just one example of the infinite
-number of possible structures that can be built using pairs and lists.
-As such, the keys and values in an association list can be manipulated
-using the general list structure procedures @code{cons}, @code{car},
-@code{cdr}, @code{set-car!}, @code{set-cdr!} and so on. However,
-because association lists are so useful, Guile also provides specific
-procedures for manipulating them.
-
-@menu
-* Alist Key Equality::
-* Adding or Setting Alist Entries::
-* Retrieving Alist Entries::
-* Removing Alist Entries::
-* Sloppy Alist Functions::
-* Alist Example::
-@end menu
-
-@node Alist Key Equality
-@subsubsection Alist Key Equality
-
-All of Guile's dedicated association list procedures, apart from
-@code{acons}, come in three flavours, depending on the level of equality
-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
-required entry.
-
-@itemize @bullet
-@item
-Procedures with @dfn{assq} in their name use @code{eq?} to determine key
-equality.
-
-@item
-Procedures with @dfn{assv} in their name use @code{eqv?} to determine
-key equality.
-
-@item
-Procedures with @dfn{assoc} in their name use @code{equal?} to
-determine key equality.
-@end itemize
-
-@code{acons} is an exception because it is used to build association
-lists which do not require their entries' keys to be unique.
-
-@node Adding or Setting Alist Entries
-@subsubsection Adding or Setting Alist Entries
-
-@code{acons} adds a new entry to an association list and returns the
-combined association list. The combined alist is formed by consing the
-new entry onto the head of the alist specified in the @code{acons}
-procedure call. So the specified alist is not modified, but its
-contents become shared with the tail of the combined alist that
-@code{acons} returns.
-
-In the most common usage of @code{acons}, a variable holding the
-original association list is updated with the combined alist:
-
-@example
-(set! address-list (acons name address address-list))
-@end example
-
-In such cases, it doesn't matter that the old and new values of
-@code{address-list} share some of their contents, since the old value is
-usually no longer independently accessible.
-
-Note that @code{acons} adds the specified new entry regardless of
-whether the alist may already contain entries with keys that are, in
-some sense, the same as that of the new entry. Thus @code{acons} is
-ideal for building alists where there is no concept of key uniqueness.
-
-@example
-(set! task-list (acons 3 "pay gas bill" '()))
-task-list
-@result{}
-((3 . "pay gas bill"))
-
-(set! task-list (acons 3 "tidy bedroom" task-list))
-task-list
-@result{}
-((3 . "tidy bedroom") (3 . "pay gas bill"))
-@end example
-
-@code{assq-set!}, @code{assv-set!} and @code{assoc-set!} are used to add
-or replace an entry in an association list where there @emph{is} a
-concept of key uniqueness. If the specified association list already
-contains an entry whose key is the same as that specified in the
-procedure call, the existing entry is replaced by the new one.
-Otherwise, the new entry is consed onto the head of the old association
-list to create the combined alist. In all cases, these procedures
-return the combined alist.
-
-@code{assq-set!} and friends @emph{may} destructively modify the
-structure of the old association list in such a way that an existing
-variable is correctly updated without having to @code{set!} it to the
-value returned:
-
-@example
-address-list
-@result{}
-(("mary" . "34 Elm Road") ("james" . "16 Bow Street"))
-
-(assoc-set! address-list "james" "1a London Road")
-@result{}
-(("mary" . "34 Elm Road") ("james" . "1a London Road"))
-
-address-list
-@result{}
-(("mary" . "34 Elm Road") ("james" . "1a London Road"))
-@end example
-
-Or they may not:
-
-@example
-(assoc-set! address-list "bob" "11 Newington Avenue")
-@result{}
-(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road")
- ("james" . "1a London Road"))
-
-address-list
-@result{}
-(("mary" . "34 Elm Road") ("james" . "1a London Road"))
-@end example
-
-The only safe way to update an association list variable when adding or
-replacing an entry like this is to @code{set!} the variable to the
-returned value:
-
-@example
-(set! address-list
- (assoc-set! address-list "bob" "11 Newington Avenue"))
-address-list
-@result{}
-(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road")
- ("james" . "1a London Road"))
-@end example
-
-Because of this slight inconvenience, you may find it more convenient to
-use hash tables to store dictionary data. If your application will not
-be modifying the contents of an alist very often, this may not make much
-difference to you.
-
-If you need to keep the old value of an association list in a form
-independent from the list that results from modification by
-@code{acons}, @code{assq-set!}, @code{assv-set!} or @code{assoc-set!},
-use @code{list-copy} to copy the old association list before modifying
-it.
-
-@deffn {Scheme Procedure} acons key value alist
-@deffnx {C Function} scm_acons (key, value, alist)
-Add a new key-value pair to @var{alist}. A new pair is
-created whose car is @var{key} and whose cdr is @var{value}, and the
-pair is consed onto @var{alist}, and the new list is returned. This
-function is @emph{not} destructive; @var{alist} is not modified.
-@end deffn
-
-@deffn {Scheme Procedure} assq-set! alist key val
-@deffnx {Scheme Procedure} assv-set! alist key value
-@deffnx {Scheme Procedure} assoc-set! alist key value
-@deffnx {C Function} scm_assq_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)
-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{value}. If @var{alist} does not contain an entry for @var{key},
-add a new one. Return the (possibly new) alist.
-
-These functions do not attempt to verify the structure of @var{alist},
-and so may cause unusual results if passed an object that is not an
-association list.
-@end deffn
-
-@node Retrieving Alist Entries
-@subsubsection Retrieving Alist Entries
-@rnindex assq
-@rnindex assv
-@rnindex assoc
-
-@code{assq}, @code{assv} and @code{assoc} find the entry in an alist
-for a given key, and return the @code{(@var{key} . @var{value})} pair.
-@code{assq-ref}, @code{assv-ref} and @code{assoc-ref} do a similar
-lookup, but return just the @var{value}.
-
-@deffn {Scheme Procedure} assq key alist
-@deffnx {Scheme Procedure} assv key alist
-@deffnx {Scheme Procedure} assoc key alist
-@deffnx {C Function} scm_assq (key, alist)
-@deffnx {C Function} scm_assv (key, alist)
-@deffnx {C Function} scm_assoc (key, alist)
-Return the first entry in @var{alist} with the given @var{key}. The
-return is the pair @code{(KEY . VALUE)} from @var{alist}. If there's
-no matching entry the return is @code{#f}.
-
-@code{assq} compares keys with @code{eq?}, @code{assv} uses
-@code{eqv?} and @code{assoc} uses @code{equal?}. See also SRFI-1
-which has an extended @code{assoc} (@ref{SRFI-1 Association Lists}).
-@end deffn
-
-@deffn {Scheme Procedure} assq-ref alist key
-@deffnx {Scheme Procedure} assv-ref alist key
-@deffnx {Scheme Procedure} assoc-ref alist key
-@deffnx {C Function} scm_assq_ref (alist, key)
-@deffnx {C Function} scm_assv_ref (alist, key)
-@deffnx {C Function} scm_assoc_ref (alist, key)
-Return the value from the first entry in @var{alist} with the given
-@var{key}, or @code{#f} if there's no such entry.
-
-@code{assq-ref} compares keys with @code{eq?}, @code{assv-ref} uses
-@code{eqv?} and @code{assoc-ref} uses @code{equal?}.
-
-Notice these functions have the @var{key} argument last, like other
-@code{-ref} functions, but this is opposite to what @code{assq}
-etc above use.
-
-When the return is @code{#f} it can be either @var{key} not found, or
-an entry which happens to have value @code{#f} in the @code{cdr}. Use
-@code{assq} etc above if you need to differentiate these cases.
-@end deffn
-
-
-@node Removing Alist Entries
-@subsubsection Removing Alist Entries
-
-To remove the element from an association list whose key matches a
-specified key, use @code{assq-remove!}, @code{assv-remove!} or
-@code{assoc-remove!} (depending, as usual, on the level of equality
-required between the key that you specify and the keys in the
-association list).
-
-As with @code{assq-set!} and friends, the specified alist may or may not
-be modified destructively, and the only safe way to update a variable
-containing the alist is to @code{set!} it to the value that
-@code{assq-remove!} and friends return.
-
-@example
-address-list
-@result{}
-(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road")
- ("james" . "1a London Road"))
-
-(set! address-list (assoc-remove! address-list "mary"))
-address-list
-@result{}
-(("bob" . "11 Newington Avenue") ("james" . "1a London Road"))
-@end example
-
-Note that, when @code{assq/v/oc-remove!} is used to modify an
-association list that has been constructed only using the corresponding
-@code{assq/v/oc-set!}, there can be at most one matching entry in the
-alist, so the question of multiple entries being removed in one go does
-not arise. If @code{assq/v/oc-remove!} is applied to an association
-list that has been constructed using @code{acons}, or an
-@code{assq/v/oc-set!} with a different level of equality, or any mixture
-of these, it removes only the first matching entry from the alist, even
-if the alist might contain further matching entries. For example:
-
-@example
-(define address-list '())
-(set! address-list (assq-set! address-list "mary" "11 Elm Street"))
-(set! address-list (assq-set! address-list "mary" "57 Pine Drive"))
-address-list
-@result{}
-(("mary" . "57 Pine Drive") ("mary" . "11 Elm Street"))
-
-(set! address-list (assoc-remove! address-list "mary"))
-address-list
-@result{}
-(("mary" . "11 Elm Street"))
-@end example
-
-In this example, the two instances of the string "mary" are not the same
-when compared using @code{eq?}, so the two @code{assq-set!} calls add
-two distinct entries to @code{address-list}. When compared using
-@code{equal?}, both "mary"s in @code{address-list} are the same as the
-"mary" in the @code{assoc-remove!} call, but @code{assoc-remove!} stops
-after removing the first matching entry that it finds, and so one of the
-"mary" entries is left in place.
-
-@deffn {Scheme Procedure} assq-remove! alist key
-@deffnx {Scheme Procedure} assv-remove! alist key
-@deffnx {Scheme Procedure} assoc-remove! alist key
-@deffnx {C Function} scm_assq_remove_x (alist, key)
-@deffnx {C Function} scm_assv_remove_x (alist, key)
-@deffnx {C Function} scm_assoc_remove_x (alist, key)
-Delete the first entry in @var{alist} associated with @var{key}, and return
-the resulting alist.
-@end deffn
-
-@node Sloppy Alist Functions
-@subsubsection Sloppy Alist Functions
-
-@code{sloppy-assq}, @code{sloppy-assv} and @code{sloppy-assoc} behave
-like the corresponding non-@code{sloppy-} procedures, except that they
-return @code{#f} when the specified association list is not well-formed,
-where the non-@code{sloppy-} versions would signal an error.
-
-Specifically, there are two conditions for which the non-@code{sloppy-}
-procedures signal an error, which the @code{sloppy-} procedures handle
-instead by returning @code{#f}. Firstly, if the specified alist as a
-whole is not a proper list:
-
-@example
-(assoc "mary" '((1 . 2) ("key" . "door") . "open sesame"))
-@result{}
-ERROR: In procedure assoc in expression (assoc "mary" (quote #)):
-ERROR: Wrong type argument in position 2 (expecting
- association list): ((1 . 2) ("key" . "door") . "open sesame")
-
-(sloppy-assoc "mary" '((1 . 2) ("key" . "door") . "open sesame"))
-@result{}
-#f
-@end example
-
-@noindent
-Secondly, if one of the entries in the specified alist is not a pair:
-
-@example
-(assoc 2 '((1 . 1) 2 (3 . 9)))
-@result{}
-ERROR: In procedure assoc in expression (assoc 2 (quote #)):
-ERROR: Wrong type argument in position 2 (expecting
- association list): ((1 . 1) 2 (3 . 9))
-
-(sloppy-assoc 2 '((1 . 1) 2 (3 . 9)))
-@result{}
-#f
-@end example
-
-Unless you are explicitly working with badly formed association lists,
-it is much safer to use the non-@code{sloppy-} procedures, because they
-help to highlight coding and data errors that the @code{sloppy-}
-versions would silently cover up.
-
-@deffn {Scheme Procedure} sloppy-assq key alist
-@deffnx {C Function} scm_sloppy_assq (key, alist)
-Behaves like @code{assq} but does not do any error checking.
-Recommended only for use in Guile internals.
-@end deffn
-
-@deffn {Scheme Procedure} sloppy-assv key alist
-@deffnx {C Function} scm_sloppy_assv (key, alist)
-Behaves like @code{assv} but does not do any error checking.
-Recommended only for use in Guile internals.
-@end deffn
-
-@deffn {Scheme Procedure} sloppy-assoc key alist
-@deffnx {C Function} scm_sloppy_assoc (key, alist)
-Behaves like @code{assoc} but does not do any error checking.
-Recommended only for use in Guile internals.
-@end deffn
-
-@node Alist Example
-@subsubsection Alist Example
-
-Here is a longer example of how alists may be used in practice.
-
-@lisp
-(define capitals '(("New York" . "Albany")
- ("Oregon" . "Salem")
- ("Florida" . "Miami")))
-
-;; What's the capital of Oregon?
-(assoc "Oregon" capitals) @result{} ("Oregon" . "Salem")
-(assoc-ref capitals "Oregon") @result{} "Salem"
-
-;; We left out South Dakota.
-(set! capitals
- (assoc-set! capitals "South Dakota" "Pierre"))
-capitals
-@result{} (("South Dakota" . "Pierre")
- ("New York" . "Albany")
- ("Oregon" . "Salem")
- ("Florida" . "Miami"))
-
-;; And we got Florida wrong.
-(set! capitals
- (assoc-set! capitals "Florida" "Tallahassee"))
-capitals
-@result{} (("South Dakota" . "Pierre")
- ("New York" . "Albany")
- ("Oregon" . "Salem")
- ("Florida" . "Tallahassee"))
-
-;; After Oregon secedes, we can remove it.
-(set! capitals
- (assoc-remove! capitals "Oregon"))
-capitals
-@result{} (("South Dakota" . "Pierre")
- ("New York" . "Albany")
- ("Florida" . "Tallahassee"))
-@end lisp
-
-@node VHashes
-@subsection VList-Based Hash Lists or ``VHashes''
-
-@cindex VList-based hash lists
-@cindex VHash
-
-The @code{(ice-9 vlist)} module provides an implementation of @dfn{VList-based
-hash lists} (@pxref{VLists}). VList-based hash lists, or @dfn{vhashes}, are an
-immutable dictionary type similar to association lists that maps @dfn{keys} to
-@dfn{values}. However, unlike association lists, accessing a value given its
-key is typically a constant-time operation.
-
-The VHash programming interface of @code{(ice-9 vlist)} is mostly the same as
-that of association lists found in SRFI-1, with procedure names prefixed by
-@code{vhash-} instead of @code{alist-} (@pxref{SRFI-1 Association Lists}).
-
-In addition, vhashes can be manipulated using VList operations:
-
-@example
-(vlist-head (vhash-consq 'a 1 vlist-null))
-@result{} (a . 1)
-
-(define vh1 (vhash-consq 'b 2 (vhash-consq 'a 1 vlist-null)))
-(define vh2 (vhash-consq 'c 3 (vlist-tail vh1)))
-
-(vhash-assq 'a vh2)
-@result{} (a . 1)
-(vhash-assq 'b vh2)
-@result{} #f
-(vhash-assq 'c vh2)
-@result{} (c . 3)
-(vlist->list vh2)
-@result{} ((c . 3) (a . 1))
-@end example
-
-However, keep in mind that procedures that construct new VLists
-(@code{vlist-map}, @code{vlist-filter}, etc.) return raw VLists, not vhashes:
-
-@example
-(define vh (alist->vhash '((a . 1) (b . 2) (c . 3)) hashq))
-(vhash-assq 'a vh)
-@result{} (a . 1)
-
-(define vl
- ;; This will create a raw vlist.
- (vlist-filter (lambda (key+value) (odd? (cdr key+value))) vh))
-(vhash-assq 'a vl)
-@result{} ERROR: Wrong type argument in position 2
-
-(vlist->list vl)
-@result{} ((a . 1) (c . 3))
-@end example
-
-@deffn {Scheme Procedure} vhash? obj
-Return true if @var{obj} is a vhash.
-@end deffn
-
-@deffn {Scheme Procedure} vhash-cons key value vhash [hash-proc]
-@deffnx {Scheme Procedure} vhash-consq key value vhash
-@deffnx {Scheme Procedure} vhash-consv key value vhash
-Return a new hash list based on @var{vhash} where @var{key} is associated with
-@var{value}, using @var{hash-proc} to compute the hash of @var{key}.
-@var{vhash} must be either @code{vlist-null} or a vhash returned by a previous
-call to @code{vhash-cons}. @var{hash-proc} defaults to @code{hash} (@pxref{Hash
-Table Reference, @code{hash} procedure}). With @code{vhash-consq}, the
-@code{hashq} hash function is used; with @code{vhash-consv} the @code{hashv}
-hash function is used.
-
-All @code{vhash-cons} calls made to construct a vhash should use the same
-@var{hash-proc}. Failing to do that, the result is undefined.
-@end deffn
-
-@deffn {Scheme Procedure} vhash-assoc key vhash [equal? [hash-proc]]
-@deffnx {Scheme Procedure} vhash-assq key vhash
-@deffnx {Scheme Procedure} vhash-assv key vhash
-Return the first key/value pair from @var{vhash} whose key is equal to @var{key}
-according to the @var{equal?} equality predicate (which defaults to
-@code{equal?}), and using @var{hash-proc} (which defaults to @code{hash}) to
-compute the hash of @var{key}. The second form uses @code{eq?} as the equality
-predicate and @code{hashq} as the hash function; the last form uses @code{eqv?}
-and @code{hashv}.
-
-Note that it is important to consistently use the same hash function for
-@var{hash-proc} as was passed to @code{vhash-cons}. Failing to do that, the
-result is unpredictable.
-@end deffn
-
-@deffn {Scheme Procedure} vhash-delete key vhash [equal? [hash-proc]]
-@deffnx {Scheme Procedure} vhash-delq key vhash
-@deffnx {Scheme Procedure} vhash-delv key vhash
-Remove all associations from @var{vhash} with @var{key}, comparing keys with
-@var{equal?} (which defaults to @code{equal?}), and computing the hash of
-@var{key} using @var{hash-proc} (which defaults to @code{hash}). The second
-form uses @code{eq?} as the equality predicate and @code{hashq} as the hash
-function; the last one uses @code{eqv?} and @code{hashv}.
-
-Again the choice of @var{hash-proc} must be consistent with previous calls to
-@code{vhash-cons}.
-@end deffn
-
-@deffn {Scheme Procedure} vhash-fold proc init vhash
-@deffnx {Scheme Procedure} vhash-fold-right proc init vhash
-Fold over the key/value elements of @var{vhash} in the given direction,
-with each call to @var{proc} having the form @code{(@var{proc} key value
-result)}, where @var{result} is the result of the previous call to
-@var{proc} and @var{init} the value of @var{result} for the first call
-to @var{proc}.
-@end deffn
-
-@deffn {Scheme Procedure} vhash-fold* proc init key vhash [equal? [hash]]
-@deffnx {Scheme Procedure} vhash-foldq* proc init key vhash
-@deffnx {Scheme Procedure} vhash-foldv* proc init key vhash
-Fold over all the values associated with @var{key} in @var{vhash}, with each
-call to @var{proc} having the form @code{(proc value result)}, where
-@var{result} is the result of the previous call to @var{proc} and @var{init} the
-value of @var{result} for the first call to @var{proc}.
-
-Keys in @var{vhash} are hashed using @var{hash} are compared using @var{equal?}.
-The second form uses @code{eq?} as the equality predicate and @code{hashq} as
-the hash function; the third one uses @code{eqv?} and @code{hashv}.
-
-Example:
-
-@example
-(define vh
- (alist->vhash '((a . 1) (a . 2) (z . 0) (a . 3))))
-
-(vhash-fold* cons '() 'a vh)
-@result{} (3 2 1)
-
-(vhash-fold* cons '() 'z vh)
-@result{} (0)
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} alist->vhash alist [hash-proc]
-Return the vhash corresponding to @var{alist}, an association list, using
-@var{hash-proc} to compute key hashes. When omitted, @var{hash-proc} defaults
-to @code{hash}.
-@end deffn
-
-
-@node Hash Tables
-@subsection Hash Tables
-@tpindex Hash Tables
-
-Hash tables are dictionaries which offer similar functionality as
-association lists: They provide a mapping from keys to values. The
-difference is that association lists need time linear in the size of
-elements when searching for entries, whereas hash tables can normally
-search in constant time. The drawback is that hash tables require a
-little bit more memory, and that you can not use the normal list
-procedures (@pxref{Lists}) for working with them.
-
-@menu
-* Hash Table Examples:: Demonstration of hash table usage.
-* Hash Table Reference:: Hash table procedure descriptions.
-@end menu
-
-
-@node Hash Table Examples
-@subsubsection Hash Table Examples
-
-For demonstration purposes, this section gives a few usage examples of
-some hash table procedures, together with some explanation what they do.
-
-First we start by creating a new hash table with 31 slots, and
-populate it with two key/value pairs.
-
-@lisp
-(define h (make-hash-table 31))
-
-;; This is an opaque object
-h
-@result{}
-#
-
-;; Inserting into a hash table can be done with hashq-set!
-(hashq-set! h 'foo "bar")
-@result{}
-"bar"
-
-(hashq-set! h 'braz "zonk")
-@result{}
-"zonk"
-
-;; Or with hash-create-handle!
-(hashq-create-handle! h 'frob #f)
-@result{}
-(frob . #f)
-@end lisp
-
-You can get the value for a given key with the procedure
-@code{hashq-ref}, but the problem with this procedure is that you
-cannot reliably determine whether a key does exists in the table. The
-reason is that the procedure returns @code{#f} if the key is not in
-the table, but it will return the same value if the key is in the
-table and just happens to have the value @code{#f}, as you can see in
-the following examples.
-
-@lisp
-(hashq-ref h 'foo)
-@result{}
-"bar"
-
-(hashq-ref h 'frob)
-@result{}
-#f
-
-(hashq-ref h 'not-there)
-@result{}
-#f
-@end lisp
-
-Better is to use the procedure @code{hashq-get-handle}, which makes a
-distinction between the two cases. Just like @code{assq}, this
-procedure returns a key/value-pair on success, and @code{#f} if the
-key is not found.
-
-@lisp
-(hashq-get-handle h 'foo)
-@result{}
-(foo . "bar")
-
-(hashq-get-handle h 'not-there)
-@result{}
-#f
-@end lisp
-
-Interesting results can be computed by using @code{hash-fold} to work
-through each element. This example will count the total number of
-elements:
-
-@lisp
-(hash-fold (lambda (key value seed) (+ 1 seed)) 0 h)
-@result{}
-3
-@end lisp
-
-The same thing can be done with the procedure @code{hash-count}, which
-can also count the number of elements matching a particular predicate.
-For example, count the number of elements with string values:
-
-@lisp
-(hash-count (lambda (key value) (string? value)) h)
-@result{}
-2
-@end lisp
-
-Counting all the elements is a simple task using @code{const}:
-
-@lisp
-(hash-count (const #t) h)
-@result{}
-3
-@end lisp
-
-@node Hash Table Reference
-@subsubsection Hash Table Reference
-
-@c FIXME: Describe in broad terms what happens for resizing, and what
-@c the initial size means for this.
-
-Like the association list functions, the hash table functions come in
-several varieties, according to the equality test used for the keys.
-Plain @code{hash-} functions use @code{equal?}, @code{hashq-}
-functions use @code{eq?}, @code{hashv-} functions use @code{eqv?}, and
-the @code{hashx-} functions use an application supplied test.
-
-A single @code{make-hash-table} creates a hash table suitable for use
-with any set of functions, but it's imperative that just one set is
-then used consistently, or results will be unpredictable.
-
-Hash tables are implemented as a vector indexed by a hash value formed
-from the key, with an association list of key/value pairs for each
-bucket in case distinct keys hash together. Direct access to the
-pairs in those lists is provided by the @code{-handle-} functions.
-
-When the number of entries in a hash table goes above a threshold, the
-vector is made larger and the entries are rehashed, to prevent the
-bucket lists from becoming too long and slowing down accesses. When the
-number of entries goes below a threshold, the vector is shrunk to save
-space.
-
-For the @code{hashx-} ``extended'' routines, an application supplies a
-@var{hash} function producing an integer index like @code{hashq} etc
-below, and an @var{assoc} alist search function like @code{assq} etc
-(@pxref{Retrieving Alist Entries}). Here's an example of such
-functions implementing case-insensitive hashing of string keys,
-
-@example
-(use-modules (srfi srfi-1)
- (srfi srfi-13))
-
-(define (my-hash str size)
- (remainder (string-hash-ci str) size))
-(define (my-assoc str alist)
- (find (lambda (pair) (string-ci=? str (car pair))) alist))
-
-(define my-table (make-hash-table))
-(hashx-set! my-hash my-assoc my-table "foo" 123)
-
-(hashx-ref my-hash my-assoc my-table "FOO")
-@result{} 123
-@end example
-
-In a @code{hashx-} @var{hash} function the aim is to spread keys
-across the vector, so bucket lists don't become long. But the actual
-values are arbitrary as long as they're in the range 0 to
-@math{@var{size}-1}. Helpful functions for forming a hash value, in
-addition to @code{hashq} etc below, include @code{symbol-hash}
-(@pxref{Symbol Keys}), @code{string-hash} and @code{string-hash-ci}
-(@pxref{String Comparison}), and @code{char-set-hash}
-(@pxref{Character Set Predicates/Comparison}).
-
-@sp 1
-@deffn {Scheme Procedure} make-hash-table [size]
-Create a new hash table object, with an optional minimum
-vector @var{size}.
-
-When @var{size} is given, the table vector will still grow and shrink
-automatically, as described above, but with @var{size} as a minimum.
-If an application knows roughly how many entries the table will hold
-then it can use @var{size} to avoid rehashing when initial entries are
-added.
-@end deffn
-
-@deffn {Scheme Procedure} alist->hash-table alist
-@deffnx {Scheme Procedure} alist->hashq-table alist
-@deffnx {Scheme Procedure} alist->hashv-table alist
-@deffnx {Scheme Procedure} alist->hashx-table hash assoc alist
-Convert @var{alist} into a hash table. When keys are repeated in
-@var{alist}, the leftmost association takes precedence.
-
-@example
-(use-modules (ice-9 hash-table))
-(alist->hash-table '((foo . 1) (bar . 2)))
-@end example
-
-When converting to an extended hash table, custom @var{hash} and
-@var{assoc} procedures must be provided.
-
-@example
-(alist->hashx-table hash assoc '((foo . 1) (bar . 2)))
-@end example
-
-@end deffn
-
-@deffn {Scheme Procedure} hash-table? obj
-@deffnx {C Function} scm_hash_table_p (obj)
-Return @code{#t} if @var{obj} is a abstract hash table object.
-@end deffn
-
-@deffn {Scheme Procedure} hash-clear! table
-@deffnx {C Function} scm_hash_clear_x (table)
-Remove all items from @var{table} (without triggering a resize).
-@end deffn
-
-@deffn {Scheme Procedure} hash-ref table key [dflt]
-@deffnx {Scheme Procedure} hashq-ref table key [dflt]
-@deffnx {Scheme Procedure} hashv-ref table key [dflt]
-@deffnx {Scheme Procedure} hashx-ref hash assoc table key [dflt]
-@deffnx {C Function} scm_hash_ref (table, key, dflt)
-@deffnx {C Function} scm_hashq_ref (table, key, dflt)
-@deffnx {C Function} scm_hashv_ref (table, key, dflt)
-@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt)
-Lookup @var{key} in the given hash @var{table}, and return the
-associated value. If @var{key} is not found, return @var{dflt}, or
-@code{#f} if @var{dflt} is not given.
-@end deffn
-
-@deffn {Scheme Procedure} hash-set! table key val
-@deffnx {Scheme Procedure} hashq-set! table key val
-@deffnx {Scheme Procedure} hashv-set! table key val
-@deffnx {Scheme Procedure} hashx-set! hash assoc table key val
-@deffnx {C Function} scm_hash_set_x (table, key, val)
-@deffnx {C Function} scm_hashq_set_x (table, key, val)
-@deffnx {C Function} scm_hashv_set_x (table, key, val)
-@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val)
-Associate @var{val} with @var{key} in the given hash @var{table}. If
-@var{key} is already present then it's associated value is changed.
-If it's not present then a new entry is created.
-@end deffn
-
-@deffn {Scheme Procedure} hash-remove! table key
-@deffnx {Scheme Procedure} hashq-remove! table key
-@deffnx {Scheme Procedure} hashv-remove! table key
-@deffnx {Scheme Procedure} hashx-remove! hash assoc table key
-@deffnx {C Function} scm_hash_remove_x (table, key)
-@deffnx {C Function} scm_hashq_remove_x (table, key)
-@deffnx {C Function} scm_hashv_remove_x (table, key)
-@deffnx {C Function} scm_hashx_remove_x (hash, assoc, table, key)
-Remove any association for @var{key} in the given hash @var{table}.
-If @var{key} is not in @var{table} then nothing is done.
-@end deffn
-
-@deffn {Scheme Procedure} hash key size
-@deffnx {Scheme Procedure} hashq key size
-@deffnx {Scheme Procedure} hashv key size
-@deffnx {C Function} scm_hash (key, size)
-@deffnx {C Function} scm_hashq (key, size)
-@deffnx {C Function} scm_hashv (key, size)
-Return a hash value for @var{key}. This is a number in the range
-@math{0} to @math{@var{size}-1}, which is suitable for use in a hash
-table of the given @var{size}.
-
-Note that @code{hashq} and @code{hashv} may use internal addresses of
-objects, so if an object is garbage collected and re-created it can
-have a different hash value, even when the two are notionally
-@code{eq?}. For instance with symbols,
-
-@example
-(hashq 'something 123) @result{} 19
-(gc)
-(hashq 'something 123) @result{} 62
-@end example
-
-In normal use this is not a problem, since an object entered into a
-hash table won't be garbage collected until removed. It's only if
-hashing calculations are somehow separated from normal references that
-its lifetime needs to be considered.
-@end deffn
-
-@deffn {Scheme Procedure} hash-get-handle table key
-@deffnx {Scheme Procedure} hashq-get-handle table key
-@deffnx {Scheme Procedure} hashv-get-handle table key
-@deffnx {Scheme Procedure} hashx-get-handle hash assoc table key
-@deffnx {C Function} scm_hash_get_handle (table, key)
-@deffnx {C Function} scm_hashq_get_handle (table, key)
-@deffnx {C Function} scm_hashv_get_handle (table, key)
-@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key)
-Return the @code{(@var{key} . @var{value})} pair for @var{key} in the
-given hash @var{table}, or @code{#f} if @var{key} is not in
-@var{table}.
-@end deffn
-
-@deffn {Scheme Procedure} hash-create-handle! table key init
-@deffnx {Scheme Procedure} hashq-create-handle! table key init
-@deffnx {Scheme Procedure} hashv-create-handle! table key init
-@deffnx {Scheme Procedure} hashx-create-handle! hash assoc table key init
-@deffnx {C Function} scm_hash_create_handle_x (table, key, init)
-@deffnx {C Function} scm_hashq_create_handle_x (table, key, init)
-@deffnx {C Function} scm_hashv_create_handle_x (table, key, init)
-@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init)
-Return the @code{(@var{key} . @var{value})} pair for @var{key} in the
-given hash @var{table}. If @var{key} is not in @var{table} then
-create an entry for it with @var{init} as the value, and return that
-pair.
-@end deffn
-
-@deffn {Scheme Procedure} hash-map->list proc table
-@deffnx {Scheme Procedure} hash-for-each proc table
-@deffnx {C Function} scm_hash_map_to_list (proc, table)
-@deffnx {C Function} scm_hash_for_each (proc, table)
-Apply @var{proc} to the entries in the given hash @var{table}. Each
-call is @code{(@var{proc} @var{key} @var{value})}. @code{hash-map->list}
-returns a list of the results from these calls, @code{hash-for-each}
-discards the results and returns an unspecified value.
-
-Calls are made over the table entries in an unspecified order, and for
-@code{hash-map->list} the order of the values in the returned list is
-unspecified. Results will be unpredictable if @var{table} is modified
-while iterating.
-
-For example the following returns a new alist comprising all the
-entries from @code{mytable}, in no particular order.
-
-@example
-(hash-map->list cons mytable)
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} hash-for-each-handle proc table
-@deffnx {C Function} scm_hash_for_each_handle (proc, table)
-Apply @var{proc} to the entries in the given hash @var{table}. Each
-call is @code{(@var{proc} @var{handle})}, where @var{handle} is a
-@code{(@var{key} . @var{value})} pair. Return an unspecified value.
-
-@code{hash-for-each-handle} differs from @code{hash-for-each} only in
-the argument list of @var{proc}.
-@end deffn
-
-@deffn {Scheme Procedure} hash-fold proc init table
-@deffnx {C Function} scm_hash_fold (proc, init, table)
-Accumulate a result by applying @var{proc} to the elements of the
-given hash @var{table}. Each call is @code{(@var{proc} @var{key}
-@var{value} @var{prior-result})}, where @var{key} and @var{value} are
-from the @var{table} and @var{prior-result} is the return from the
-previous @var{proc} call. For the first call, @var{prior-result} is
-the given @var{init} value.
-
-Calls are made over the table entries in an unspecified order.
-Results will be unpredictable if @var{table} is modified while
-@code{hash-fold} is running.
-
-For example, the following returns a count of how many keys in
-@code{mytable} are strings.
-
-@example
-(hash-fold (lambda (key value prior)
- (if (string? key) (1+ prior) prior))
- 0 mytable)
-@end example
-@end deffn
-
-@deffn {Scheme Procedure} hash-count pred table
-@deffnx {C Function} scm_hash_count (pred, table)
-Return the number of elements in the given hash @var{table} that cause
-@code{(@var{pred} @var{key} @var{value})} to return true. To quickly
-determine the total number of elements, use @code{(const #t)} for
-@var{pred}.
-@end deffn
-
-@c Local Variables:
-@c TeX-master: "guile.texi"
-@c End:
diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi
index 4253a206a..2d696ea89 100644
--- a/doc/ref/api-control.texi
+++ b/doc/ref/api-control.texi
@@ -21,6 +21,8 @@ flow of Scheme affects C code.
* Exceptions:: Throwing and catching exceptions.
* Error Reporting:: Procedures for signaling errors.
* Dynamic Wind:: Dealing with non-local entrance/exit.
+* Fluids and Dynamic States:: Dynamic scope building blocks.
+* Parameters:: A dynamic scope facility.
* Handling Errors:: How to handle errors in C code.
* Continuation Barriers:: Protection from non-local control flow.
@end menu
@@ -168,7 +170,7 @@ Each @code{cond}-clause must look like this:
(@var{test} @var{expression} @dots{})
@end lisp
-where @var{test} and @var{expression} are arbitrary expression, or like
+where @var{test} and @var{expression} are arbitrary expressions, or like
this
@lisp
@@ -178,7 +180,7 @@ this
where @var{expression} must evaluate to a procedure.
The @var{test}s of the clauses are evaluated in order and as soon as one
-of them evaluates to a true values, the corresponding @var{expression}s
+of them evaluates to a true value, the corresponding @var{expression}s
are evaluated in order and the last value is returned as the value of
the @code{cond}-expression. For the @code{=>} clause type,
@var{expression} is evaluated and the resulting procedure is applied to
@@ -584,10 +586,8 @@ important efficiency consideration to keep in mind.
One example where this optimization matters is @dfn{escape
continuations}. Escape continuations are delimited continuations whose
only use is to make a non-local exit---i.e., to escape from the current
-continuation. Such continuations are invoked only once, and for this
-reason they are sometimes called @dfn{one-shot continuations}. A common
-use of escape continuations is when throwing an exception
-(@pxref{Exceptions}).
+continuation. A common use of escape continuations is when throwing an
+exception (@pxref{Exceptions}).
The constructs below are syntactic sugar atop prompts to simplify the
use of escape continuations.
@@ -628,6 +628,33 @@ This is equivalent to
@code{(call/ec (lambda (@var{k}) @var{body} @dots{}))}.
@end deffn
+Additionally there is another helper primitive exported by @code{(ice-9
+control)}, so load up that module for @code{suspendable-continuation?}:
+
+@example
+(use-modules (ice-9 control))
+@end example
+
+@deffn {Scheme Procedure} suspendable-continuation? tag
+Return @code{#t} if a call to @code{abort-to-prompt} with the prompt tag
+@var{tag} would produce a delimited continuation that could be resumed
+later.
+
+Almost all continuations have this property. The exception is where
+some code between the @code{call-with-prompt} and the
+@code{abort-to-prompt} recursed through C for some reason, the
+@code{abort-to-prompt} will succeed but any attempt to resume the
+continuation (by calling it) would fail. This is because composing a
+saved continuation with the current continuation involves relocating the
+stack frames that were saved from the old stack onto a (possibly) new
+position on the new stack, and Guile can only do this for stack frames
+that it created for Scheme code, not stack frames created by the C
+compiler. It's a bit gnarly but if you stick with Scheme, you won't
+have any problem.
+
+If no prompt is found with the given tag, this procedure just returns
+@code{#f}.
+@end deffn
@node Shift and Reset
@subsubsection Shift, Reset, and All That
@@ -896,7 +923,7 @@ a new values object, and copies into it the @var{n} values starting from
@var{base}.
Currently this creates a list and passes it to @code{scm_values}, but we
-expect that in the future we will be able to use more a efficient
+expect that in the future we will be able to use a more efficient
representation.
@end deftypefn
@@ -1660,6 +1687,339 @@ context is exited, whether normally or non-locally.
@end deftypefn
+@node Fluids and Dynamic States
+@subsection Fluids and Dynamic States
+
+@cindex fluids
+
+A @emph{fluid} is a variable whose value is associated with the dynamic
+extent of a function call. In the same way that an operating system
+runs a process with a given set of current input and output ports (or
+file descriptors), in Guile you can arrange to call a function while
+binding a fluid to a particular value. That association between fluid
+and value will exist during the dynamic extent of the function call.
+
+Fluids are a therefore a building block for implementing dynamically
+scoped variables. Dynamically scoped variables are useful when you want
+to set a variable to a value during some dynamic extent in the execution
+of your program and have them revert to their original value when the
+control flow is outside of this dynamic extent. See the description of
+@code{with-fluids} below for details. This association between fluids,
+values, and dynamic extents is robust to multiple entries (as when a
+captured continuation is invoked more than once) and early exits (for
+example, when throwing exceptions).
+
+Guile uses fluids to implement parameters (@pxref{Parameters}). Usually
+you just want to use parameters directly. However it can be useful to
+know what a fluid is and how it works, so that's what this section is
+about.
+
+The current set of fluid-value associations can be captured in a
+@emph{dynamic state} object. A dynamic extent is simply that: a
+snapshot of the current fluid-value associations. Guile users can
+capture the current dynamic state with @code{current-dynamic-state} and
+restore it later via @code{with-dynamic-state} or similar procedures.
+This facility is especially useful when implementing lightweight
+thread-like abstractions.
+
+New fluids are created with @code{make-fluid} and @code{fluid?} is
+used for testing whether an object is actually a fluid. The values
+stored in a fluid can be accessed with @code{fluid-ref} and
+@code{fluid-set!}.
+
+@xref{Thread Local Variables}, for further notes on fluids, threads,
+parameters, and dynamic states.
+
+@deffn {Scheme Procedure} make-fluid [dflt]
+@deffnx {C Function} scm_make_fluid ()
+@deffnx {C Function} scm_make_fluid_with_default (dflt)
+Return a newly created fluid, whose initial value is @var{dflt}, or
+@code{#f} if @var{dflt} is not given.
+Fluids are objects that can hold one
+value per dynamic state. That is, modifications to this value are
+only visible to code that executes with the same dynamic state as
+the modifying code. When a new dynamic state is constructed, it
+inherits the values from its parent. Because each thread normally executes
+with its own dynamic state, you can use fluids for thread local storage.
+@end deffn
+
+@deffn {Scheme Procedure} make-unbound-fluid
+@deffnx {C Function} scm_make_unbound_fluid ()
+Return a new fluid that is initially unbound (instead of being
+implicitly bound to some definite value).
+@end deffn
+
+@deffn {Scheme Procedure} fluid? obj
+@deffnx {C Function} scm_fluid_p (obj)
+Return @code{#t} if @var{obj} is a fluid; otherwise, return
+@code{#f}.
+@end deffn
+
+@deffn {Scheme Procedure} fluid-ref fluid
+@deffnx {C Function} scm_fluid_ref (fluid)
+Return the value associated with @var{fluid} in the current
+dynamic root. If @var{fluid} has not been set, then return
+its default value. Calling @code{fluid-ref} on an unbound fluid produces
+a runtime error.
+@end deffn
+
+@deffn {Scheme Procedure} fluid-set! fluid value
+@deffnx {C Function} scm_fluid_set_x (fluid, value)
+Set the value associated with @var{fluid} in the current dynamic root.
+@end deffn
+
+@deffn {Scheme Procedure} fluid-ref* fluid depth
+@deffnx {C Function} scm_fluid_ref_star (fluid, depth)
+Return the @var{depth}th oldest value associated with @var{fluid} in the
+current thread. If @var{depth} equals or exceeds the number of values
+that have been assigned to @var{fluid}, return the default value of the
+fluid. @code{(fluid-ref* f 0)} is equivalent to @code{(fluid-ref f)}.
+
+@code{fluid-ref*} is useful when you want to maintain a stack-like
+structure in a fluid, such as the stack of current exception handlers.
+Using @code{fluid-ref*} instead of an explicit stack allows any partial
+continuation captured by @code{call-with-prompt} to only capture the
+bindings made within the limits of the prompt instead of the entire
+continuation. @xref{Prompts}, for more on delimited continuations.
+@end deffn
+
+@deffn {Scheme Procedure} fluid-unset! fluid
+@deffnx {C Function} scm_fluid_unset_x (fluid)
+Disassociate the given fluid from any value, making it unbound.
+@end deffn
+
+@deffn {Scheme Procedure} fluid-bound? fluid
+@deffnx {C Function} scm_fluid_bound_p (fluid)
+Returns @code{#t} if the given fluid is bound to a value, otherwise
+@code{#f}.
+@end deffn
+
+@code{with-fluids*} temporarily changes the values of one or more fluids,
+so that the given procedure and each procedure called by it access the
+given values. After the procedure returns, the old values are restored.
+
+@deffn {Scheme Procedure} with-fluid* fluid value thunk
+@deffnx {C Function} scm_with_fluid (fluid, value, thunk)
+Set @var{fluid} to @var{value} temporarily, and call @var{thunk}.
+@var{thunk} must be a procedure with no argument.
+@end deffn
+
+@deffn {Scheme Procedure} with-fluids* fluids values thunk
+@deffnx {C Function} scm_with_fluids (fluids, values, thunk)
+Set @var{fluids} to @var{values} temporary, and call @var{thunk}.
+@var{fluids} must be a list of fluids and @var{values} must be the
+same number of their values to be applied. Each substitution is done
+in the order given. @var{thunk} must be a procedure with no argument.
+It is called inside a @code{dynamic-wind} and the fluids are
+set/restored when control enter or leaves the established dynamic
+extent.
+@end deffn
+
+@deffn {Scheme Macro} with-fluids ((fluid value) @dots{}) body1 body2 @dots{}
+Execute body @var{body1} @var{body2} @dots{} while each @var{fluid} is
+set to the corresponding @var{value}. Both @var{fluid} and @var{value}
+are evaluated and @var{fluid} must yield a fluid. The body is executed
+inside a @code{dynamic-wind} and the fluids are set/restored when
+control enter or leaves the established dynamic extent.
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_with_fluids (SCM fluids, SCM vals, SCM (*cproc)(void *), void *data)
+@deftypefnx {C Function} SCM scm_c_with_fluid (SCM fluid, SCM val, SCM (*cproc)(void *), void *data)
+The function @code{scm_c_with_fluids} is like @code{scm_with_fluids}
+except that it takes a C function to call instead of a Scheme thunk.
+
+The function @code{scm_c_with_fluid} is similar but only allows one
+fluid to be set instead of a list.
+@end deftypefn
+
+@deftypefn {C Function} void scm_dynwind_fluid (SCM fluid, SCM val)
+This function must be used inside a pair of calls to
+@code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic
+Wind}). During the dynwind context, the fluid @var{fluid} is set to
+@var{val}.
+
+More precisely, the value of the fluid is swapped with a `backup'
+value whenever the dynwind context is entered or left. The backup
+value is initialized with the @var{val} argument.
+@end deftypefn
+
+@deffn {Scheme Procedure} dynamic-state? obj
+@deffnx {C Function} scm_dynamic_state_p (obj)
+Return @code{#t} if @var{obj} is a dynamic state object;
+return @code{#f} otherwise.
+@end deffn
+
+@deftypefn {C Procedure} int scm_is_dynamic_state (SCM obj)
+Return non-zero if @var{obj} is a dynamic state object;
+return zero otherwise.
+@end deftypefn
+
+@deffn {Scheme Procedure} current-dynamic-state
+@deffnx {C Function} scm_current_dynamic_state ()
+Return a snapshot of the current fluid-value associations as a fresh
+dynamic state object.
+@end deffn
+
+@deffn {Scheme Procedure} set-current-dynamic-state state
+@deffnx {C Function} scm_set_current_dynamic_state (state)
+Restore the saved fluid-value associations from @var{state}, replacing
+the current fluid-value associations. Return the current fluid-value
+associatoins as a dynamic state object, as in
+@code{current-dynamic-state}.
+@end deffn
+
+@deffn {Scheme Procedure} with-dynamic-state state proc
+@deffnx {C Function} scm_with_dynamic_state (state, proc)
+Call @var{proc} while the fluid bindings from @var{state} have been made
+current, saving the current fluid bindings. When control leaves the
+invocation of @var{proc}, restore the saved bindings, saving instead the
+fluid bindings from inside the call. If control later re-enters
+@var{proc}, restore those saved bindings, saving the current bindings,
+and so on.
+@end deffn
+
+@deftypefn {C Procedure} void scm_dynwind_current_dynamic_state (SCM state)
+Set the current dynamic state to @var{state} for the current dynwind
+context. Like @code{with-dynamic-state}, but in terms of Guile's
+``dynwind'' C API.
+@end deftypefn
+
+@deftypefn {C Procedure} {void *} scm_c_with_dynamic_state (SCM state, void *(*func)(void *), void *data)
+Like @code{scm_with_dynamic_state}, but call @var{func} with
+@var{data}.
+@end deftypefn
+
+@node Parameters
+@subsection Parameters
+
+@cindex SRFI-39
+@cindex parameter object
+@tindex Parameter
+
+Parameters are Guile's facility for dynamically bound variables.
+
+On the most basic level, a parameter object is a procedure. Calling it
+with no arguments returns its value. Calling it with one argument sets
+the value.
+
+@example
+(define my-param (make-parameter 123))
+(my-param) @result{} 123
+(my-param 456)
+(my-param) @result{} 456
+@end example
+
+The @code{parameterize} special form establishes new locations for
+parameters, those new locations having effect within the dynamic extent
+of the @code{parameterize} body. Leaving restores the previous
+locations. Re-entering (through a saved continuation) will again use
+the new locations.
+
+@example
+(parameterize ((my-param 789))
+ (my-param)) @result{} 789
+(my-param) @result{} 456
+@end example
+
+Parameters are like dynamically bound variables in other Lisp dialects.
+They allow an application to establish parameter settings (as the name
+suggests) just for the execution of a particular bit of code, restoring
+when done. Examples of such parameters might be case-sensitivity for a
+search, or a prompt for user input.
+
+Global variables are not as good as parameter objects for this sort of
+thing. Changes to them are visible to all threads, but in Guile
+parameter object locations are per-thread, thereby truly limiting the
+effect of @code{parameterize} to just its dynamic execution.
+
+Passing arguments to functions is thread-safe, but that soon becomes
+tedious when there's more than a few or when they need to pass down
+through several layers of calls before reaching the point they should
+affect. Introducing a new setting to existing code is often easier with
+a parameter object than adding arguments.
+
+@deffn {Scheme Procedure} make-parameter init [converter]
+Return a new parameter object, with initial value @var{init}.
+
+If a @var{converter} is given, then a call @code{(@var{converter}
+val)} is made for each value set, its return is the value stored.
+Such a call is made for the @var{init} initial value too.
+
+A @var{converter} allows values to be validated, or put into a
+canonical form. For example,
+
+@example
+(define my-param (make-parameter 123
+ (lambda (val)
+ (if (not (number? val))
+ (error "must be a number"))
+ (inexact->exact val))))
+(my-param 0.75)
+(my-param) @result{} 3/4
+@end example
+@end deffn
+
+@deffn {library syntax} parameterize ((param value) @dots{}) body1 body2 @dots{}
+Establish a new dynamic scope with the given @var{param}s bound to new
+locations and set to the given @var{value}s. @var{body1} @var{body2}
+@dots{} is evaluated in that environment. The value returned is that of
+last body form.
+
+Each @var{param} is an expression which is evaluated to get the
+parameter object. Often this will just be the name of a variable
+holding the object, but it can be anything that evaluates to a
+parameter.
+
+The @var{param} expressions and @var{value} expressions are all
+evaluated before establishing the new dynamic bindings, and they're
+evaluated in an unspecified order.
+
+For example,
+
+@example
+(define prompt (make-parameter "Type something: "))
+(define (get-input)
+ (display (prompt))
+ ...)
+
+(parameterize ((prompt "Type a number: "))
+ (get-input)
+ ...)
+@end example
+@end deffn
+
+Parameter objects are implemented using fluids (@pxref{Fluids and
+Dynamic States}), so each dynamic state has its own parameter
+locations. That includes the separate locations when outside any
+@code{parameterize} form. When a parameter is created it gets a
+separate initial location in each dynamic state, all initialized to the
+given @var{init} value.
+
+New code should probably just use parameters instead of fluids, because
+the interface is better. But for migrating old code or otherwise
+providing interoperability, Guile provides the @code{fluid->parameter}
+procedure:
+
+@deffn {Scheme Procedure} fluid->parameter fluid [conv]
+Make a parameter that wraps a fluid.
+
+The value of the parameter will be the same as the value of the fluid.
+If the parameter is rebound in some dynamic extent, perhaps via
+@code{parameterize}, the new value will be run through the optional
+@var{conv} procedure, as with any parameter. Note that unlike
+@code{make-parameter}, @var{conv} is not applied to the initial value.
+@end deffn
+
+As alluded to above, because each thread usually has a separate dynamic
+state, each thread has its own locations behind parameter objects, and
+changes in one thread are not visible to any other. When a new dynamic
+state or thread is created, the values of parameters in the originating
+context are copied, into new locations.
+
+@cindex SRFI-39
+Guile's parameters conform to SRFI-39 (@pxref{SRFI-39}).
+
+
@node Handling Errors
@subsection How to Handle Errors
@@ -1801,8 +2161,8 @@ In @code{scm_wrong_type_arg_msg}, @var{expected} is a C string
describing the type of argument that was expected.
In @code{scm_misc_error}, @var{message} is the error message string,
-possibly containing @code{simple-format} escapes (@pxref{Writing}), and
-the corresponding arguments in the @var{args} list.
+possibly containing @code{simple-format} escapes (@pxref{Simple
+Output}), and the corresponding arguments in the @var{args} list.
@end deftypefn
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 3f787b1c9..7b10d34f4 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -1,42 +1,16 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000-2004, 2006-2014
+@c Copyright (C) 1996, 1997, 2000-2004, 2006-2016
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
-@node Simple Data Types
-@section Simple Generic Data Types
+@node Data Types
+@section Data Types
-This chapter describes those of Guile's simple data types which are
-primarily used for their role as items of generic data. By
-@dfn{simple} we mean data types that are not primarily used as
-containers to hold other data --- i.e.@: pairs, lists, vectors and so on.
-For the documentation of such @dfn{compound} data types, see
-@ref{Compound Data Types}.
-
-@c One of the great strengths of Scheme is that there is no straightforward
-@c distinction between ``data'' and ``functionality''. For example,
-@c Guile's support for dynamic linking could be described:
-
-@c @itemize @bullet
-@c @item
-@c either in a ``data-centric'' way, as the behaviour and properties of the
-@c ``dynamically linked object'' data type, and the operations that may be
-@c applied to instances of this type
-
-@c @item
-@c or in a ``functionality-centric'' way, as the set of procedures that
-@c constitute Guile's support for dynamic linking, in the context of the
-@c module system.
-@c @end itemize
-
-@c The contents of this chapter are, therefore, a matter of judgment. By
-@c @dfn{generic}, we mean to select those data types whose typical use as
-@c @emph{data} in a wide variety of programming contexts is more important
-@c than their use in the implementation of a particular piece of
-@c @emph{functionality}. The last section of this chapter provides
-@c references for all the data types that are documented not here but in a
-@c ``functionality-centric'' way elsewhere in the manual.
+Guile's data types form a powerful built-in library of representations
+and functionality that you can apply to your problem domain. This
+chapter surveys the data types built-in to Guile, from the simple to the
+complex.
@menu
* Booleans:: True/false values.
@@ -44,10 +18,24 @@ For the documentation of such @dfn{compound} data types, see
* Characters:: Single characters.
* Character Sets:: Sets of characters.
* Strings:: Sequences of characters.
-* Bytevectors:: Sequences of bytes.
* Symbols:: Symbols.
* Keywords:: Self-quoting, customizable display keywords.
-* Other Types:: "Functionality-centric" data types.
+* Pairs:: Scheme's basic building block.
+* Lists:: Special list functions supported by Guile.
+* Vectors:: One-dimensional arrays of Scheme objects.
+* Bit Vectors:: Vectors of bits.
+* Bytevectors:: Sequences of bytes.
+* Arrays:: Multidimensional matrices.
+* VLists:: Vector-like lists.
+* Record Overview:: Walking through the maze of record APIs.
+* SRFI-9 Records:: The standard, recommended record API.
+* Records:: Guile's historical record API.
+* Structures:: Low-level record representation.
+* Dictionary Types:: About dictionary types in general.
+* Association Lists:: List-based dictionaries.
+* VHashes:: VList-based dictionaries.
+* Hash Tables:: Table-based dictionaries.
+* Other Types:: Other sections describe data types too.
@end menu
@@ -434,6 +422,7 @@ function will always succeed and will always return an exact number.
@deftypefnx {C Function} {unsigned long long} scm_to_ulong_long (SCM x)
@deftypefnx {C Function} size_t scm_to_size_t (SCM x)
@deftypefnx {C Function} ssize_t scm_to_ssize_t (SCM x)
+@deftypefnx {C Function} scm_t_uintptr scm_to_uintptr_t (SCM x)
@deftypefnx {C Function} scm_t_ptrdiff scm_to_ptrdiff_t (SCM x)
@deftypefnx {C Function} scm_t_int8 scm_to_int8 (SCM x)
@deftypefnx {C Function} scm_t_uint8 scm_to_uint8 (SCM x)
@@ -470,6 +459,7 @@ the corresponding types are.
@deftypefnx {C Function} SCM scm_from_ulong_long (unsigned long long x)
@deftypefnx {C Function} SCM scm_from_size_t (size_t x)
@deftypefnx {C Function} SCM scm_from_ssize_t (ssize_t x)
+@deftypefnx {C Function} SCM scm_from_uintptr_t (uintptr_t x)
@deftypefnx {C Function} SCM scm_from_ptrdiff_t (scm_t_ptrdiff x)
@deftypefnx {C Function} SCM scm_from_int8 (scm_t_int8 x)
@deftypefnx {C Function} SCM scm_from_uint8 (scm_t_uint8 x)
@@ -1712,7 +1702,7 @@ starts from 0 for the least significant bit.
@deffn {Scheme Procedure} ash n count
@deffnx {C Function} scm_ash (n, count)
-Return @math{floor(n * 2^count)}.
+Return @math{floor(n * 2^{count})}.
@var{n} and @var{count} must be exact integers.
With @var{n} viewed as an infinite-precision twos-complement
@@ -2014,7 +2004,7 @@ names, described in the table below.
@multitable {@code{#\backspace}} {Preferred}
@item Character Name @tab Codepoint
@item @code{#\nul} @tab U+0000
-@item @code{#\alarm} @tab u+0007
+@item @code{#\alarm} @tab U+0007
@item @code{#\backspace} @tab U+0008
@item @code{#\tab} @tab U+0009
@item @code{#\linefeed} @tab U+000A
@@ -4579,470 +4569,6 @@ or @code{#f} if they are stored in an 8-bit buffer
@end deffn
-@node Bytevectors
-@subsection Bytevectors
-
-@cindex bytevector
-@cindex R6RS
-
-A @dfn{bytevector} is a raw bit string. The @code{(rnrs bytevectors)}
-module provides the programming interface specified by the
-@uref{http://www.r6rs.org/, Revised^6 Report on the Algorithmic Language
-Scheme (R6RS)}. It contains procedures to manipulate bytevectors and
-interpret their contents in a number of ways: bytevector contents can be
-accessed as signed or unsigned integer of various sizes and endianness,
-as IEEE-754 floating point numbers, or as strings. It is a useful tool
-to encode and decode binary data.
-
-The R6RS (Section 4.3.4) specifies an external representation for
-bytevectors, whereby the octets (integers in the range 0--255) contained
-in the bytevector are represented as a list prefixed by @code{#vu8}:
-
-@lisp
-#vu8(1 53 204)
-@end lisp
-
-denotes a 3-byte bytevector containing the octets 1, 53, and 204. Like
-string literals, booleans, etc., bytevectors are ``self-quoting'', i.e.,
-they do not need to be quoted:
-
-@lisp
-#vu8(1 53 204)
-@result{} #vu8(1 53 204)
-@end lisp
-
-Bytevectors can be used with the binary input/output primitives of the
-R6RS (@pxref{R6RS I/O Ports}).
-
-@menu
-* Bytevector Endianness:: Dealing with byte order.
-* Bytevector Manipulation:: Creating, copying, manipulating bytevectors.
-* Bytevectors as Integers:: Interpreting bytes as integers.
-* Bytevectors and Integer Lists:: Converting to/from an integer list.
-* Bytevectors as Floats:: Interpreting bytes as real numbers.
-* Bytevectors as Strings:: Interpreting bytes as Unicode strings.
-* Bytevectors as Arrays:: Guile extension to the bytevector API.
-* Bytevectors as Uniform Vectors:: Bytevectors and SRFI-4.
-@end menu
-
-@node Bytevector Endianness
-@subsubsection Endianness
-
-@cindex endianness
-@cindex byte order
-@cindex word order
-
-Some of the following procedures take an @var{endianness} parameter.
-The @dfn{endianness} is defined as the order of bytes in multi-byte
-numbers: numbers encoded in @dfn{big endian} have their most
-significant bytes written first, whereas numbers encoded in
-@dfn{little endian} have their least significant bytes
-first@footnote{Big-endian and little-endian are the most common
-``endiannesses'', but others do exist. For instance, the GNU MP
-library allows @dfn{word order} to be specified independently of
-@dfn{byte order} (@pxref{Integer Import and Export,,, gmp, The GNU
-Multiple Precision Arithmetic Library Manual}).}.
-
-Little-endian is the native endianness of the IA32 architecture and
-its derivatives, while big-endian is native to SPARC and PowerPC,
-among others. The @code{native-endianness} procedure returns the
-native endianness of the machine it runs on.
-
-@deffn {Scheme Procedure} native-endianness
-@deffnx {C Function} scm_native_endianness ()
-Return a value denoting the native endianness of the host machine.
-@end deffn
-
-@deffn {Scheme Macro} endianness symbol
-Return an object denoting the endianness specified by @var{symbol}. If
-@var{symbol} is neither @code{big} nor @code{little} then an error is
-raised at expand-time.
-@end deffn
-
-@defvr {C Variable} scm_endianness_big
-@defvrx {C Variable} scm_endianness_little
-The objects denoting big- and little-endianness, respectively.
-@end defvr
-
-
-@node Bytevector Manipulation
-@subsubsection Manipulating Bytevectors
-
-Bytevectors can be created, copied, and analyzed with the following
-procedures and C functions.
-
-@deffn {Scheme Procedure} make-bytevector len [fill]
-@deffnx {C Function} scm_make_bytevector (len, fill)
-@deffnx {C Function} scm_c_make_bytevector (size_t len)
-Return a new bytevector of @var{len} bytes. Optionally, if @var{fill}
-is given, fill it with @var{fill}; @var{fill} must be in the range
-[-128,255].
-@end deffn
-
-@deffn {Scheme Procedure} bytevector? obj
-@deffnx {C Function} scm_bytevector_p (obj)
-Return true if @var{obj} is a bytevector.
-@end deffn
-
-@deftypefn {C Function} int scm_is_bytevector (SCM obj)
-Equivalent to @code{scm_is_true (scm_bytevector_p (obj))}.
-@end deftypefn
-
-@deffn {Scheme Procedure} bytevector-length bv
-@deffnx {C Function} scm_bytevector_length (bv)
-Return the length in bytes of bytevector @var{bv}.
-@end deffn
-
-@deftypefn {C Function} size_t scm_c_bytevector_length (SCM bv)
-Likewise, return the length in bytes of bytevector @var{bv}.
-@end deftypefn
-
-@deffn {Scheme Procedure} bytevector=? bv1 bv2
-@deffnx {C Function} scm_bytevector_eq_p (bv1, bv2)
-Return is @var{bv1} equals to @var{bv2}---i.e., if they have the same
-length and contents.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-fill! bv fill
-@deffnx {C Function} scm_bytevector_fill_x (bv, fill)
-Fill bytevector @var{bv} with @var{fill}, a byte.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-copy! source source-start target target-start len
-@deffnx {C Function} scm_bytevector_copy_x (source, source_start, target, target_start, len)
-Copy @var{len} bytes from @var{source} into @var{target}, starting
-reading from @var{source-start} (a positive index within @var{source})
-and start writing at @var{target-start}. It is permitted for the
-@var{source} and @var{target} regions to overlap.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-copy bv
-@deffnx {C Function} scm_bytevector_copy (bv)
-Return a newly allocated copy of @var{bv}.
-@end deffn
-
-@deftypefn {C Function} scm_t_uint8 scm_c_bytevector_ref (SCM bv, size_t index)
-Return the byte at @var{index} in bytevector @var{bv}.
-@end deftypefn
-
-@deftypefn {C Function} void scm_c_bytevector_set_x (SCM bv, size_t index, scm_t_uint8 value)
-Set the byte at @var{index} in @var{bv} to @var{value}.
-@end deftypefn
-
-Low-level C macros are available. They do not perform any
-type-checking; as such they should be used with care.
-
-@deftypefn {C Macro} size_t SCM_BYTEVECTOR_LENGTH (bv)
-Return the length in bytes of bytevector @var{bv}.
-@end deftypefn
-
-@deftypefn {C Macro} {signed char *} SCM_BYTEVECTOR_CONTENTS (bv)
-Return a pointer to the contents of bytevector @var{bv}.
-@end deftypefn
-
-
-@node Bytevectors as Integers
-@subsubsection Interpreting Bytevector Contents as Integers
-
-The contents of a bytevector can be interpreted as a sequence of
-integers of any given size, sign, and endianness.
-
-@lisp
-(let ((bv (make-bytevector 4)))
- (bytevector-u8-set! bv 0 #x12)
- (bytevector-u8-set! bv 1 #x34)
- (bytevector-u8-set! bv 2 #x56)
- (bytevector-u8-set! bv 3 #x78)
-
- (map (lambda (number)
- (number->string number 16))
- (list (bytevector-u8-ref bv 0)
- (bytevector-u16-ref bv 0 (endianness big))
- (bytevector-u32-ref bv 0 (endianness little)))))
-
-@result{} ("12" "1234" "78563412")
-@end lisp
-
-The most generic procedures to interpret bytevector contents as integers
-are described below.
-
-@deffn {Scheme Procedure} bytevector-uint-ref bv index endianness size
-@deffnx {C Function} scm_bytevector_uint_ref (bv, index, endianness, size)
-Return the @var{size}-byte long unsigned integer at index @var{index} in
-@var{bv}, decoded according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-sint-ref bv index endianness size
-@deffnx {C Function} scm_bytevector_sint_ref (bv, index, endianness, size)
-Return the @var{size}-byte long signed integer at index @var{index} in
-@var{bv}, decoded according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-uint-set! bv index value endianness size
-@deffnx {C Function} scm_bytevector_uint_set_x (bv, index, value, endianness, size)
-Set the @var{size}-byte long unsigned integer at @var{index} to
-@var{value}, encoded according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-sint-set! bv index value endianness size
-@deffnx {C Function} scm_bytevector_sint_set_x (bv, index, value, endianness, size)
-Set the @var{size}-byte long signed integer at @var{index} to
-@var{value}, encoded according to @var{endianness}.
-@end deffn
-
-The following procedures are similar to the ones above, but specialized
-to a given integer size:
-
-@deffn {Scheme Procedure} bytevector-u8-ref bv index
-@deffnx {Scheme Procedure} bytevector-s8-ref bv index
-@deffnx {Scheme Procedure} bytevector-u16-ref bv index endianness
-@deffnx {Scheme Procedure} bytevector-s16-ref bv index endianness
-@deffnx {Scheme Procedure} bytevector-u32-ref bv index endianness
-@deffnx {Scheme Procedure} bytevector-s32-ref bv index endianness
-@deffnx {Scheme Procedure} bytevector-u64-ref bv index endianness
-@deffnx {Scheme Procedure} bytevector-s64-ref bv index endianness
-@deffnx {C Function} scm_bytevector_u8_ref (bv, index)
-@deffnx {C Function} scm_bytevector_s8_ref (bv, index)
-@deffnx {C Function} scm_bytevector_u16_ref (bv, index, endianness)
-@deffnx {C Function} scm_bytevector_s16_ref (bv, index, endianness)
-@deffnx {C Function} scm_bytevector_u32_ref (bv, index, endianness)
-@deffnx {C Function} scm_bytevector_s32_ref (bv, index, endianness)
-@deffnx {C Function} scm_bytevector_u64_ref (bv, index, endianness)
-@deffnx {C Function} scm_bytevector_s64_ref (bv, index, endianness)
-Return the unsigned @var{n}-bit (signed) integer (where @var{n} is 8,
-16, 32 or 64) from @var{bv} at @var{index}, decoded according to
-@var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-u8-set! bv index value
-@deffnx {Scheme Procedure} bytevector-s8-set! bv index value
-@deffnx {Scheme Procedure} bytevector-u16-set! bv index value endianness
-@deffnx {Scheme Procedure} bytevector-s16-set! bv index value endianness
-@deffnx {Scheme Procedure} bytevector-u32-set! bv index value endianness
-@deffnx {Scheme Procedure} bytevector-s32-set! bv index value endianness
-@deffnx {Scheme Procedure} bytevector-u64-set! bv index value endianness
-@deffnx {Scheme Procedure} bytevector-s64-set! bv index value endianness
-@deffnx {C Function} scm_bytevector_u8_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_s8_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_u16_set_x (bv, index, value, endianness)
-@deffnx {C Function} scm_bytevector_s16_set_x (bv, index, value, endianness)
-@deffnx {C Function} scm_bytevector_u32_set_x (bv, index, value, endianness)
-@deffnx {C Function} scm_bytevector_s32_set_x (bv, index, value, endianness)
-@deffnx {C Function} scm_bytevector_u64_set_x (bv, index, value, endianness)
-@deffnx {C Function} scm_bytevector_s64_set_x (bv, index, value, endianness)
-Store @var{value} as an @var{n}-bit (signed) integer (where @var{n} is
-8, 16, 32 or 64) in @var{bv} at @var{index}, encoded according to
-@var{endianness}.
-@end deffn
-
-Finally, a variant specialized for the host's endianness is available
-for each of these functions (with the exception of the @code{u8}
-accessors, for obvious reasons):
-
-@deffn {Scheme Procedure} bytevector-u16-native-ref bv index
-@deffnx {Scheme Procedure} bytevector-s16-native-ref bv index
-@deffnx {Scheme Procedure} bytevector-u32-native-ref bv index
-@deffnx {Scheme Procedure} bytevector-s32-native-ref bv index
-@deffnx {Scheme Procedure} bytevector-u64-native-ref bv index
-@deffnx {Scheme Procedure} bytevector-s64-native-ref bv index
-@deffnx {C Function} scm_bytevector_u16_native_ref (bv, index)
-@deffnx {C Function} scm_bytevector_s16_native_ref (bv, index)
-@deffnx {C Function} scm_bytevector_u32_native_ref (bv, index)
-@deffnx {C Function} scm_bytevector_s32_native_ref (bv, index)
-@deffnx {C Function} scm_bytevector_u64_native_ref (bv, index)
-@deffnx {C Function} scm_bytevector_s64_native_ref (bv, index)
-Return the unsigned @var{n}-bit (signed) integer (where @var{n} is 8,
-16, 32 or 64) from @var{bv} at @var{index}, decoded according to the
-host's native endianness.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-u16-native-set! bv index value
-@deffnx {Scheme Procedure} bytevector-s16-native-set! bv index value
-@deffnx {Scheme Procedure} bytevector-u32-native-set! bv index value
-@deffnx {Scheme Procedure} bytevector-s32-native-set! bv index value
-@deffnx {Scheme Procedure} bytevector-u64-native-set! bv index value
-@deffnx {Scheme Procedure} bytevector-s64-native-set! bv index value
-@deffnx {C Function} scm_bytevector_u16_native_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_s16_native_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_u32_native_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_s32_native_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_u64_native_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_s64_native_set_x (bv, index, value)
-Store @var{value} as an @var{n}-bit (signed) integer (where @var{n} is
-8, 16, 32 or 64) in @var{bv} at @var{index}, encoded according to the
-host's native endianness.
-@end deffn
-
-
-@node Bytevectors and Integer Lists
-@subsubsection Converting Bytevectors to/from Integer Lists
-
-Bytevector contents can readily be converted to/from lists of signed or
-unsigned integers:
-
-@lisp
-(bytevector->sint-list (u8-list->bytevector (make-list 4 255))
- (endianness little) 2)
-@result{} (-1 -1)
-@end lisp
-
-@deffn {Scheme Procedure} bytevector->u8-list bv
-@deffnx {C Function} scm_bytevector_to_u8_list (bv)
-Return a newly allocated list of unsigned 8-bit integers from the
-contents of @var{bv}.
-@end deffn
-
-@deffn {Scheme Procedure} u8-list->bytevector lst
-@deffnx {C Function} scm_u8_list_to_bytevector (lst)
-Return a newly allocated bytevector consisting of the unsigned 8-bit
-integers listed in @var{lst}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector->uint-list bv endianness size
-@deffnx {C Function} scm_bytevector_to_uint_list (bv, endianness, size)
-Return a list of unsigned integers of @var{size} bytes representing the
-contents of @var{bv}, decoded according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector->sint-list bv endianness size
-@deffnx {C Function} scm_bytevector_to_sint_list (bv, endianness, size)
-Return a list of signed integers of @var{size} bytes representing the
-contents of @var{bv}, decoded according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} uint-list->bytevector lst endianness size
-@deffnx {C Function} scm_uint_list_to_bytevector (lst, endianness, size)
-Return a new bytevector containing the unsigned integers listed in
-@var{lst} and encoded on @var{size} bytes according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} sint-list->bytevector lst endianness size
-@deffnx {C Function} scm_sint_list_to_bytevector (lst, endianness, size)
-Return a new bytevector containing the signed integers listed in
-@var{lst} and encoded on @var{size} bytes according to @var{endianness}.
-@end deffn
-
-@node Bytevectors as Floats
-@subsubsection Interpreting Bytevector Contents as Floating Point Numbers
-
-@cindex IEEE-754 floating point numbers
-
-Bytevector contents can also be accessed as IEEE-754 single- or
-double-precision floating point numbers (respectively 32 and 64-bit
-long) using the procedures described here.
-
-@deffn {Scheme Procedure} bytevector-ieee-single-ref bv index endianness
-@deffnx {Scheme Procedure} bytevector-ieee-double-ref bv index endianness
-@deffnx {C Function} scm_bytevector_ieee_single_ref (bv, index, endianness)
-@deffnx {C Function} scm_bytevector_ieee_double_ref (bv, index, endianness)
-Return the IEEE-754 single-precision floating point number from @var{bv}
-at @var{index} according to @var{endianness}.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-ieee-single-set! bv index value endianness
-@deffnx {Scheme Procedure} bytevector-ieee-double-set! bv index value endianness
-@deffnx {C Function} scm_bytevector_ieee_single_set_x (bv, index, value, endianness)
-@deffnx {C Function} scm_bytevector_ieee_double_set_x (bv, index, value, endianness)
-Store real number @var{value} in @var{bv} at @var{index} according to
-@var{endianness}.
-@end deffn
-
-Specialized procedures are also available:
-
-@deffn {Scheme Procedure} bytevector-ieee-single-native-ref bv index
-@deffnx {Scheme Procedure} bytevector-ieee-double-native-ref bv index
-@deffnx {C Function} scm_bytevector_ieee_single_native_ref (bv, index)
-@deffnx {C Function} scm_bytevector_ieee_double_native_ref (bv, index)
-Return the IEEE-754 single-precision floating point number from @var{bv}
-at @var{index} according to the host's native endianness.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector-ieee-single-native-set! bv index value
-@deffnx {Scheme Procedure} bytevector-ieee-double-native-set! bv index value
-@deffnx {C Function} scm_bytevector_ieee_single_native_set_x (bv, index, value)
-@deffnx {C Function} scm_bytevector_ieee_double_native_set_x (bv, index, value)
-Store real number @var{value} in @var{bv} at @var{index} according to
-the host's native endianness.
-@end deffn
-
-
-@node Bytevectors as Strings
-@subsubsection Interpreting Bytevector Contents as Unicode Strings
-
-@cindex Unicode string encoding
-
-Bytevector contents can also be interpreted as Unicode strings encoded
-in one of the most commonly available encoding formats.
-@xref{Representing Strings as Bytes}, for a more generic interface.
-
-@lisp
-(utf8->string (u8-list->bytevector '(99 97 102 101)))
-@result{} "cafe"
-
-(string->utf8 "caf@'e") ;; SMALL LATIN LETTER E WITH ACUTE ACCENT
-@result{} #vu8(99 97 102 195 169)
-@end lisp
-
-@deffn {Scheme Procedure} string->utf8 str
-@deffnx {Scheme Procedure} string->utf16 str [endianness]
-@deffnx {Scheme Procedure} string->utf32 str [endianness]
-@deffnx {C Function} scm_string_to_utf8 (str)
-@deffnx {C Function} scm_string_to_utf16 (str, endianness)
-@deffnx {C Function} scm_string_to_utf32 (str, endianness)
-Return a newly allocated bytevector that contains the UTF-8, UTF-16, or
-UTF-32 (aka. UCS-4) encoding of @var{str}. For UTF-16 and UTF-32,
-@var{endianness} should be the symbol @code{big} or @code{little}; when omitted,
-it defaults to big endian.
-@end deffn
-
-@deffn {Scheme Procedure} utf8->string utf
-@deffnx {Scheme Procedure} utf16->string utf [endianness]
-@deffnx {Scheme Procedure} utf32->string utf [endianness]
-@deffnx {C Function} scm_utf8_to_string (utf)
-@deffnx {C Function} scm_utf16_to_string (utf, endianness)
-@deffnx {C Function} scm_utf32_to_string (utf, endianness)
-Return a newly allocated string that contains from the UTF-8-, UTF-16-,
-or UTF-32-decoded contents of bytevector @var{utf}. For UTF-16 and UTF-32,
-@var{endianness} should be the symbol @code{big} or @code{little}; when omitted,
-it defaults to big endian.
-@end deffn
-
-@node Bytevectors as Arrays
-@subsubsection Accessing Bytevectors with the Array API
-
-As an extension to the R6RS, Guile allows bytevectors to be manipulated
-with the @dfn{array} procedures (@pxref{Arrays}). When using these
-APIs, bytes are accessed one at a time as 8-bit unsigned integers:
-
-@example
-(define bv #vu8(0 1 2 3))
-
-(array? bv)
-@result{} #t
-
-(array-rank bv)
-@result{} 1
-
-(array-ref bv 2)
-@result{} 2
-
-;; Note the different argument order on array-set!.
-(array-set! bv 77 2)
-(array-ref bv 2)
-@result{} 77
-
-(array-type bv)
-@result{} vu8
-@end example
-
-
-@node Bytevectors as Uniform Vectors
-@subsubsection Accessing Bytevectors with the SRFI-4 API
-
-Bytevectors may also be accessed with the SRFI-4 API. @xref{SRFI-4 and
-Bytevectors}, for more information.
-
-
@node Symbols
@subsection Symbols
@tpindex Symbols
@@ -5135,7 +4661,7 @@ mapping consistently:
@lisp
;; 1=red, 2=green, 3=purple
-(if (eq? (colour-of car) 1)
+(if (eq? (colour-of vehicle) 1)
...)
@end lisp
@@ -5148,7 +4674,7 @@ defining constants:
(define green 2)
(define purple 3)
-(if (eq? (colour-of car) red)
+(if (eq? (colour-of vehicle) red)
...)
@end lisp
@@ -5157,7 +4683,7 @@ But the simplest and clearest approach is not to use numbers at all, but
symbols whose names specify the colours that they refer to:
@lisp
-(if (eq? (colour-of car) 'red)
+(if (eq? (colour-of vehicle) 'red)
...)
@end lisp
@@ -5179,15 +4705,15 @@ Then a car's combined property set could be naturally represented and
manipulated as a list of symbols:
@lisp
-(properties-of car1)
+(properties-of vehicle1)
@result{}
(red manual unleaded power-steering)
-(if (memq 'power-steering (properties-of car1))
- (display "Unfit people can drive this car.\n")
- (display "You'll need strong arms to drive this car!\n"))
+(if (memq 'power-steering (properties-of vehicle1))
+ (display "Unfit people can drive this vehicle.\n")
+ (display "You'll need strong arms to drive this vehicle!\n"))
@print{}
-Unfit people can drive this car.
+Unfit people can drive this vehicle.
@end lisp
Remember, the fundamental property of symbols that we are relying on
@@ -5882,13 +5408,13 @@ objects print using this syntax as well, so values containing keyword
objects can be read back into Guile. When used in an expression,
keywords are self-quoting objects.
-If the @code{keyword} read option is set to @code{'prefix}, Guile also
+If the @code{keywords} read option is set to @code{'prefix}, Guile also
recognizes the alternative read syntax @code{:NAME}. Otherwise, tokens
of the form @code{:NAME} are read as symbols, as required by R5RS.
@cindex SRFI-88 keyword syntax
-If the @code{keyword} read option is set to @code{'postfix}, Guile
+If the @code{keywords} read option is set to @code{'postfix}, Guile
recognizes the SRFI-88 read syntax @code{NAME:} (@pxref{SRFI-88}).
Otherwise, tokens of this form are read as symbols.
@@ -6037,26 +5563,4670 @@ void my_init ()
@end deftypefn
-@node Other Types
-@subsection ``Functionality-Centric'' Data Types
+@node Pairs
+@subsection Pairs
+@tpindex Pairs
-Procedures and macros are documented in their own sections: see
-@ref{Procedures} and @ref{Macros}.
+Pairs are used to combine two Scheme objects into one compound object.
+Hence the name: A pair stores a pair of objects.
+
+The data type @dfn{pair} is extremely important in Scheme, just like in
+any other Lisp dialect. The reason is that pairs are not only used to
+make two values available as one object, but that pairs are used for
+constructing lists of values. Because lists are so important in Scheme,
+they are described in a section of their own (@pxref{Lists}).
+
+Pairs can literally get entered in source code or at the REPL, in the
+so-called @dfn{dotted list} syntax. This syntax consists of an opening
+parentheses, the first element of the pair, a dot, the second element
+and a closing parentheses. The following example shows how a pair
+consisting of the two numbers 1 and 2, and a pair containing the symbols
+@code{foo} and @code{bar} can be entered. It is very important to write
+the whitespace before and after the dot, because otherwise the Scheme
+parser would not be able to figure out where to split the tokens.
+
+@lisp
+(1 . 2)
+(foo . bar)
+@end lisp
+
+But beware, if you want to try out these examples, you have to
+@dfn{quote} the expressions. More information about quotation is
+available in the section @ref{Expression Syntax}. The correct way
+to try these examples is as follows.
+
+@lisp
+'(1 . 2)
+@result{}
+(1 . 2)
+'(foo . bar)
+@result{}
+(foo . bar)
+@end lisp
+
+A new pair is made by calling the procedure @code{cons} with two
+arguments. Then the argument values are stored into a newly allocated
+pair, and the pair is returned. The name @code{cons} stands for
+"construct". Use the procedure @code{pair?} to test whether a
+given Scheme object is a pair or not.
+
+@rnindex cons
+@deffn {Scheme Procedure} cons x y
+@deffnx {C Function} scm_cons (x, y)
+Return a newly allocated pair whose car is @var{x} and whose
+cdr is @var{y}. The pair is guaranteed to be different (in the
+sense of @code{eq?}) from every previously existing object.
+@end deffn
+
+@rnindex pair?
+@deffn {Scheme Procedure} pair? x
+@deffnx {C Function} scm_pair_p (x)
+Return @code{#t} if @var{x} is a pair; otherwise return
+@code{#f}.
+@end deffn
+
+@deftypefn {C Function} int scm_is_pair (SCM x)
+Return 1 when @var{x} is a pair; otherwise return 0.
+@end deftypefn
+
+The two parts of a pair are traditionally called @dfn{car} and
+@dfn{cdr}. They can be retrieved with procedures of the same name
+(@code{car} and @code{cdr}), and can be modified with the procedures
+@code{set-car!} and @code{set-cdr!}.
+
+Since a very common operation in Scheme programs is to access the car of
+a car of a pair, or the car of the cdr of a pair, etc., the procedures
+called @code{caar}, @code{cadr} and so on are also predefined. However,
+using these procedures is often detrimental to readability, and
+error-prone. Thus, accessing the contents of a list is usually better
+achieved using pattern matching techniques (@pxref{Pattern Matching}).
+
+@rnindex car
+@rnindex cdr
+@deffn {Scheme Procedure} car pair
+@deffnx {Scheme Procedure} cdr pair
+@deffnx {C Function} scm_car (pair)
+@deffnx {C Function} scm_cdr (pair)
+Return the car or the cdr of @var{pair}, respectively.
+@end deffn
+
+@deftypefn {C Macro} SCM SCM_CAR (SCM pair)
+@deftypefnx {C Macro} SCM SCM_CDR (SCM pair)
+These two macros are the fastest way to access the car or cdr of a
+pair; they can be thought of as compiling into a single memory
+reference.
+
+These macros do no checking at all. The argument @var{pair} must be a
+valid pair.
+@end deftypefn
+
+@deffn {Scheme Procedure} cddr pair
+@deffnx {Scheme Procedure} cdar pair
+@deffnx {Scheme Procedure} cadr pair
+@deffnx {Scheme Procedure} caar pair
+@deffnx {Scheme Procedure} cdddr pair
+@deffnx {Scheme Procedure} cddar pair
+@deffnx {Scheme Procedure} cdadr pair
+@deffnx {Scheme Procedure} cdaar pair
+@deffnx {Scheme Procedure} caddr pair
+@deffnx {Scheme Procedure} cadar pair
+@deffnx {Scheme Procedure} caadr pair
+@deffnx {Scheme Procedure} caaar pair
+@deffnx {Scheme Procedure} cddddr pair
+@deffnx {Scheme Procedure} cdddar pair
+@deffnx {Scheme Procedure} cddadr pair
+@deffnx {Scheme Procedure} cddaar pair
+@deffnx {Scheme Procedure} cdaddr pair
+@deffnx {Scheme Procedure} cdadar pair
+@deffnx {Scheme Procedure} cdaadr pair
+@deffnx {Scheme Procedure} cdaaar pair
+@deffnx {Scheme Procedure} cadddr pair
+@deffnx {Scheme Procedure} caddar pair
+@deffnx {Scheme Procedure} cadadr pair
+@deffnx {Scheme Procedure} cadaar pair
+@deffnx {Scheme Procedure} caaddr pair
+@deffnx {Scheme Procedure} caadar pair
+@deffnx {Scheme Procedure} caaadr pair
+@deffnx {Scheme Procedure} caaaar pair
+@deffnx {C Function} scm_cddr (pair)
+@deffnx {C Function} scm_cdar (pair)
+@deffnx {C Function} scm_cadr (pair)
+@deffnx {C Function} scm_caar (pair)
+@deffnx {C Function} scm_cdddr (pair)
+@deffnx {C Function} scm_cddar (pair)
+@deffnx {C Function} scm_cdadr (pair)
+@deffnx {C Function} scm_cdaar (pair)
+@deffnx {C Function} scm_caddr (pair)
+@deffnx {C Function} scm_cadar (pair)
+@deffnx {C Function} scm_caadr (pair)
+@deffnx {C Function} scm_caaar (pair)
+@deffnx {C Function} scm_cddddr (pair)
+@deffnx {C Function} scm_cdddar (pair)
+@deffnx {C Function} scm_cddadr (pair)
+@deffnx {C Function} scm_cddaar (pair)
+@deffnx {C Function} scm_cdaddr (pair)
+@deffnx {C Function} scm_cdadar (pair)
+@deffnx {C Function} scm_cdaadr (pair)
+@deffnx {C Function} scm_cdaaar (pair)
+@deffnx {C Function} scm_cadddr (pair)
+@deffnx {C Function} scm_caddar (pair)
+@deffnx {C Function} scm_cadadr (pair)
+@deffnx {C Function} scm_cadaar (pair)
+@deffnx {C Function} scm_caaddr (pair)
+@deffnx {C Function} scm_caadar (pair)
+@deffnx {C Function} scm_caaadr (pair)
+@deffnx {C Function} scm_caaaar (pair)
+These procedures are compositions of @code{car} and @code{cdr}, where
+for example @code{caddr} could be defined by
+
+@lisp
+(define caddr (lambda (x) (car (cdr (cdr x)))))
+@end lisp
+
+@code{cadr}, @code{caddr} and @code{cadddr} pick out the second, third
+or fourth elements of a list, respectively. SRFI-1 provides the same
+under the names @code{second}, @code{third} and @code{fourth}
+(@pxref{SRFI-1 Selectors}).
+@end deffn
+
+@rnindex set-car!
+@deffn {Scheme Procedure} set-car! pair value
+@deffnx {C Function} scm_set_car_x (pair, value)
+Stores @var{value} in the car field of @var{pair}. The value returned
+by @code{set-car!} is unspecified.
+@end deffn
+
+@rnindex set-cdr!
+@deffn {Scheme Procedure} set-cdr! pair value
+@deffnx {C Function} scm_set_cdr_x (pair, value)
+Stores @var{value} in the cdr field of @var{pair}. The value returned
+by @code{set-cdr!} is unspecified.
+@end deffn
+
+
+@node Lists
+@subsection Lists
+@tpindex Lists
+
+A very important data type in Scheme---as well as in all other Lisp
+dialects---is the data type @dfn{list}.@footnote{Strictly speaking,
+Scheme does not have a real datatype @dfn{list}. Lists are made up of
+@dfn{chained pairs}, and only exist by definition---a list is a chain
+of pairs which looks like a list.}
+
+This is the short definition of what a list is:
+
+@itemize @bullet
+@item
+Either the empty list @code{()},
+
+@item
+or a pair which has a list in its cdr.
+@end itemize
+
+@c FIXME::martin: Describe the pair chaining in more detail.
+
+@c FIXME::martin: What is a proper, what an improper list?
+@c What is a circular list?
+
+@c FIXME::martin: Maybe steal some graphics from the Elisp reference
+@c manual?
+
+@menu
+* List Syntax:: Writing literal lists.
+* List Predicates:: Testing lists.
+* List Constructors:: Creating new lists.
+* List Selection:: Selecting from lists, getting their length.
+* Append/Reverse:: Appending and reversing lists.
+* List Modification:: Modifying existing lists.
+* List Searching:: Searching for list elements
+* List Mapping:: Applying procedures to lists.
+@end menu
+
+@node List Syntax
+@subsubsection List Read Syntax
+
+The syntax for lists is an opening parentheses, then all the elements of
+the list (separated by whitespace) and finally a closing
+parentheses.@footnote{Note that there is no separation character between
+the list elements, like a comma or a semicolon.}.
+
+@lisp
+(1 2 3) ; @r{a list of the numbers 1, 2 and 3}
+("foo" bar 3.1415) ; @r{a string, a symbol and a real number}
+() ; @r{the empty list}
+@end lisp
+
+The last example needs a bit more explanation. A list with no elements,
+called the @dfn{empty list}, is special in some ways. It is used for
+terminating lists by storing it into the cdr of the last pair that makes
+up a list. An example will clear that up:
+
+@lisp
+(car '(1))
+@result{}
+1
+(cdr '(1))
+@result{}
+()
+@end lisp
+
+This example also shows that lists have to be quoted when written
+(@pxref{Expression Syntax}), because they would otherwise be
+mistakingly taken as procedure applications (@pxref{Simple
+Invocation}).
+
+
+@node List Predicates
+@subsubsection List Predicates
+
+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
+whether their input is valid, or they could do different things
+depending on the datatype of their arguments.
+
+@rnindex list?
+@deffn {Scheme Procedure} list? x
+@deffnx {C Function} scm_list_p (x)
+Return @code{#t} if @var{x} is a proper list, else @code{#f}.
+@end deffn
+
+The predicate @code{null?} is often used in list-processing code to
+tell whether a given list has run out of elements. That is, a loop
+somehow deals with the elements of a list until the list satisfies
+@code{null?}. Then, the algorithm terminates.
+
+@rnindex null?
+@deffn {Scheme Procedure} null? x
+@deffnx {C Function} scm_null_p (x)
+Return @code{#t} if @var{x} is the empty list, else @code{#f}.
+@end deffn
+
+@deftypefn {C Function} int scm_is_null (SCM x)
+Return 1 when @var{x} is the empty list; otherwise return 0.
+@end deftypefn
+
+
+@node List Constructors
+@subsubsection List Constructors
+
+This section describes the procedures for constructing new lists.
+@code{list} simply returns a list where the elements are the arguments,
+@code{cons*} is similar, but the last argument is stored in the cdr of
+the last pair of the list.
+
+@c C Function scm_list(rest) used to be documented here, but it's a
+@c no-op since it does nothing but return the list the caller must
+@c have already created.
+@c
+@deffn {Scheme Procedure} list elem @dots{}
+@deffnx {C Function} scm_list_1 (elem1)
+@deffnx {C Function} scm_list_2 (elem1, elem2)
+@deffnx {C Function} scm_list_3 (elem1, elem2, elem3)
+@deffnx {C Function} scm_list_4 (elem1, elem2, elem3, elem4)
+@deffnx {C Function} scm_list_5 (elem1, elem2, elem3, elem4, elem5)
+@deffnx {C Function} scm_list_n (elem1, @dots{}, elemN, @nicode{SCM_UNDEFINED})
+@rnindex list
+Return a new list containing elements @var{elem} @enddots{}.
+
+@code{scm_list_n} takes a variable number of arguments, terminated by
+the special @code{SCM_UNDEFINED}. That final @code{SCM_UNDEFINED} is
+not included in the list. None of @var{elem} @dots{} can
+themselves be @code{SCM_UNDEFINED}, or @code{scm_list_n} will
+terminate at that point.
+@end deffn
+
+@c C Function scm_cons_star(arg1,rest) used to be documented here,
+@c but it's not really a useful interface, since it expects the
+@c caller to have already consed up all but the first argument
+@c already.
+@c
+@deffn {Scheme Procedure} cons* arg1 arg2 @dots{}
+Like @code{list}, but the last arg provides the tail of the
+constructed list, returning @code{(cons @var{arg1} (cons
+@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one
+argument. If given one argument, that argument is returned as
+result. This function is called @code{list*} in some other
+Schemes and in Common LISP.
+@end deffn
+
+@deffn {Scheme Procedure} list-copy lst
+@deffnx {C Function} scm_list_copy (lst)
+Return a (newly-created) copy of @var{lst}.
+@end deffn
+
+@deffn {Scheme Procedure} make-list n [init]
+Create a list containing of @var{n} elements, where each element is
+initialized to @var{init}. @var{init} defaults to the empty list
+@code{()} if not given.
+@end deffn
+
+Note that @code{list-copy} only makes a copy of the pairs which make up
+the spine of the lists. The list elements are not copied, which means
+that modifying the elements of the new list also modifies the elements
+of the old list. On the other hand, applying procedures like
+@code{set-cdr!} or @code{delv!} to the new list will not alter the old
+list. If you also need to copy the list elements (making a deep copy),
+use the procedure @code{copy-tree} (@pxref{Copying}).
+
+@node List Selection
+@subsubsection List Selection
+
+These procedures are used to get some information about a list, or to
+retrieve one or more elements of a list.
+
+@rnindex length
+@deffn {Scheme Procedure} length lst
+@deffnx {C Function} scm_length (lst)
+Return the number of elements in list @var{lst}.
+@end deffn
+
+@deffn {Scheme Procedure} last-pair lst
+@deffnx {C Function} scm_last_pair (lst)
+Return the last pair in @var{lst}, signalling an error if
+@var{lst} is circular.
+@end deffn
+
+@rnindex list-ref
+@deffn {Scheme Procedure} list-ref list k
+@deffnx {C Function} scm_list_ref (list, k)
+Return the @var{k}th element from @var{list}.
+@end deffn
+
+@rnindex list-tail
+@deffn {Scheme Procedure} list-tail lst k
+@deffnx {Scheme Procedure} list-cdr-ref lst k
+@deffnx {C Function} scm_list_tail (lst, k)
+Return the "tail" of @var{lst} beginning with its @var{k}th element.
+The first element of the list is considered to be element 0.
+
+@code{list-tail} and @code{list-cdr-ref} are identical. It may help to
+think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list,
+or returning the results of cdring @var{k} times down @var{lst}.
+@end deffn
+
+@deffn {Scheme Procedure} list-head lst k
+@deffnx {C Function} scm_list_head (lst, k)
+Copy the first @var{k} elements from @var{lst} into a new list, and
+return it.
+@end deffn
+
+@node Append/Reverse
+@subsubsection Append and Reverse
+
+@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!}
+return lists with the same elements as their arguments, but in reverse
+order. The procedure variants with an @code{!} directly modify the
+pairs which form the list, whereas the other procedures create new
+pairs. This is why you should be careful when using the side-effecting
+variants.
+
+@rnindex append
+@deffn {Scheme Procedure} append lst @dots{} obj
+@deffnx {Scheme Procedure} append
+@deffnx {Scheme Procedure} append! lst @dots{} obj
+@deffnx {Scheme Procedure} append!
+@deffnx {C Function} scm_append (lstlst)
+@deffnx {C Function} scm_append_x (lstlst)
+Return a list comprising all the elements of lists @var{lst} @dots{}
+@var{obj}. If called with no arguments, return the empty list.
+
+@lisp
+(append '(x) '(y)) @result{} (x y)
+(append '(a) '(b c d)) @result{} (a b c d)
+(append '(a (b)) '((c))) @result{} (a (b) (c))
+@end lisp
+
+The last argument @var{obj} may actually be any object; an improper
+list results if the last argument is not a proper list.
+
+@lisp
+(append '(a b) '(c . d)) @result{} (a b c . d)
+(append '() 'a) @result{} a
+@end lisp
+
+@code{append} doesn't modify the given lists, but the return may share
+structure with the final @var{obj}. @code{append!} is permitted, but
+not required, to modify the given lists to form its return.
+
+For @code{scm_append} and @code{scm_append_x}, @var{lstlst} is a list
+of the list operands @var{lst} @dots{} @var{obj}. That @var{lstlst}
+itself is not modified or used in the return.
+@end deffn
+
+@rnindex reverse
+@deffn {Scheme Procedure} reverse lst
+@deffnx {Scheme Procedure} reverse! lst [newtail]
+@deffnx {C Function} scm_reverse (lst)
+@deffnx {C Function} scm_reverse_x (lst, newtail)
+Return a list comprising the elements of @var{lst}, in reverse order.
+
+@code{reverse} constructs a new list. @code{reverse!} is permitted, but
+not required, to modify @var{lst} in constructing its return.
+
+For @code{reverse!}, the optional @var{newtail} is appended to the
+result. @var{newtail} isn't reversed, it simply becomes the list
+tail. For @code{scm_reverse_x}, the @var{newtail} parameter is
+mandatory, but can be @code{SCM_EOL} if no further tail is required.
+@end deffn
+
+@node List Modification
+@subsubsection List Modification
+
+The following procedures modify an existing list, either by changing
+elements of the list, or by changing the list structure itself.
+
+@deffn {Scheme Procedure} list-set! list k val
+@deffnx {C Function} scm_list_set_x (list, k, val)
+Set the @var{k}th element of @var{list} to @var{val}.
+@end deffn
+
+@deffn {Scheme Procedure} list-cdr-set! list k val
+@deffnx {C Function} scm_list_cdr_set_x (list, k, val)
+Set the @var{k}th cdr of @var{list} to @var{val}.
+@end deffn
+
+@deffn {Scheme Procedure} delq item lst
+@deffnx {C Function} scm_delq (item, lst)
+Return a newly-created copy of @var{lst} with elements
+@code{eq?} to @var{item} removed. This procedure mirrors
+@code{memq}: @code{delq} compares elements of @var{lst} against
+@var{item} with @code{eq?}.
+@end deffn
+
+@deffn {Scheme Procedure} delv item lst
+@deffnx {C Function} scm_delv (item, lst)
+Return a newly-created copy of @var{lst} with elements
+@code{eqv?} to @var{item} removed. This procedure mirrors
+@code{memv}: @code{delv} compares elements of @var{lst} against
+@var{item} with @code{eqv?}.
+@end deffn
+
+@deffn {Scheme Procedure} delete item lst
+@deffnx {C Function} scm_delete (item, lst)
+Return a newly-created copy of @var{lst} with elements
+@code{equal?} to @var{item} removed. This procedure mirrors
+@code{member}: @code{delete} compares elements of @var{lst}
+against @var{item} with @code{equal?}.
+
+See also SRFI-1 which has an extended @code{delete} (@ref{SRFI-1
+Deleting}), and also an @code{lset-difference} which can delete
+multiple @var{item}s in one call (@ref{SRFI-1 Set Operations}).
+@end deffn
+
+@deffn {Scheme Procedure} delq! item lst
+@deffnx {Scheme Procedure} delv! item lst
+@deffnx {Scheme Procedure} delete! item lst
+@deffnx {C Function} scm_delq_x (item, lst)
+@deffnx {C Function} scm_delv_x (item, lst)
+@deffnx {C Function} scm_delete_x (item, lst)
+These procedures are destructive versions of @code{delq}, @code{delv}
+and @code{delete}: they modify the pointers in the existing @var{lst}
+rather than creating a new list. Caveat evaluator: Like other
+destructive list functions, these functions cannot modify the binding of
+@var{lst}, and so cannot be used to delete the first element of
+@var{lst} destructively.
+@end deffn
+
+@deffn {Scheme Procedure} delq1! item lst
+@deffnx {C Function} scm_delq1_x (item, lst)
+Like @code{delq!}, but only deletes the first occurrence of
+@var{item} from @var{lst}. Tests for equality using
+@code{eq?}. See also @code{delv1!} and @code{delete1!}.
+@end deffn
+
+@deffn {Scheme Procedure} delv1! item lst
+@deffnx {C Function} scm_delv1_x (item, lst)
+Like @code{delv!}, but only deletes the first occurrence of
+@var{item} from @var{lst}. Tests for equality using
+@code{eqv?}. See also @code{delq1!} and @code{delete1!}.
+@end deffn
+
+@deffn {Scheme Procedure} delete1! item lst
+@deffnx {C Function} scm_delete1_x (item, lst)
+Like @code{delete!}, but only deletes the first occurrence of
+@var{item} from @var{lst}. Tests for equality using
+@code{equal?}. See also @code{delq1!} and @code{delv1!}.
+@end deffn
+
+@deffn {Scheme Procedure} filter pred lst
+@deffnx {Scheme Procedure} filter! pred lst
+Return a list containing all elements from @var{lst} which satisfy the
+predicate @var{pred}. The elements in the result list have the same
+order as in @var{lst}. The order in which @var{pred} is applied to
+the list elements is not specified.
+
+@code{filter} does not change @var{lst}, but the result may share a
+tail with it. @code{filter!} may modify @var{lst} to construct its
+return.
+@end deffn
+
+@node List Searching
+@subsubsection List Searching
+
+The following procedures search lists for particular elements. They use
+different comparison predicates for comparing list elements with the
+object to be searched. When they fail, they return @code{#f}, otherwise
+they return the sublist whose car is equal to the search object, where
+equality depends on the equality predicate used.
+
+@rnindex memq
+@deffn {Scheme Procedure} memq x lst
+@deffnx {C Function} scm_memq (x, lst)
+Return the first sublist of @var{lst} whose car is @code{eq?}
+to @var{x} where the sublists of @var{lst} are the non-empty
+lists returned by @code{(list-tail @var{lst} @var{k})} for
+@var{k} less than the length of @var{lst}. If @var{x} does not
+occur in @var{lst}, then @code{#f} (not the empty list) is
+returned.
+@end deffn
+
+@rnindex memv
+@deffn {Scheme Procedure} memv x lst
+@deffnx {C Function} scm_memv (x, lst)
+Return the first sublist of @var{lst} whose car is @code{eqv?}
+to @var{x} where the sublists of @var{lst} are the non-empty
+lists returned by @code{(list-tail @var{lst} @var{k})} for
+@var{k} less than the length of @var{lst}. If @var{x} does not
+occur in @var{lst}, then @code{#f} (not the empty list) is
+returned.
+@end deffn
+
+@rnindex member
+@deffn {Scheme Procedure} member x lst
+@deffnx {C Function} scm_member (x, lst)
+Return the first sublist of @var{lst} whose car is
+@code{equal?} to @var{x} where the sublists of @var{lst} are
+the non-empty lists returned by @code{(list-tail @var{lst}
+@var{k})} for @var{k} less than the length of @var{lst}. If
+@var{x} does not occur in @var{lst}, then @code{#f} (not the
+empty list) is returned.
+
+See also SRFI-1 which has an extended @code{member} function
+(@ref{SRFI-1 Searching}).
+@end deffn
+
+
+@node List Mapping
+@subsubsection List Mapping
+
+List processing is very convenient in Scheme because the process of
+iterating over the elements of a list can be highly abstracted. The
+procedures in this section are the most basic iterating procedures for
+lists. They take a procedure and one or more lists as arguments, and
+apply the procedure to each element of the list. They differ in their
+return value.
+
+@rnindex map
+@c begin (texi-doc-string "guile" "map")
+@deffn {Scheme Procedure} map proc arg1 arg2 @dots{}
+@deffnx {Scheme Procedure} map-in-order proc arg1 arg2 @dots{}
+@deffnx {C Function} scm_map (proc, arg1, args)
+Apply @var{proc} to each element of the list @var{arg1} (if only two
+arguments are given), or to the corresponding elements of the argument
+lists (if more than two arguments are given). The result(s) of the
+procedure applications are saved and returned in a list. For
+@code{map}, the order of procedure applications is not specified,
+@code{map-in-order} applies the procedure from left to right to the list
+elements.
+@end deffn
+
+@rnindex for-each
+@c begin (texi-doc-string "guile" "for-each")
+@deffn {Scheme Procedure} for-each proc arg1 arg2 @dots{}
+Like @code{map}, but the procedure is always applied from left to right,
+and the result(s) of the procedure applications are thrown away. The
+return value is not specified.
+@end deffn
+
+See also SRFI-1 which extends these functions to take lists of unequal
+lengths (@ref{SRFI-1 Fold and Map}).
+
+@node Vectors
+@subsection Vectors
+@tpindex Vectors
+
+Vectors are sequences of Scheme objects. Unlike lists, the length of a
+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
+given its @dfn{position} (synonymous with @dfn{index}), a zero-origin number,
+is constant, whereas lists have an access time linear to the position of the
+accessed element in the list.
+
+Vectors can contain any kind of Scheme object; it is even possible to
+have different types of objects in the same vector. For vectors
+containing vectors, you may wish to use arrays, instead. Note, too,
+that vectors are the special case of one dimensional non-uniform arrays
+and that most array procedures operate happily on vectors
+(@pxref{Arrays}).
+
+Also see @ref{SRFI-43}, for a comprehensive vector library.
+
+@menu
+* Vector Syntax:: Read syntax for vectors.
+* Vector Creation:: Dynamic vector creation and validation.
+* Vector Accessors:: Accessing and modifying vector contents.
+* Vector Accessing from C:: Ways to work with vectors from C.
+* Uniform Numeric Vectors:: Vectors of unboxed numeric values.
+@end menu
+
+
+@node Vector Syntax
+@subsubsection Read Syntax for Vectors
+
+Vectors can literally be entered in source code, just like strings,
+characters or some of the other data types. The read syntax for vectors
+is as follows: A sharp sign (@code{#}), followed by an opening
+parentheses, all elements of the vector in their respective read syntax,
+and finally a closing parentheses. Like strings, vectors do not have to
+be quoted.
+
+The following are examples of the read syntax for vectors; where the
+first vector only contains numbers and the second three different object
+types: a string, a symbol and a number in hexadecimal notation.
+
+@lisp
+#(1 2 3)
+#("Hello" foo #xdeadbeef)
+@end lisp
+
+@node Vector Creation
+@subsubsection Dynamic Vector Creation and Validation
+
+Instead of creating a vector implicitly by using the read syntax just
+described, you can create a vector dynamically by calling one of the
+@code{vector} and @code{list->vector} primitives with the list of Scheme
+values that you want to place into a vector. The size of the vector
+thus created is determined implicitly by the number of arguments given.
+
+@rnindex vector
+@rnindex list->vector
+@deffn {Scheme Procedure} vector arg @dots{}
+@deffnx {Scheme Procedure} list->vector l
+@deffnx {C Function} scm_vector (l)
+Return a newly allocated vector composed of the
+given arguments. Analogous to @code{list}.
+
+@lisp
+(vector 'a 'b 'c) @result{} #(a b c)
+@end lisp
+@end deffn
+
+The inverse operation is @code{vector->list}:
+
+@rnindex vector->list
+@deffn {Scheme Procedure} vector->list v
+@deffnx {C Function} scm_vector_to_list (v)
+Return a newly allocated list composed of the elements of @var{v}.
+
+@lisp
+(vector->list #(dah dah didah)) @result{} (dah dah didah)
+(list->vector '(dididit dah)) @result{} #(dididit dah)
+@end lisp
+@end deffn
+
+To allocate a vector with an explicitly specified size, use
+@code{make-vector}. With this primitive you can also specify an initial
+value for the vector elements (the same value for all elements, that
+is):
+
+@rnindex make-vector
+@deffn {Scheme Procedure} make-vector len [fill]
+@deffnx {C Function} scm_make_vector (len, fill)
+Return a newly allocated vector of @var{len} elements. If a
+second argument is given, then each position is initialized to
+@var{fill}. Otherwise the initial contents of each position is
+unspecified.
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_make_vector (size_t k, SCM fill)
+Like @code{scm_make_vector}, but the length is given as a @code{size_t}.
+@end deftypefn
+
+To check whether an arbitrary Scheme value @emph{is} a vector, use the
+@code{vector?} primitive:
+
+@rnindex vector?
+@deffn {Scheme Procedure} vector? obj
+@deffnx {C Function} scm_vector_p (obj)
+Return @code{#t} if @var{obj} is a vector, otherwise return
+@code{#f}.
+@end deffn
+
+@deftypefn {C Function} int scm_is_vector (SCM obj)
+Return non-zero when @var{obj} is a vector, otherwise return
+@code{zero}.
+@end deftypefn
+
+@node Vector Accessors
+@subsubsection Accessing and Modifying Vector Contents
+
+@code{vector-length} and @code{vector-ref} return information about a
+given vector, respectively its size and the elements that are contained
+in the vector.
+
+@rnindex vector-length
+@deffn {Scheme Procedure} vector-length vector
+@deffnx {C Function} scm_vector_length (vector)
+Return the number of elements in @var{vector} as an exact integer.
+@end deffn
+
+@deftypefn {C Function} size_t scm_c_vector_length (SCM vec)
+Return the number of elements in @var{vec} as a @code{size_t}.
+@end deftypefn
+
+@rnindex vector-ref
+@deffn {Scheme Procedure} vector-ref vec k
+@deffnx {C Function} scm_vector_ref (vec, k)
+Return the contents of position @var{k} of @var{vec}.
+@var{k} must be a valid index of @var{vec}.
+@lisp
+(vector-ref #(1 1 2 3 5 8 13 21) 5) @result{} 8
+(vector-ref #(1 1 2 3 5 8 13 21)
+ (let ((i (round (* 2 (acos -1)))))
+ (if (inexact? i)
+ (inexact->exact i)
+ i))) @result{} 13
+@end lisp
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_vector_ref (SCM vec, size_t k)
+Return the contents of position @var{k} (a @code{size_t}) of
+@var{vec}.
+@end deftypefn
+
+A vector created by one of the dynamic vector constructor procedures
+(@pxref{Vector Creation}) can be modified using the following
+procedures.
+
+@emph{NOTE:} According to R5RS, it is an error to use any of these
+procedures on a literally read vector, because such vectors should be
+considered as constants. Currently, however, Guile does not detect this
+error.
+
+@rnindex vector-set!
+@deffn {Scheme Procedure} vector-set! vec k obj
+@deffnx {C Function} scm_vector_set_x (vec, k, obj)
+Store @var{obj} in position @var{k} of @var{vec}.
+@var{k} must be a valid index of @var{vec}.
+The value returned by @samp{vector-set!} is unspecified.
+@lisp
+(let ((vec (vector 0 '(2 2 2 2) "Anna")))
+ (vector-set! vec 1 '("Sue" "Sue"))
+ vec) @result{} #(0 ("Sue" "Sue") "Anna")
+@end lisp
+@end deffn
+
+@deftypefn {C Function} void scm_c_vector_set_x (SCM vec, size_t k, SCM obj)
+Store @var{obj} in position @var{k} (a @code{size_t}) of @var{vec}.
+@end deftypefn
+
+@rnindex vector-fill!
+@deffn {Scheme Procedure} vector-fill! vec fill
+@deffnx {C Function} scm_vector_fill_x (vec, fill)
+Store @var{fill} in every position of @var{vec}. The value
+returned by @code{vector-fill!} is unspecified.
+@end deffn
+
+@deffn {Scheme Procedure} vector-copy vec
+@deffnx {C Function} scm_vector_copy (vec)
+Return a copy of @var{vec}.
+@end deffn
+
+@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2
+@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2)
+Copy elements from @var{vec1}, positions @var{start1} to @var{end1},
+to @var{vec2} starting at position @var{start2}. @var{start1} and
+@var{start2} are inclusive indices; @var{end1} is exclusive.
+
+@code{vector-move-left!} copies elements in leftmost order.
+Therefore, in the case where @var{vec1} and @var{vec2} refer to the
+same vector, @code{vector-move-left!} is usually appropriate when
+@var{start1} is greater than @var{start2}.
+@end deffn
+
+@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2
+@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2)
+Copy elements from @var{vec1}, positions @var{start1} to @var{end1},
+to @var{vec2} starting at position @var{start2}. @var{start1} and
+@var{start2} are inclusive indices; @var{end1} is exclusive.
+
+@code{vector-move-right!} copies elements in rightmost order.
+Therefore, in the case where @var{vec1} and @var{vec2} refer to the
+same vector, @code{vector-move-right!} is usually appropriate when
+@var{start1} is less than @var{start2}.
+@end deffn
+
+@node Vector Accessing from C
+@subsubsection Vector Accessing from C
+
+A vector can be read and modified from C with the functions
+@code{scm_c_vector_ref} and @code{scm_c_vector_set_x}, for example. In
+addition to these functions, there are two more ways to access vectors
+from C that might be more efficient in certain situations: you can
+restrict yourself to @dfn{simple vectors} and then use the very fast
+@emph{simple vector macros}; or you can use the very general framework
+for accessing all kinds of arrays (@pxref{Accessing Arrays from C}),
+which is more verbose, but can deal efficiently with all kinds of
+vectors (and arrays). For vectors, you can use the
+@code{scm_vector_elements} and @code{scm_vector_writable_elements}
+functions as shortcuts.
+
+@deftypefn {C Function} int scm_is_simple_vector (SCM obj)
+Return non-zero if @var{obj} is a simple vector, else return zero. A
+simple vector is a vector that can be used with the @code{SCM_SIMPLE_*}
+macros below.
+
+The following functions are guaranteed to return simple vectors:
+@code{scm_make_vector}, @code{scm_c_make_vector}, @code{scm_vector},
+@code{scm_list_to_vector}.
+@end deftypefn
+
+@deftypefn {C Macro} size_t SCM_SIMPLE_VECTOR_LENGTH (SCM vec)
+Evaluates to the length of the simple vector @var{vec}. No type
+checking is done.
+@end deftypefn
+
+@deftypefn {C Macro} SCM SCM_SIMPLE_VECTOR_REF (SCM vec, size_t idx)
+Evaluates to the element at position @var{idx} in the simple vector
+@var{vec}. No type or range checking is done.
+@end deftypefn
+
+@deftypefn {C Macro} void SCM_SIMPLE_VECTOR_SET (SCM vec, size_t idx, SCM val)
+Sets the element at position @var{idx} in the simple vector
+@var{vec} to @var{val}. No type or range checking is done.
+@end deftypefn
+
+@deftypefn {C Function} {const SCM *} scm_vector_elements (SCM vec, scm_t_array_handle *handle, size_t *lenp, ssize_t *incp)
+Acquire a handle for the vector @var{vec} and return a pointer to the
+elements of it. This pointer can only be used to read the elements of
+@var{vec}. When @var{vec} is not a vector, an error is signaled. The
+handle must eventually be released with
+@code{scm_array_handle_release}.
+
+The variables pointed to by @var{lenp} and @var{incp} are filled with
+the number of elements of the vector and the increment (number of
+elements) between successive elements, respectively. Successive
+elements of @var{vec} need not be contiguous in their underlying
+``root vector'' returned here; hence the increment is not necessarily
+equal to 1 and may well be negative too (@pxref{Shared Arrays}).
+
+The following example shows the typical way to use this function. It
+creates a list of all elements of @var{vec} (in reverse order).
+
+@example
+scm_t_array_handle handle;
+size_t i, len;
+ssize_t inc;
+const SCM *elt;
+SCM list;
+
+elt = scm_vector_elements (vec, &handle, &len, &inc);
+list = SCM_EOL;
+for (i = 0; i < len; i++, elt += inc)
+ list = scm_cons (*elt, list);
+scm_array_handle_release (&handle);
+@end example
+
+@end deftypefn
+
+@deftypefn {C Function} {SCM *} scm_vector_writable_elements (SCM vec, scm_t_array_handle *handle, size_t *lenp, ssize_t *incp)
+Like @code{scm_vector_elements} but the pointer can be used to modify
+the vector.
+
+The following example shows the typical way to use this function. It
+fills a vector with @code{#t}.
+
+@example
+scm_t_array_handle handle;
+size_t i, len;
+ssize_t inc;
+SCM *elt;
+
+elt = scm_vector_writable_elements (vec, &handle, &len, &inc);
+for (i = 0; i < len; i++, elt += inc)
+ *elt = SCM_BOOL_T;
+scm_array_handle_release (&handle);
+@end example
+
+@end deftypefn
+
+@node Uniform Numeric Vectors
+@subsubsection Uniform Numeric Vectors
+
+A uniform numeric vector is a vector whose elements are all of a single
+numeric type. Guile offers uniform numeric vectors for signed and
+unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers, two sizes of
+floating point values, and complex floating-point numbers of these two
+sizes. @xref{SRFI-4}, for more information.
+
+For many purposes, bytevectors work just as well as uniform vectors, and have
+the advantage that they integrate well with binary input and output.
+@xref{Bytevectors}, for more information on bytevectors.
+
+@node Bit Vectors
+@subsection Bit Vectors
+
+@noindent
+Bit vectors are zero-origin, one-dimensional arrays of booleans. They
+are displayed as a sequence of @code{0}s and @code{1}s prefixed by
+@code{#*}, e.g.,
+
+@example
+(make-bitvector 8 #f) @result{}
+#*00000000
+@end example
+
+Bit vectors are the special case of one dimensional bit arrays, and can
+thus be used with the array procedures, @xref{Arrays}.
+
+@deffn {Scheme Procedure} bitvector? obj
+@deffnx {C Function} scm_bitvector_p (obj)
+Return @code{#t} when @var{obj} is a bitvector, else
+return @code{#f}.
+@end deffn
+
+@deftypefn {C Function} int scm_is_bitvector (SCM obj)
+Return @code{1} when @var{obj} is a bitvector, else return @code{0}.
+@end deftypefn
+
+@deffn {Scheme Procedure} make-bitvector len [fill]
+@deffnx {C Function} scm_make_bitvector (len, fill)
+Create a new bitvector of length @var{len} and
+optionally initialize all elements to @var{fill}.
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_make_bitvector (size_t len, SCM fill)
+Like @code{scm_make_bitvector}, but the length is given as a
+@code{size_t}.
+@end deftypefn
+
+@deffn {Scheme Procedure} bitvector bit @dots{}
+@deffnx {C Function} scm_bitvector (bits)
+Create a new bitvector with the arguments as elements.
+@end deffn
+
+@deffn {Scheme Procedure} bitvector-length vec
+@deffnx {C Function} scm_bitvector_length (vec)
+Return the length of the bitvector @var{vec}.
+@end deffn
+
+@deftypefn {C Function} size_t scm_c_bitvector_length (SCM vec)
+Like @code{scm_bitvector_length}, but the length is returned as a
+@code{size_t}.
+@end deftypefn
+
+@deffn {Scheme Procedure} bitvector-ref vec idx
+@deffnx {C Function} scm_bitvector_ref (vec, idx)
+Return the element at index @var{idx} of the bitvector
+@var{vec}.
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_bitvector_ref (SCM vec, size_t idx)
+Return the element at index @var{idx} of the bitvector
+@var{vec}.
+@end deftypefn
+
+@deffn {Scheme Procedure} bitvector-set! vec idx val
+@deffnx {C Function} scm_bitvector_set_x (vec, idx, val)
+Set the element at index @var{idx} of the bitvector
+@var{vec} when @var{val} is true, else clear it.
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_bitvector_set_x (SCM vec, size_t idx, SCM val)
+Set the element at index @var{idx} of the bitvector
+@var{vec} when @var{val} is true, else clear it.
+@end deftypefn
+
+@deffn {Scheme Procedure} bitvector-fill! vec val
+@deffnx {C Function} scm_bitvector_fill_x (vec, val)
+Set all elements of the bitvector
+@var{vec} when @var{val} is true, else clear them.
+@end deffn
+
+@deffn {Scheme Procedure} list->bitvector list
+@deffnx {C Function} scm_list_to_bitvector (list)
+Return a new bitvector initialized with the elements
+of @var{list}.
+@end deffn
+
+@deffn {Scheme Procedure} bitvector->list vec
+@deffnx {C Function} scm_bitvector_to_list (vec)
+Return a new list initialized with the elements
+of the bitvector @var{vec}.
+@end deffn
+
+@deffn {Scheme Procedure} bit-count bool bitvector
+@deffnx {C Function} scm_bit_count (bool, bitvector)
+Return a count of how many entries in @var{bitvector} are equal to
+@var{bool}. For example,
+
+@example
+(bit-count #f #*000111000) @result{} 6
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} bit-position bool bitvector start
+@deffnx {C Function} scm_bit_position (bool, bitvector, start)
+Return the index of the first occurrence of @var{bool} in
+@var{bitvector}, starting from @var{start}. If there is no @var{bool}
+entry between @var{start} and the end of @var{bitvector}, then return
+@code{#f}. For example,
+
+@example
+(bit-position #t #*000101 0) @result{} 3
+(bit-position #f #*0001111 3) @result{} #f
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} bit-invert! bitvector
+@deffnx {C Function} scm_bit_invert_x (bitvector)
+Modify @var{bitvector} by replacing each element with its negation.
+@end deffn
+
+@deffn {Scheme Procedure} bit-set*! bitvector uvec bool
+@deffnx {C Function} scm_bit_set_star_x (bitvector, uvec, bool)
+Set entries of @var{bitvector} to @var{bool}, with @var{uvec}
+selecting the entries to change. The return value is unspecified.
+
+If @var{uvec} is a bit vector, then those entries where it has
+@code{#t} are the ones in @var{bitvector} which are set to @var{bool}.
+@var{uvec} and @var{bitvector} must be the same length. When
+@var{bool} is @code{#t} it's like @var{uvec} is OR'ed into
+@var{bitvector}. Or when @var{bool} is @code{#f} it can be seen as an
+ANDNOT.
+
+@example
+(define bv #*01000010)
+(bit-set*! bv #*10010001 #t)
+bv
+@result{} #*11010011
+@end example
+
+If @var{uvec} is a uniform vector of unsigned long integers, then
+they're indexes into @var{bitvector} which are set to @var{bool}.
+
+@example
+(define bv #*01000010)
+(bit-set*! bv #u(5 2 7) #t)
+bv
+@result{} #*01100111
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} bit-count* bitvector uvec bool
+@deffnx {C Function} scm_bit_count_star (bitvector, uvec, bool)
+Return a count of how many entries in @var{bitvector} are equal to
+@var{bool}, with @var{uvec} selecting the entries to consider.
+
+@var{uvec} is interpreted in the same way as for @code{bit-set*!}
+above. Namely, if @var{uvec} is a bit vector then entries which have
+@code{#t} there are considered in @var{bitvector}. Or if @var{uvec}
+is a uniform vector of unsigned long integers then it's the indexes in
+@var{bitvector} to consider.
+
+For example,
+
+@example
+(bit-count* #*01110111 #*11001101 #t) @result{} 3
+(bit-count* #*01110111 #u32(7 0 4) #f) @result{} 2
+@end example
+@end deffn
+
+@deftypefn {C Function} {const scm_t_uint32 *} scm_bitvector_elements (SCM vec, scm_t_array_handle *handle, size_t *offp, size_t *lenp, ssize_t *incp)
+Like @code{scm_vector_elements} (@pxref{Vector Accessing from C}), but
+for bitvectors. The variable pointed to by @var{offp} is set to the
+value returned by @code{scm_array_handle_bit_elements_offset}. See
+@code{scm_array_handle_bit_elements} for how to use the returned
+pointer and the offset.
+@end deftypefn
+
+@deftypefn {C Function} {scm_t_uint32 *} scm_bitvector_writable_elements (SCM vec, scm_t_array_handle *handle, size_t *offp, size_t *lenp, ssize_t *incp)
+Like @code{scm_bitvector_elements}, but the pointer is good for reading
+and writing.
+@end deftypefn
+
+@node Bytevectors
+@subsection Bytevectors
+
+@cindex bytevector
+@cindex R6RS
+
+A @dfn{bytevector} is a raw bit string. The @code{(rnrs bytevectors)}
+module provides the programming interface specified by the
+@uref{http://www.r6rs.org/, Revised^6 Report on the Algorithmic Language
+Scheme (R6RS)}. It contains procedures to manipulate bytevectors and
+interpret their contents in a number of ways: bytevector contents can be
+accessed as signed or unsigned integer of various sizes and endianness,
+as IEEE-754 floating point numbers, or as strings. It is a useful tool
+to encode and decode binary data.
+
+The R6RS (Section 4.3.4) specifies an external representation for
+bytevectors, whereby the octets (integers in the range 0--255) contained
+in the bytevector are represented as a list prefixed by @code{#vu8}:
+
+@lisp
+#vu8(1 53 204)
+@end lisp
+
+denotes a 3-byte bytevector containing the octets 1, 53, and 204. Like
+string literals, booleans, etc., bytevectors are ``self-quoting'', i.e.,
+they do not need to be quoted:
+
+@lisp
+#vu8(1 53 204)
+@result{} #vu8(1 53 204)
+@end lisp
+
+Bytevectors can be used with the binary input/output primitives
+(@pxref{Binary I/O}).
+
+@menu
+* Bytevector Endianness:: Dealing with byte order.
+* Bytevector Manipulation:: Creating, copying, manipulating bytevectors.
+* Bytevectors as Integers:: Interpreting bytes as integers.
+* Bytevectors and Integer Lists:: Converting to/from an integer list.
+* Bytevectors as Floats:: Interpreting bytes as real numbers.
+* Bytevectors as Strings:: Interpreting bytes as Unicode strings.
+* Bytevectors as Arrays:: Guile extension to the bytevector API.
+* Bytevectors as Uniform Vectors:: Bytevectors and SRFI-4.
+@end menu
+
+@node Bytevector Endianness
+@subsubsection Endianness
+
+@cindex endianness
+@cindex byte order
+@cindex word order
+
+Some of the following procedures take an @var{endianness} parameter.
+The @dfn{endianness} is defined as the order of bytes in multi-byte
+numbers: numbers encoded in @dfn{big endian} have their most
+significant bytes written first, whereas numbers encoded in
+@dfn{little endian} have their least significant bytes
+first@footnote{Big-endian and little-endian are the most common
+``endiannesses'', but others do exist. For instance, the GNU MP
+library allows @dfn{word order} to be specified independently of
+@dfn{byte order} (@pxref{Integer Import and Export,,, gmp, The GNU
+Multiple Precision Arithmetic Library Manual}).}.
+
+Little-endian is the native endianness of the IA32 architecture and
+its derivatives, while big-endian is native to SPARC and PowerPC,
+among others. The @code{native-endianness} procedure returns the
+native endianness of the machine it runs on.
+
+@deffn {Scheme Procedure} native-endianness
+@deffnx {C Function} scm_native_endianness ()
+Return a value denoting the native endianness of the host machine.
+@end deffn
+
+@deffn {Scheme Macro} endianness symbol
+Return an object denoting the endianness specified by @var{symbol}. If
+@var{symbol} is neither @code{big} nor @code{little} then an error is
+raised at expand-time.
+@end deffn
+
+@defvr {C Variable} scm_endianness_big
+@defvrx {C Variable} scm_endianness_little
+The objects denoting big- and little-endianness, respectively.
+@end defvr
+
+
+@node Bytevector Manipulation
+@subsubsection Manipulating Bytevectors
+
+Bytevectors can be created, copied, and analyzed with the following
+procedures and C functions.
+
+@deffn {Scheme Procedure} make-bytevector len [fill]
+@deffnx {C Function} scm_make_bytevector (len, fill)
+@deffnx {C Function} scm_c_make_bytevector (size_t len)
+Return a new bytevector of @var{len} bytes. Optionally, if @var{fill}
+is given, fill it with @var{fill}; @var{fill} must be in the range
+[-128,255].
+@end deffn
+
+@deffn {Scheme Procedure} bytevector? obj
+@deffnx {C Function} scm_bytevector_p (obj)
+Return true if @var{obj} is a bytevector.
+@end deffn
+
+@deftypefn {C Function} int scm_is_bytevector (SCM obj)
+Equivalent to @code{scm_is_true (scm_bytevector_p (obj))}.
+@end deftypefn
+
+@deffn {Scheme Procedure} bytevector-length bv
+@deffnx {C Function} scm_bytevector_length (bv)
+Return the length in bytes of bytevector @var{bv}.
+@end deffn
+
+@deftypefn {C Function} size_t scm_c_bytevector_length (SCM bv)
+Likewise, return the length in bytes of bytevector @var{bv}.
+@end deftypefn
+
+@deffn {Scheme Procedure} bytevector=? bv1 bv2
+@deffnx {C Function} scm_bytevector_eq_p (bv1, bv2)
+Return is @var{bv1} equals to @var{bv2}---i.e., if they have the same
+length and contents.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-fill! bv fill
+@deffnx {C Function} scm_bytevector_fill_x (bv, fill)
+Fill bytevector @var{bv} with @var{fill}, a byte.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-copy! source source-start target target-start len
+@deffnx {C Function} scm_bytevector_copy_x (source, source_start, target, target_start, len)
+Copy @var{len} bytes from @var{source} into @var{target}, starting
+reading from @var{source-start} (a positive index within @var{source})
+and start writing at @var{target-start}. It is permitted for the
+@var{source} and @var{target} regions to overlap.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-copy bv
+@deffnx {C Function} scm_bytevector_copy (bv)
+Return a newly allocated copy of @var{bv}.
+@end deffn
+
+@deftypefn {C Function} scm_t_uint8 scm_c_bytevector_ref (SCM bv, size_t index)
+Return the byte at @var{index} in bytevector @var{bv}.
+@end deftypefn
+
+@deftypefn {C Function} void scm_c_bytevector_set_x (SCM bv, size_t index, scm_t_uint8 value)
+Set the byte at @var{index} in @var{bv} to @var{value}.
+@end deftypefn
+
+Low-level C macros are available. They do not perform any
+type-checking; as such they should be used with care.
+
+@deftypefn {C Macro} size_t SCM_BYTEVECTOR_LENGTH (bv)
+Return the length in bytes of bytevector @var{bv}.
+@end deftypefn
+
+@deftypefn {C Macro} {signed char *} SCM_BYTEVECTOR_CONTENTS (bv)
+Return a pointer to the contents of bytevector @var{bv}.
+@end deftypefn
+
+
+@node Bytevectors as Integers
+@subsubsection Interpreting Bytevector Contents as Integers
+
+The contents of a bytevector can be interpreted as a sequence of
+integers of any given size, sign, and endianness.
+
+@lisp
+(let ((bv (make-bytevector 4)))
+ (bytevector-u8-set! bv 0 #x12)
+ (bytevector-u8-set! bv 1 #x34)
+ (bytevector-u8-set! bv 2 #x56)
+ (bytevector-u8-set! bv 3 #x78)
+
+ (map (lambda (number)
+ (number->string number 16))
+ (list (bytevector-u8-ref bv 0)
+ (bytevector-u16-ref bv 0 (endianness big))
+ (bytevector-u32-ref bv 0 (endianness little)))))
+
+@result{} ("12" "1234" "78563412")
+@end lisp
+
+The most generic procedures to interpret bytevector contents as integers
+are described below.
+
+@deffn {Scheme Procedure} bytevector-uint-ref bv index endianness size
+@deffnx {C Function} scm_bytevector_uint_ref (bv, index, endianness, size)
+Return the @var{size}-byte long unsigned integer at index @var{index} in
+@var{bv}, decoded according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-sint-ref bv index endianness size
+@deffnx {C Function} scm_bytevector_sint_ref (bv, index, endianness, size)
+Return the @var{size}-byte long signed integer at index @var{index} in
+@var{bv}, decoded according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-uint-set! bv index value endianness size
+@deffnx {C Function} scm_bytevector_uint_set_x (bv, index, value, endianness, size)
+Set the @var{size}-byte long unsigned integer at @var{index} to
+@var{value}, encoded according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-sint-set! bv index value endianness size
+@deffnx {C Function} scm_bytevector_sint_set_x (bv, index, value, endianness, size)
+Set the @var{size}-byte long signed integer at @var{index} to
+@var{value}, encoded according to @var{endianness}.
+@end deffn
+
+The following procedures are similar to the ones above, but specialized
+to a given integer size:
+
+@deffn {Scheme Procedure} bytevector-u8-ref bv index
+@deffnx {Scheme Procedure} bytevector-s8-ref bv index
+@deffnx {Scheme Procedure} bytevector-u16-ref bv index endianness
+@deffnx {Scheme Procedure} bytevector-s16-ref bv index endianness
+@deffnx {Scheme Procedure} bytevector-u32-ref bv index endianness
+@deffnx {Scheme Procedure} bytevector-s32-ref bv index endianness
+@deffnx {Scheme Procedure} bytevector-u64-ref bv index endianness
+@deffnx {Scheme Procedure} bytevector-s64-ref bv index endianness
+@deffnx {C Function} scm_bytevector_u8_ref (bv, index)
+@deffnx {C Function} scm_bytevector_s8_ref (bv, index)
+@deffnx {C Function} scm_bytevector_u16_ref (bv, index, endianness)
+@deffnx {C Function} scm_bytevector_s16_ref (bv, index, endianness)
+@deffnx {C Function} scm_bytevector_u32_ref (bv, index, endianness)
+@deffnx {C Function} scm_bytevector_s32_ref (bv, index, endianness)
+@deffnx {C Function} scm_bytevector_u64_ref (bv, index, endianness)
+@deffnx {C Function} scm_bytevector_s64_ref (bv, index, endianness)
+Return the unsigned @var{n}-bit (signed) integer (where @var{n} is 8,
+16, 32 or 64) from @var{bv} at @var{index}, decoded according to
+@var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-u8-set! bv index value
+@deffnx {Scheme Procedure} bytevector-s8-set! bv index value
+@deffnx {Scheme Procedure} bytevector-u16-set! bv index value endianness
+@deffnx {Scheme Procedure} bytevector-s16-set! bv index value endianness
+@deffnx {Scheme Procedure} bytevector-u32-set! bv index value endianness
+@deffnx {Scheme Procedure} bytevector-s32-set! bv index value endianness
+@deffnx {Scheme Procedure} bytevector-u64-set! bv index value endianness
+@deffnx {Scheme Procedure} bytevector-s64-set! bv index value endianness
+@deffnx {C Function} scm_bytevector_u8_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_s8_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_u16_set_x (bv, index, value, endianness)
+@deffnx {C Function} scm_bytevector_s16_set_x (bv, index, value, endianness)
+@deffnx {C Function} scm_bytevector_u32_set_x (bv, index, value, endianness)
+@deffnx {C Function} scm_bytevector_s32_set_x (bv, index, value, endianness)
+@deffnx {C Function} scm_bytevector_u64_set_x (bv, index, value, endianness)
+@deffnx {C Function} scm_bytevector_s64_set_x (bv, index, value, endianness)
+Store @var{value} as an @var{n}-bit (signed) integer (where @var{n} is
+8, 16, 32 or 64) in @var{bv} at @var{index}, encoded according to
+@var{endianness}.
+@end deffn
+
+Finally, a variant specialized for the host's endianness is available
+for each of these functions (with the exception of the @code{u8} and
+@code{s8} accessors, as endianness is about byte order and there is only
+1 byte):
+
+@deffn {Scheme Procedure} bytevector-u16-native-ref bv index
+@deffnx {Scheme Procedure} bytevector-s16-native-ref bv index
+@deffnx {Scheme Procedure} bytevector-u32-native-ref bv index
+@deffnx {Scheme Procedure} bytevector-s32-native-ref bv index
+@deffnx {Scheme Procedure} bytevector-u64-native-ref bv index
+@deffnx {Scheme Procedure} bytevector-s64-native-ref bv index
+@deffnx {C Function} scm_bytevector_u16_native_ref (bv, index)
+@deffnx {C Function} scm_bytevector_s16_native_ref (bv, index)
+@deffnx {C Function} scm_bytevector_u32_native_ref (bv, index)
+@deffnx {C Function} scm_bytevector_s32_native_ref (bv, index)
+@deffnx {C Function} scm_bytevector_u64_native_ref (bv, index)
+@deffnx {C Function} scm_bytevector_s64_native_ref (bv, index)
+Return the unsigned @var{n}-bit (signed) integer (where @var{n} is 8,
+16, 32 or 64) from @var{bv} at @var{index}, decoded according to the
+host's native endianness.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-u16-native-set! bv index value
+@deffnx {Scheme Procedure} bytevector-s16-native-set! bv index value
+@deffnx {Scheme Procedure} bytevector-u32-native-set! bv index value
+@deffnx {Scheme Procedure} bytevector-s32-native-set! bv index value
+@deffnx {Scheme Procedure} bytevector-u64-native-set! bv index value
+@deffnx {Scheme Procedure} bytevector-s64-native-set! bv index value
+@deffnx {C Function} scm_bytevector_u16_native_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_s16_native_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_u32_native_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_s32_native_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_u64_native_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_s64_native_set_x (bv, index, value)
+Store @var{value} as an @var{n}-bit (signed) integer (where @var{n} is
+8, 16, 32 or 64) in @var{bv} at @var{index}, encoded according to the
+host's native endianness.
+@end deffn
+
+
+@node Bytevectors and Integer Lists
+@subsubsection Converting Bytevectors to/from Integer Lists
+
+Bytevector contents can readily be converted to/from lists of signed or
+unsigned integers:
+
+@lisp
+(bytevector->sint-list (u8-list->bytevector (make-list 4 255))
+ (endianness little) 2)
+@result{} (-1 -1)
+@end lisp
+
+@deffn {Scheme Procedure} bytevector->u8-list bv
+@deffnx {C Function} scm_bytevector_to_u8_list (bv)
+Return a newly allocated list of unsigned 8-bit integers from the
+contents of @var{bv}.
+@end deffn
+
+@deffn {Scheme Procedure} u8-list->bytevector lst
+@deffnx {C Function} scm_u8_list_to_bytevector (lst)
+Return a newly allocated bytevector consisting of the unsigned 8-bit
+integers listed in @var{lst}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector->uint-list bv endianness size
+@deffnx {C Function} scm_bytevector_to_uint_list (bv, endianness, size)
+Return a list of unsigned integers of @var{size} bytes representing the
+contents of @var{bv}, decoded according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector->sint-list bv endianness size
+@deffnx {C Function} scm_bytevector_to_sint_list (bv, endianness, size)
+Return a list of signed integers of @var{size} bytes representing the
+contents of @var{bv}, decoded according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} uint-list->bytevector lst endianness size
+@deffnx {C Function} scm_uint_list_to_bytevector (lst, endianness, size)
+Return a new bytevector containing the unsigned integers listed in
+@var{lst} and encoded on @var{size} bytes according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} sint-list->bytevector lst endianness size
+@deffnx {C Function} scm_sint_list_to_bytevector (lst, endianness, size)
+Return a new bytevector containing the signed integers listed in
+@var{lst} and encoded on @var{size} bytes according to @var{endianness}.
+@end deffn
+
+@node Bytevectors as Floats
+@subsubsection Interpreting Bytevector Contents as Floating Point Numbers
+
+@cindex IEEE-754 floating point numbers
+
+Bytevector contents can also be accessed as IEEE-754 single- or
+double-precision floating point numbers (respectively 32 and 64-bit
+long) using the procedures described here.
+
+@deffn {Scheme Procedure} bytevector-ieee-single-ref bv index endianness
+@deffnx {Scheme Procedure} bytevector-ieee-double-ref bv index endianness
+@deffnx {C Function} scm_bytevector_ieee_single_ref (bv, index, endianness)
+@deffnx {C Function} scm_bytevector_ieee_double_ref (bv, index, endianness)
+Return the IEEE-754 single-precision floating point number from @var{bv}
+at @var{index} according to @var{endianness}.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-ieee-single-set! bv index value endianness
+@deffnx {Scheme Procedure} bytevector-ieee-double-set! bv index value endianness
+@deffnx {C Function} scm_bytevector_ieee_single_set_x (bv, index, value, endianness)
+@deffnx {C Function} scm_bytevector_ieee_double_set_x (bv, index, value, endianness)
+Store real number @var{value} in @var{bv} at @var{index} according to
+@var{endianness}.
+@end deffn
+
+Specialized procedures are also available:
+
+@deffn {Scheme Procedure} bytevector-ieee-single-native-ref bv index
+@deffnx {Scheme Procedure} bytevector-ieee-double-native-ref bv index
+@deffnx {C Function} scm_bytevector_ieee_single_native_ref (bv, index)
+@deffnx {C Function} scm_bytevector_ieee_double_native_ref (bv, index)
+Return the IEEE-754 single-precision floating point number from @var{bv}
+at @var{index} according to the host's native endianness.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector-ieee-single-native-set! bv index value
+@deffnx {Scheme Procedure} bytevector-ieee-double-native-set! bv index value
+@deffnx {C Function} scm_bytevector_ieee_single_native_set_x (bv, index, value)
+@deffnx {C Function} scm_bytevector_ieee_double_native_set_x (bv, index, value)
+Store real number @var{value} in @var{bv} at @var{index} according to
+the host's native endianness.
+@end deffn
+
+
+@node Bytevectors as Strings
+@subsubsection Interpreting Bytevector Contents as Unicode Strings
+
+@cindex Unicode string encoding
+
+Bytevector contents can also be interpreted as Unicode strings encoded
+in one of the most commonly available encoding formats.
+@xref{Representing Strings as Bytes}, for a more generic interface.
+
+@lisp
+(utf8->string (u8-list->bytevector '(99 97 102 101)))
+@result{} "cafe"
+
+(string->utf8 "caf@'e") ;; SMALL LATIN LETTER E WITH ACUTE ACCENT
+@result{} #vu8(99 97 102 195 169)
+@end lisp
+
+@deftypefn {Scheme Procedure} {} string-utf8-length str
+@deftypefnx {C function} SCM scm_string_utf8_length (str)
+@deftypefnx {C function} size_t scm_c_string_utf8_length (str)
+Return the number of bytes in the UTF-8 representation of @var{str}.
+@end deftypefn
+
+@deffn {Scheme Procedure} string->utf8 str
+@deffnx {Scheme Procedure} string->utf16 str [endianness]
+@deffnx {Scheme Procedure} string->utf32 str [endianness]
+@deffnx {C Function} scm_string_to_utf8 (str)
+@deffnx {C Function} scm_string_to_utf16 (str, endianness)
+@deffnx {C Function} scm_string_to_utf32 (str, endianness)
+Return a newly allocated bytevector that contains the UTF-8, UTF-16, or
+UTF-32 (aka. UCS-4) encoding of @var{str}. For UTF-16 and UTF-32,
+@var{endianness} should be the symbol @code{big} or @code{little}; when omitted,
+it defaults to big endian.
+@end deffn
+
+@deffn {Scheme Procedure} utf8->string utf
+@deffnx {Scheme Procedure} utf16->string utf [endianness]
+@deffnx {Scheme Procedure} utf32->string utf [endianness]
+@deffnx {C Function} scm_utf8_to_string (utf)
+@deffnx {C Function} scm_utf16_to_string (utf, endianness)
+@deffnx {C Function} scm_utf32_to_string (utf, endianness)
+Return a newly allocated string that contains from the UTF-8-, UTF-16-,
+or UTF-32-decoded contents of bytevector @var{utf}. For UTF-16 and UTF-32,
+@var{endianness} should be the symbol @code{big} or @code{little}; when omitted,
+it defaults to big endian.
+@end deffn
+
+@node Bytevectors as Arrays
+@subsubsection Accessing Bytevectors with the Array API
+
+As an extension to the R6RS, Guile allows bytevectors to be manipulated
+with the @dfn{array} procedures (@pxref{Arrays}). When using these
+APIs, bytes are accessed one at a time as 8-bit unsigned integers:
+
+@example
+(define bv #vu8(0 1 2 3))
+
+(array? bv)
+@result{} #t
+
+(array-rank bv)
+@result{} 1
+
+(array-ref bv 2)
+@result{} 2
+
+;; Note the different argument order on array-set!.
+(array-set! bv 77 2)
+(array-ref bv 2)
+@result{} 77
+
+(array-type bv)
+@result{} vu8
+@end example
+
+
+@node Bytevectors as Uniform Vectors
+@subsubsection Accessing Bytevectors with the SRFI-4 API
+
+Bytevectors may also be accessed with the SRFI-4 API. @xref{SRFI-4 and
+Bytevectors}, for more information.
+
+
+@node Arrays
+@subsection Arrays
+@tpindex Arrays
+
+@dfn{Arrays} are a collection of cells organized into an arbitrary
+number of dimensions. Each cell can be accessed in constant time by
+supplying an index for each dimension.
+
+In the current implementation, an array uses a vector of some kind for
+the actual storage of its elements. Any kind of vector will do, so you
+can have arrays of uniform numeric values, arrays of characters, arrays
+of bits, and of course, arrays of arbitrary Scheme values. For example,
+arrays with an underlying @code{c64vector} might be nice for digital
+signal processing, while arrays made from a @code{u8vector} might be
+used to hold gray-scale images.
+
+The number of dimensions of an array is called its @dfn{rank}. Thus,
+a matrix is an array of rank 2, while a vector has rank 1. When
+accessing an array element, you have to specify one exact integer for
+each dimension. These integers are called the @dfn{indices} of the
+element. An array specifies the allowed range of indices for each
+dimension via an inclusive lower and upper bound. These bounds can
+well be negative, but the upper bound must be greater than or equal to
+the lower bound minus one. When all lower bounds of an array are
+zero, it is called a @dfn{zero-origin} array.
+
+Arrays can be of rank 0, which could be interpreted as a scalar.
+Thus, a zero-rank array can store exactly one object and the list of
+indices of this element is the empty list.
+
+Arrays contain zero elements when one of their dimensions has a zero
+length. These empty arrays maintain information about their shape: a
+matrix with zero columns and 3 rows is different from a matrix with 3
+columns and zero rows, which again is different from a vector of
+length zero.
+
+The array procedures are all polymorphic, treating strings, uniform
+numeric vectors, bytevectors, bit vectors and ordinary vectors as one
+dimensional arrays.
+
+@menu
+* Array Syntax::
+* Array Procedures::
+* Shared Arrays::
+* Arrays as arrays of arrays::
+* Accessing Arrays from C::
+@end menu
+
+@node Array Syntax
+@subsubsection Array Syntax
+
+An array is displayed as @code{#} followed by its rank, followed by a
+tag that describes the underlying vector, optionally followed by
+information about its shape, and finally followed by the cells,
+organized into dimensions using parentheses.
+
+In more words, the array tag is of the form
+
+@example
+ #<@@lower><:len><@@lower><:len>...
+@end example
+
+where @code{} is a positive integer in decimal giving the rank of
+the array. It is omitted when the rank is 1 and the array is non-shared
+and has zero-origin (see below). For shared arrays and for a non-zero
+origin, the rank is always printed even when it is 1 to distinguish
+them from ordinary vectors.
+
+The @code{} part is the tag for a uniform numeric vector, like
+@code{u8}, @code{s16}, etc, @code{b} for bitvectors, or @code{a} for
+strings. It is empty for ordinary vectors.
+
+The @code{<@@lower>} part is a @samp{@@} character followed by a signed
+integer in decimal giving the lower bound of a dimension. There is one
+@code{<@@lower>} for each dimension. When all lower bounds are zero,
+all @code{<@@lower>} parts are omitted.
+
+The @code{<:len>} part is a @samp{:} character followed by an unsigned
+integer in decimal giving the length of a dimension. Like for the lower
+bounds, there is one @code{<:len>} for each dimension, and the
+@code{<:len>} part always follows the @code{<@@lower>} part for a
+dimension. Lengths are only then printed when they can't be deduced
+from the nested lists of elements of the array literal, which can happen
+when at least one length is zero.
+
+As a special case, an array of rank 0 is printed as
+@code{#0()}, where @code{} is the result of
+printing the single element of the array.
+
+Thus,
+
+@table @code
+@item #(1 2 3)
+is an ordinary array of rank 1 with lower bound 0 in dimension 0.
+(I.e., a regular vector.)
+
+@item #@@2(1 2 3)
+is an ordinary array of rank 1 with lower bound 2 in dimension 0.
+
+@item #2((1 2 3) (4 5 6))
+is a non-uniform array of rank 2; a 2@cross{}3 matrix with index ranges 0..1
+and 0..2.
+
+@item #u32(0 1 2)
+is a uniform u8 array of rank 1.
+
+@item #2u32@@2@@3((1 2) (2 3))
+is a uniform u32 array of rank 2 with index ranges 2..3 and 3..4.
+
+@item #2()
+is a two-dimensional array with index ranges 0..-1 and 0..-1, i.e.@:
+both dimensions have length zero.
+
+@item #2:0:2()
+is a two-dimensional array with index ranges 0..-1 and 0..1, i.e.@: the
+first dimension has length zero, but the second has length 2.
+
+@item #0(12)
+is a rank-zero array with contents 12.
+
+@end table
+
+In addition, bytevectors are also arrays, but use a different syntax
+(@pxref{Bytevectors}):
+
+@table @code
+
+@item #vu8(1 2 3)
+is a 3-byte long bytevector, with contents 1, 2, 3.
+
+@end table
+
+@node Array Procedures
+@subsubsection Array Procedures
+
+When an array is created, the range of each dimension must be
+specified, e.g., to create a 2@cross{}3 array with a zero-based index:
+
+@example
+(make-array 'ho 2 3) @result{} #2((ho ho ho) (ho ho ho))
+@end example
+
+The range of each dimension can also be given explicitly, e.g., another
+way to create the same array:
+
+@example
+(make-array 'ho '(0 1) '(0 2)) @result{} #2((ho ho ho) (ho ho ho))
+@end example
+
+The following procedures can be used with arrays (or vectors). An
+argument shown as @var{idx}@dots{} means one parameter for each
+dimension in the array. A @var{idxlist} argument means a list of such
+values, one for each dimension.
+
+
+@deffn {Scheme Procedure} array? obj
+@deffnx {C Function} scm_array_p (obj, unused)
+Return @code{#t} if the @var{obj} is an array, and @code{#f} if
+not.
+
+The second argument to scm_array_p is there for historical reasons,
+but it is not used. You should always pass @code{SCM_UNDEFINED} as
+its value.
+@end deffn
+
+@deffn {Scheme Procedure} typed-array? obj type
+@deffnx {C Function} scm_typed_array_p (obj, type)
+Return @code{#t} if the @var{obj} is an array of type @var{type}, and
+@code{#f} if not.
+@end deffn
+
+@deftypefn {C Function} int scm_is_array (SCM obj)
+Return @code{1} if the @var{obj} is an array and @code{0} if not.
+@end deftypefn
+
+@deftypefn {C Function} int scm_is_typed_array (SCM obj, SCM type)
+Return @code{0} if the @var{obj} is an array of type @var{type}, and
+@code{1} if not.
+@end deftypefn
+
+@deffn {Scheme Procedure} make-array fill bound @dots{}
+@deffnx {C Function} scm_make_array (fill, bounds)
+Equivalent to @code{(make-typed-array #t @var{fill} @var{bound} ...)}.
+@end deffn
+
+@deffn {Scheme Procedure} make-typed-array type fill bound @dots{}
+@deffnx {C Function} scm_make_typed_array (type, fill, bounds)
+Create and return an array that has as many dimensions as there are
+@var{bound}s and (maybe) fill it with @var{fill}.
+
+The underlying storage vector is created according to @var{type},
+which must be a symbol whose name is the `vectag' of the array as
+explained above, or @code{#t} for ordinary, non-specialized arrays.
+
+For example, using the symbol @code{f64} for @var{type} will create an
+array that uses a @code{f64vector} for storing its elements, and
+@code{a} will use a string.
+
+When @var{fill} is not the special @emph{unspecified} value, the new
+array is filled with @var{fill}. Otherwise, the initial contents of
+the array is unspecified. The special @emph{unspecified} value is
+stored in the variable @code{*unspecified*} so that for example
+@code{(make-typed-array 'u32 *unspecified* 4)} creates a uninitialized
+@code{u32} vector of length 4.
+
+Each @var{bound} may be a positive non-zero integer @var{n}, in which
+case the index for that dimension can range from 0 through @var{n}-1; or
+an explicit index range specifier in the form @code{(LOWER UPPER)},
+where both @var{lower} and @var{upper} are integers, possibly less than
+zero, and possibly the same number (however, @var{lower} cannot be
+greater than @var{upper}).
+@end deffn
+
+@deffn {Scheme Procedure} list->array dimspec list
+Equivalent to @code{(list->typed-array #t @var{dimspec}
+@var{list})}.
+@end deffn
+
+@deffn {Scheme Procedure} list->typed-array type dimspec list
+@deffnx {C Function} scm_list_to_typed_array (type, dimspec, list)
+Return an array of the type indicated by @var{type} with elements the
+same as those of @var{list}.
+
+The argument @var{dimspec} determines the number of dimensions of the
+array and their lower bounds. When @var{dimspec} is an exact integer,
+it gives the number of dimensions directly and all lower bounds are
+zero. When it is a list of exact integers, then each element is the
+lower index bound of a dimension, and there will be as many dimensions
+as elements in the list.
+@end deffn
+
+@deffn {Scheme Procedure} array-type array
+@deffnx {C Function} scm_array_type (array)
+Return the type of @var{array}. This is the `vectag' used for
+printing @var{array} (or @code{#t} for ordinary arrays) and can be
+used with @code{make-typed-array} to create an array of the same kind
+as @var{array}.
+@end deffn
+
+@deffn {Scheme Procedure} array-ref array idx @dots{}
+@deffnx {C Function} scm_array_ref (array, idxlist)
+Return the element at @code{(idx @dots{})} in @var{array}.
+
+@example
+(define a (make-array 999 '(1 2) '(3 4)))
+(array-ref a 2 4) @result{} 999
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} array-in-bounds? array idx @dots{}
+@deffnx {C Function} scm_array_in_bounds_p (array, idxlist)
+Return @code{#t} if the given indices would be acceptable to
+@code{array-ref}.
+
+@example
+(define a (make-array #f '(1 2) '(3 4)))
+(array-in-bounds? a 2 3) @result{} #t
+(array-in-bounds? a 0 0) @result{} #f
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} array-set! array obj idx @dots{}
+@deffnx {C Function} scm_array_set_x (array, obj, idxlist)
+Set the element at @code{(idx @dots{})} in @var{array} to @var{obj}.
+The return value is unspecified.
+
+@example
+(define a (make-array #f '(0 1) '(0 1)))
+(array-set! a #t 1 1)
+a @result{} #2((#f #f) (#f #t))
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} array-shape array
+@deffnx {Scheme Procedure} array-dimensions array
+@deffnx {C Function} scm_array_dimensions (array)
+Return a list of the bounds for each dimension of @var{array}.
+
+@code{array-shape} gives @code{(@var{lower} @var{upper})} for each
+dimension. @code{array-dimensions} instead returns just
+@math{@var{upper}+1} for dimensions with a 0 lower bound. Both are
+suitable as input to @code{make-array}.
+
+For example,
+
+@example
+(define a (make-array 'foo '(-1 3) 5))
+(array-shape a) @result{} ((-1 3) (0 4))
+(array-dimensions a) @result{} ((-1 3) 5)
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} array-length array
+@deffnx {C Function} scm_array_length (array)
+@deffnx {C Function} size_t scm_c_array_length (array)
+Return the length of an array: its first dimension. It is an error to
+ask for the length of an array of rank 0.
+@end deffn
+
+@deffn {Scheme Procedure} array-rank array
+@deffnx {C Function} scm_array_rank (array)
+Return the rank of @var{array}.
+@end deffn
+
+@deftypefn {C Function} size_t scm_c_array_rank (SCM array)
+Return the rank of @var{array} as a @code{size_t}.
+@end deftypefn
+
+@deffn {Scheme Procedure} array->list array
+@deffnx {C Function} scm_array_to_list (array)
+Return a list consisting of all the elements, in order, of
+@var{array}.
+@end deffn
+
+@c FIXME: Describe how the order affects the copying (it matters for
+@c shared arrays with the same underlying root vector, presumably).
+@c
+@deffn {Scheme Procedure} array-copy! src dst
+@deffnx {Scheme Procedure} array-copy-in-order! src dst
+@deffnx {C Function} scm_array_copy_x (src, dst)
+Copy every element from vector or array @var{src} to the corresponding
+element of @var{dst}. @var{dst} must have the same rank as @var{src},
+and be at least as large in each dimension. The return value is
+unspecified.
+@end deffn
+
+@deffn {Scheme Procedure} array-fill! array fill
+@deffnx {C Function} scm_array_fill_x (array, fill)
+Store @var{fill} in every element of @var{array}. The value returned
+is unspecified.
+@end deffn
+
+@c begin (texi-doc-string "guile" "array-equal?")
+@deffn {Scheme Procedure} array-equal? array @dots{}
+Return @code{#t} if all arguments are arrays with the same shape, the
+same type, and have corresponding elements which are either
+@code{equal?} or @code{array-equal?}. This function differs from
+@code{equal?} (@pxref{Equality}) in that all arguments must be arrays.
+@end deffn
+
+@c FIXME: array-map! accepts no source arrays at all, and in that
+@c case makes calls "(proc)". Is that meant to be a documented
+@c feature?
+@c
+@c FIXME: array-for-each doesn't say what happens if the sources have
+@c different index ranges. The code currently iterates over the
+@c indices of the first and expects the others to cover those. That
+@c at least vaguely matches array-map!, but is it meant to be a
+@c documented feature?
+
+@deffn {Scheme Procedure} array-map! dst proc src @dots{}
+@deffnx {Scheme Procedure} array-map-in-order! dst proc src1 @dots{} srcN
+@deffnx {C Function} scm_array_map_x (dst, proc, srclist)
+Set each element of the @var{dst} array to values obtained from calls
+to @var{proc}. The value returned is unspecified.
+
+Each call is @code{(@var{proc} @var{elem1} @dots{} @var{elemN})},
+where each @var{elem} is from the corresponding @var{src} array, at
+the @var{dst} index. @code{array-map-in-order!} makes the calls in
+row-major order, @code{array-map!} makes them in an unspecified order.
+
+The @var{src} arrays must have the same number of dimensions as
+@var{dst}, and must have a range for each dimension which covers the
+range in @var{dst}. This ensures all @var{dst} indices are valid in
+each @var{src}.
+@end deffn
+
+@deffn {Scheme Procedure} array-for-each proc src1 src2 @dots{}
+@deffnx {C Function} scm_array_for_each (proc, src1, srclist)
+Apply @var{proc} to each tuple of elements of @var{src1} @var{src2}
+@dots{}, in row-major order. The value returned is unspecified.
+@end deffn
+
+@deffn {Scheme Procedure} array-index-map! dst proc
+@deffnx {C Function} scm_array_index_map_x (dst, proc)
+Set each element of the @var{dst} array to values returned by calls to
+@var{proc}. The value returned is unspecified.
+
+Each call is @code{(@var{proc} @var{i1} @dots{} @var{iN})}, where
+@var{i1}@dots{}@var{iN} is the destination index, one parameter for
+each dimension. The order in which the calls are made is unspecified.
+
+For example, to create a @m{4\times4, 4x4} matrix representing a
+cyclic group,
+
+@tex
+\advance\leftskip by 2\lispnarrowing {
+$\left(\matrix{%
+0 & 1 & 2 & 3 \cr
+1 & 2 & 3 & 0 \cr
+2 & 3 & 0 & 1 \cr
+3 & 0 & 1 & 2 \cr
+}\right)$} \par
+@end tex
+@ifnottex
+@example
+ / 0 1 2 3 \
+ | 1 2 3 0 |
+ | 2 3 0 1 |
+ \ 3 0 1 2 /
+@end example
+@end ifnottex
+
+@example
+(define a (make-array #f 4 4))
+(array-index-map! a (lambda (i j)
+ (modulo (+ i j) 4)))
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]]
+@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end)
+Attempt to read all elements of array @var{ra}, in lexicographic order, as
+binary objects from @var{port_or_fd}.
+If an end of file is encountered,
+the objects up to that point are put into @var{ra}
+(starting at the beginning) and the remainder of the array is
+unchanged.
+
+The optional arguments @var{start} and @var{end} allow
+a specified region of a vector (or linearized array) to be read,
+leaving the remainder of the vector unchanged.
+
+@code{uniform-array-read!} returns the number of objects read.
+@var{port_or_fd} may be omitted, in which case it defaults to the value
+returned by @code{(current-input-port)}.
+@end deffn
+
+@deffn {Scheme Procedure} uniform-array-write ra [port_or_fd [start [end]]]
+@deffnx {C Function} scm_uniform_array_write (ra, port_or_fd, start, end)
+Writes all elements of @var{ra} as binary objects to
+@var{port_or_fd}.
+
+The optional arguments @var{start}
+and @var{end} allow
+a specified region of a vector (or linearized array) to be written.
+
+The number of objects actually written is returned.
+@var{port_or_fd} may be
+omitted, in which case it defaults to the value returned by
+@code{(current-output-port)}.
+@end deffn
+
+@node Shared Arrays
+@subsubsection Shared Arrays
+
+@deffn {Scheme Procedure} make-shared-array oldarray mapfunc bound @dots{}
+@deffnx {C Function} scm_make_shared_array (oldarray, mapfunc, boundlist)
+Return a new array which shares the storage of @var{oldarray}.
+Changes made through either affect the same underlying storage. The
+@var{bound} @dots{} arguments are the shape of the new array, the same
+as @code{make-array} (@pxref{Array Procedures}).
+
+@var{mapfunc} translates coordinates from the new array to the
+@var{oldarray}. It's called as @code{(@var{mapfunc} newidx1 @dots{})}
+with one parameter for each dimension of the new array, and should
+return a list of indices for @var{oldarray}, one for each dimension of
+@var{oldarray}.
+
+@var{mapfunc} must be affine linear, meaning that each @var{oldarray}
+index must be formed by adding integer multiples (possibly negative)
+of some or all of @var{newidx1} etc, plus a possible integer offset.
+The multiples and offset must be the same in each call.
+
+@sp 1
+One good use for a shared array is to restrict the range of some
+dimensions, so as to apply say @code{array-for-each} or
+@code{array-fill!} to only part of an array. The plain @code{list}
+function can be used for @var{mapfunc} in this case, making no changes
+to the index values. For example,
+
+@example
+(make-shared-array #2((a b c) (d e f) (g h i)) list 3 2)
+@result{} #2((a b) (d e) (g h))
+@end example
+
+The new array can have fewer dimensions than @var{oldarray}, for
+example to take a column from an array.
+
+@example
+(make-shared-array #2((a b c) (d e f) (g h i))
+ (lambda (i) (list i 2))
+ '(0 2))
+@result{} #1(c f i)
+@end example
+
+A diagonal can be taken by using the single new array index for both
+row and column in the old array. For example,
+
+@example
+(make-shared-array #2((a b c) (d e f) (g h i))
+ (lambda (i) (list i i))
+ '(0 2))
+@result{} #1(a e i)
+@end example
+
+Dimensions can be increased by for instance considering portions of a
+one dimensional array as rows in a two dimensional array.
+(@code{array-contents} below can do the opposite, flattening an
+array.)
+
+@example
+(make-shared-array #1(a b c d e f g h i j k l)
+ (lambda (i j) (list (+ (* i 3) j)))
+ 4 3)
+@result{} #2((a b c) (d e f) (g h i) (j k l))
+@end example
+
+By negating an index the order that elements appear can be reversed.
+The following just reverses the column order,
+
+@example
+(make-shared-array #2((a b c) (d e f) (g h i))
+ (lambda (i j) (list i (- 2 j)))
+ 3 3)
+@result{} #2((c b a) (f e d) (i h g))
+@end example
+
+A fixed offset on indexes allows for instance a change from a 0 based
+to a 1 based array,
+
+@example
+(define x #2((a b c) (d e f) (g h i)))
+(define y (make-shared-array x
+ (lambda (i j) (list (1- i) (1- j)))
+ '(1 3) '(1 3)))
+(array-ref x 0 0) @result{} a
+(array-ref y 1 1) @result{} a
+@end example
+
+A multiple on an index allows every Nth element of an array to be
+taken. The following is every third element,
+
+@example
+(make-shared-array #1(a b c d e f g h i j k l)
+ (lambda (i) (list (* i 3)))
+ 4)
+@result{} #1(a d g j)
+@end example
+
+The above examples can be combined to make weird and wonderful
+selections from an array, but it's important to note that because
+@var{mapfunc} must be affine linear, arbitrary permutations are not
+possible.
+
+In the current implementation, @var{mapfunc} is not called for every
+access to the new array but only on some sample points to establish a
+base and stride for new array indices in @var{oldarray} data. A few
+sample points are enough because @var{mapfunc} is linear.
+@end deffn
+
+@deffn {Scheme Procedure} shared-array-increments array
+@deffnx {C Function} scm_shared_array_increments (array)
+For each dimension, return the distance between elements in the root vector.
+@end deffn
+
+@deffn {Scheme Procedure} shared-array-offset array
+@deffnx {C Function} scm_shared_array_offset (array)
+Return the root vector index of the first element in the array.
+@end deffn
+
+@deffn {Scheme Procedure} shared-array-root array
+@deffnx {C Function} scm_shared_array_root (array)
+Return the root vector of a shared array.
+@end deffn
+
+@deffn {Scheme Procedure} array-contents array [strict]
+@deffnx {C Function} scm_array_contents (array, strict)
+If @var{array} may be @dfn{unrolled} into a one dimensional shared array
+without changing their order (last subscript changing fastest), then
+@code{array-contents} returns that shared array, otherwise it returns
+@code{#f}. All arrays made by @code{make-array} and
+@code{make-typed-array} may be unrolled, some arrays made by
+@code{make-shared-array} may not be.
+
+If the optional argument @var{strict} is provided, a shared array will
+be returned only if its elements are stored internally contiguous in
+memory.
+@end deffn
+
+@deffn {Scheme Procedure} transpose-array array dim1 dim2 @dots{}
+@deffnx {C Function} scm_transpose_array (array, dimlist)
+Return an array sharing contents with @var{array}, but with
+dimensions arranged in a different order. There must be one
+@var{dim} argument for each dimension of @var{array}.
+@var{dim1}, @var{dim2}, @dots{} should be integers between 0
+and the rank of the array to be returned. Each integer in that
+range must appear at least once in the argument list.
+
+The values of @var{dim1}, @var{dim2}, @dots{} correspond to
+dimensions in the array to be returned, and their positions in the
+argument list to dimensions of @var{array}. Several @var{dim}s
+may have the same value, in which case the returned array will
+have smaller rank than @var{array}.
+
+@lisp
+(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d))
+(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d)
+(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{}
+ #2((a 4) (b 5) (c 6))
+@end lisp
+@end deffn
+
+@node Arrays as arrays of arrays
+@subsubsection Arrays as arrays of arrays
+
+@cindex array cell
+
+Mathematically, one can see an array of rank @math{n} (an
+@math{n}-array) as an array of lower rank where the elements are
+themselves arrays (`cells').
+
+@cindex array frame
+@cindex frame rank
+
+We speak of the first @math{n-k} dimensions of the array as the
+@math{n-k}-`frame' of the array, while the last @math{k} dimensions are
+the dimensions of the @math{k}-`cells'. For example, a 3-array can be
+seen as a 2-array of vectors (1-arrays) or as a 1-array of matrices
+(2-arrays). In each case, the vectors or matrices are the 1-cells or
+2-cells of the array. This terminology originates in the J language.
+
+@cindex array slice
+@cindex prefix slice
+
+The more vague concept of a `slice' refers to a subset of the array
+where some indices are fixed and others are left free. As a Guile data
+object, a cell is the same as a `prefix slice' (the first @math{n-k}
+indices into the original array are fixed), except that a 0-cell is not
+a shared array of the original array, but a 0-slice (where all the
+indices into the original array are fixed) is.
+
+@cindex enclosed array
+
+Before @w{version 2.0}, Guile had a feature called `enclosed arrays' to
+create special `array of arrays' objects. The functions in this section
+do not need special types; instead, the frame rank is stated in each
+function call, either implicitly or explicitly.
+
+@deffn {Scheme Procedure} array-cell-ref array idx @dots{}
+@deffnx {C Function} scm_array_cell_ref (array, idxlist)
+If the length of @var{idxlist} equals the rank @math{n} of @var{array},
+return the element at @code{(idx @dots{})}, just like @code{(array-ref
+array idx @dots{})}. If, however, the length @math{k} of @var{idxlist}
+is smaller than @math{n}, then return the @math{(n-k)}-cell of
+@var{array} given by @var{idxlist}, as a shared array.
+
+For example:
+
+@lisp
+(array-cell-ref #2((a b) (c d)) 0) @result{} #(a b)
+(array-cell-ref #2((a b) (c d)) 1) @result{} #(c d)
+(array-cell-ref #2((a b) (c d)) 1 1) @result{} d
+(array-cell-ref #2((a b) (c d))) @result{} #2((a b) (c d))
+@end lisp
+
+@code{(apply array-cell-ref array indices)} is equivalent to
+
+@lisp
+(let ((len (length indices)))
+ (if (= (array-rank a) len)
+ (apply array-ref a indices)
+ (apply make-shared-array a
+ (lambda t (append indices t))
+ (drop (array-dimensions a) len))))
+@end lisp
+
+@end deffn
+
+@deffn {Scheme Procedure} array-slice array idx @dots{}
+@deffnx {C Function} scm_array_slice (array, idxlist)
+Like @code{(array-cell-ref array idx @dots{})}, but return a 0-rank
+shared array into @var{ARRAY} if the length of @var{idxlist} matches the
+rank of @var{array}. This can be useful when using @var{ARRAY} as a
+place to write to.
+
+Compare:
+
+@lisp
+(array-cell-ref #2((a b) (c d)) 1 1) @result{} d
+(array-slice #2((a b) (c d)) 1 1) @result{} #0(d)
+(define a (make-array 'a 2 2))
+(array-fill! (array-slice a 1 1) 'b)
+a @result{} #2((a a) (a b)).
+(array-fill! (array-cell-ref a 1 1) 'b) @result{} error: not an array
+@end lisp
+
+@code{(apply array-slice array indices)} is equivalent to
+
+@lisp
+(apply make-shared-array a
+ (lambda t (append indices t))
+ (drop (array-dimensions a) (length indices)))
+@end lisp
+@end deffn
+
+
+@deffn {Scheme Procedure} array-cell-set! array x idx @dots{}
+@deffnx {C Function} scm_array_cell_set_x (array, x, idxlist)
+If the length of @var{idxlist} equals the rank @math{n} of
+@var{array}, set the element at @code{(idx @dots{})} of @var{array} to
+@var{x}, just like @code{(array-set! array x idx @dots{})}. If,
+however, the length @math{k} of @var{idxlist} is smaller than
+@math{n}, then copy the @math{(n-k)}-rank array @var{x}
+into the @math{(n-k)}-cell of @var{array} given by
+@var{idxlist}. In this case, the last @math{(n-k)} dimensions of
+@var{array} and the dimensions of @var{x} must match exactly.
+
+This function returns the modified @var{array}.
+
+For example:
+
+@lisp
+(array-cell-set! (make-array 'a 2 2) b 1 1)
+ @result{} #2((a a) (a b))
+(array-cell-set! (make-array 'a 2 2) #(x y) 1)
+ @result{} #2((a a) (x y))
+@end lisp
+
+Note that @code{array-cell-set!} will expect elements, not arrays, when
+the destination has rank 0. Use @code{array-slice} for the opposite
+behavior.
+
+@lisp
+(array-cell-set! (make-array 'a 2 2) #0(b) 1 1)
+ @result{} #2((a a) (a #0(b)))
+(let ((a (make-array 'a 2 2)))
+ (array-copy! #0(b) (array-slice a 1 1)) a)
+ @result{} #2((a a) (a b))
+@end lisp
+
+@code{(apply array-cell-set! array x indices)} is equivalent to
+
+@lisp
+(let ((len (length indices)))
+ (if (= (array-rank array) len)
+ (apply array-set! array x indices)
+ (array-copy! x (apply array-cell-ref array indices)))
+ array)
+@end lisp
+
+@end deffn
+
+
+@deffn {Scheme Procedure} array-slice-for-each frame-rank op x @dots{}
+@deffnx {C Function} scm_array_slice_for_each (array, frame_rank, op, xlist)
+Each @var{x} must be an array of rank ≥ @var{frame-rank}, and
+the first @var{frame-rank} dimensions of each @var{x} must all be the
+same. @var{array-slice-for-each} calls @var{op} with each set of
+(rank(@var{x}) - @var{frame-rank})-cells from @var{x}, in unspecified order.
+
+@var{array-slice-for-each} allows you to loop over cells of any rank
+without having to carry an index list or construct shared arrays
+manually. The slices passed to @var{op} are always shared arrays of
+@var{X}, even if they are of rank 0, so it is possible to write to them.
+
+This function returns an unspecified value.
+
+For example, to sort the rows of rank-2 array @code{a}:
+
+@lisp
+(array-slice-for-each 1 (lambda (x) (sort! x <)) a)
+@end lisp
+
+As another example, let @code{a} be a rank-2 array where each row is a
+2-element vector @math{(x,y)}. Let's compute the arguments of these
+vectors and store them in rank-1 array @code{b}.
+@lisp
+(array-slice-for-each 1
+ (lambda (a b)
+ (array-set! b (atan (array-ref a 1) (array-ref a 0))))
+ a b)
+@end lisp
+
+@code{(apply array-slice-for-each frame-rank op x)} is equivalent to
+
+@lisp
+(let ((frame (take (array-dimensions (car x)) frank)))
+ (unless (every (lambda (x)
+ (equal? frame (take (array-dimensions x) frank)))
+ (cdr x))
+ (error))
+ (array-index-map!
+ (apply make-shared-array (make-array #t) (const '()) frame)
+ (lambda i (apply op (map (lambda (x) (apply array-slice x i)) x)))))
+@end lisp
+
+@end deffn
+
+@deffn {Scheme Procedure} array-slice-for-each-in-order frame-rank op x @dots{}
+@deffnx {C Function} scm_array_slice_for_each_in_order (array, frame_rank, op, xlist)
+Same as @code{array-slice-for-each}, but the arguments are traversed
+sequentially and in row-major order.
+@end deffn
+
+@node Accessing Arrays from C
+@subsubsection Accessing Arrays from C
+
+For interworking with external C code, Guile provides an API to allow C
+code to access the elements of a Scheme array. In particular, for
+uniform numeric arrays, the API exposes the underlying uniform data as a
+C array of numbers of the relevant type.
+
+While pointers to the elements of an array are in use, the array itself
+must be protected so that the pointer remains valid. Such a protected
+array is said to be @dfn{reserved}. A reserved array can be read but
+modifications to it that would cause the pointer to its elements to
+become invalid are prevented. When you attempt such a modification, an
+error is signalled.
+
+(This is similar to locking the array while it is in use, but without
+the danger of a deadlock. In a multi-threaded program, you will need
+additional synchronization to avoid modifying reserved arrays.)
+
+You must take care to always unreserve an array after reserving it,
+even in the presence of non-local exits. If a non-local exit can
+happen between these two calls, you should install a dynwind context
+that releases the array when it is left (@pxref{Dynamic Wind}).
+
+In addition, array reserving and unreserving must be properly
+paired. For instance, when reserving two or more arrays in a certain
+order, you need to unreserve them in the opposite order.
+
+Once you have reserved an array and have retrieved the pointer to its
+elements, you must figure out the layout of the elements in memory.
+Guile allows slices to be taken out of arrays without actually making a
+copy, such as making an alias for the diagonal of a matrix that can be
+treated as a vector. Arrays that result from such an operation are not
+stored contiguously in memory and when working with their elements
+directly, you need to take this into account.
+
+The layout of array elements in memory can be defined via a
+@emph{mapping function} that computes a scalar position from a vector of
+indices. The scalar position then is the offset of the element with the
+given indices from the start of the storage block of the array.
+
+In Guile, this mapping function is restricted to be @dfn{affine}: all
+mapping functions of Guile arrays can be written as @code{p = b +
+c[0]*i[0] + c[1]*i[1] + ... + c[n-1]*i[n-1]} where @code{i[k]} is the
+@nicode{k}th index and @code{n} is the rank of the array. For
+example, a matrix of size 3x3 would have @code{b == 0}, @code{c[0] ==
+3} and @code{c[1] == 1}. When you transpose this matrix (with
+@code{transpose-array}, say), you will get an array whose mapping
+function has @code{b == 0}, @code{c[0] == 1} and @code{c[1] == 3}.
+
+The function @code{scm_array_handle_dims} gives you (indirect) access to
+the coefficients @code{c[k]}.
+
+@c XXX
+Note that there are no functions for accessing the elements of a
+character array yet. Once the string implementation of Guile has been
+changed to use Unicode, we will provide them.
+
+@deftp {C Type} scm_t_array_handle
+This is a structure type that holds all information necessary to manage
+the reservation of arrays as explained above. Structures of this type
+must be allocated on the stack and must only be accessed by the
+functions listed below.
+@end deftp
+
+@deftypefn {C Function} void scm_array_get_handle (SCM array, scm_t_array_handle *handle)
+Reserve @var{array}, which must be an array, and prepare @var{handle} to
+be used with the functions below. You must eventually call
+@code{scm_array_handle_release} on @var{handle}, and do this in a
+properly nested fashion, as explained above. The structure pointed to
+by @var{handle} does not need to be initialized before calling this
+function.
+@end deftypefn
+
+@deftypefn {C Function} void scm_array_handle_release (scm_t_array_handle *handle)
+End the array reservation represented by @var{handle}. After a call to
+this function, @var{handle} might be used for another reservation.
+@end deftypefn
+
+@deftypefn {C Function} size_t scm_array_handle_rank (scm_t_array_handle *handle)
+Return the rank of the array represented by @var{handle}.
+@end deftypefn
+
+@deftp {C Type} scm_t_array_dim
+This structure type holds information about the layout of one dimension
+of an array. It includes the following fields:
+
+@table @code
+@item ssize_t lbnd
+@itemx ssize_t ubnd
+The lower and upper bounds (both inclusive) of the permissible index
+range for the given dimension. Both values can be negative, but
+@var{lbnd} is always less than or equal to @var{ubnd}.
+
+@item ssize_t inc
+The distance from one element of this dimension to the next. Note, too,
+that this can be negative.
+@end table
+@end deftp
+
+@deftypefn {C Function} {const scm_t_array_dim *} scm_array_handle_dims (scm_t_array_handle *handle)
+Return a pointer to a C vector of information about the dimensions of
+the array represented by @var{handle}. This pointer is valid as long as
+the array remains reserved. As explained above, the
+@code{scm_t_array_dim} structures returned by this function can be used
+calculate the position of an element in the storage block of the array
+from its indices.
+
+This position can then be used as an index into the C array pointer
+returned by the various @code{scm_array_handle__elements}
+functions, or with @code{scm_array_handle_ref} and
+@code{scm_array_handle_set}.
+
+Here is how one can compute the position @var{pos} of an element given
+its indices in the vector @var{indices}:
+
+@example
+ssize_t indices[RANK];
+scm_t_array_dim *dims;
+ssize_t pos;
+size_t i;
+
+pos = 0;
+for (i = 0; i < RANK; i++)
+ @{
+ if (indices[i] < dims[i].lbnd || indices[i] > dims[i].ubnd)
+ out_of_range ();
+ pos += (indices[i] - dims[i].lbnd) * dims[i].inc;
+ @}
+@end example
+@end deftypefn
+
+@deftypefn {C Function} ssize_t scm_array_handle_pos (scm_t_array_handle *handle, SCM indices)
+Compute the position corresponding to @var{indices}, a list of
+indices. The position is computed as described above for
+@code{scm_array_handle_dims}. The number of the indices and their
+range is checked and an appropriate error is signalled for invalid
+indices.
+@end deftypefn
+
+@deftypefn {C Function} SCM scm_array_handle_ref (scm_t_array_handle *handle, ssize_t pos)
+Return the element at position @var{pos} in the storage block of the
+array represented by @var{handle}. Any kind of array is acceptable. No
+range checking is done on @var{pos}.
+@end deftypefn
+
+@deftypefn {C Function} void scm_array_handle_set (scm_t_array_handle *handle, ssize_t pos, SCM val)
+Set the element at position @var{pos} in the storage block of the array
+represented by @var{handle} to @var{val}. Any kind of array is
+acceptable. No range checking is done on @var{pos}. An error is
+signalled when the array can not store @var{val}.
+@end deftypefn
+
+@deftypefn {C Function} {const SCM *} scm_array_handle_elements (scm_t_array_handle *handle)
+Return a pointer to the elements of a ordinary array of general Scheme
+values (i.e., a non-uniform array) for reading. This pointer is valid
+as long as the array remains reserved.
+@end deftypefn
+
+@deftypefn {C Function} {SCM *} scm_array_handle_writable_elements (scm_t_array_handle *handle)
+Like @code{scm_array_handle_elements}, but the pointer is good for
+reading and writing.
+@end deftypefn
+
+@deftypefn {C Function} {const void *} scm_array_handle_uniform_elements (scm_t_array_handle *handle)
+Return a pointer to the elements of a uniform numeric array for reading.
+This pointer is valid as long as the array remains reserved. The size
+of each element is given by @code{scm_array_handle_uniform_element_size}.
+@end deftypefn
+
+@deftypefn {C Function} {void *} scm_array_handle_uniform_writable_elements (scm_t_array_handle *handle)
+Like @code{scm_array_handle_uniform_elements}, but the pointer is good
+reading and writing.
+@end deftypefn
+
+@deftypefn {C Function} size_t scm_array_handle_uniform_element_size (scm_t_array_handle *handle)
+Return the size of one element of the uniform numeric array represented
+by @var{handle}.
+@end deftypefn
+
+@deftypefn {C Function} {const scm_t_uint8 *} scm_array_handle_u8_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_int8 *} scm_array_handle_s8_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_uint16 *} scm_array_handle_u16_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_int16 *} scm_array_handle_s16_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_uint32 *} scm_array_handle_u32_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_int32 *} scm_array_handle_s32_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_uint64 *} scm_array_handle_u64_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const scm_t_int64 *} scm_array_handle_s64_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const float *} scm_array_handle_f32_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const double *} scm_array_handle_f64_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const float *} scm_array_handle_c32_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {const double *} scm_array_handle_c64_elements (scm_t_array_handle *handle)
+Return a pointer to the elements of a uniform numeric array of the
+indicated kind for reading. This pointer is valid as long as the array
+remains reserved.
+
+The pointers for @code{c32} and @code{c64} uniform numeric arrays point
+to pairs of floating point numbers. The even index holds the real part,
+the odd index the imaginary part of the complex number.
+@end deftypefn
+
+@deftypefn {C Function} {scm_t_uint8 *} scm_array_handle_u8_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_int8 *} scm_array_handle_s8_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_uint16 *} scm_array_handle_u16_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_int16 *} scm_array_handle_s16_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_uint32 *} scm_array_handle_u32_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_int32 *} scm_array_handle_s32_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_uint64 *} scm_array_handle_u64_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {scm_t_int64 *} scm_array_handle_s64_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {float *} scm_array_handle_f32_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {double *} scm_array_handle_f64_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {float *} scm_array_handle_c32_writable_elements (scm_t_array_handle *handle)
+@deftypefnx {C Function} {double *} scm_array_handle_c64_writable_elements (scm_t_array_handle *handle)
+Like @code{scm_array_handle__elements}, but the pointer is good
+for reading and writing.
+@end deftypefn
+
+@deftypefn {C Function} {const scm_t_uint32 *} scm_array_handle_bit_elements (scm_t_array_handle *handle)
+Return a pointer to the words that store the bits of the represented
+array, which must be a bit array.
+
+Unlike other arrays, bit arrays have an additional offset that must be
+figured into index calculations. That offset is returned by
+@code{scm_array_handle_bit_elements_offset}.
+
+To find a certain bit you first need to calculate its position as
+explained above for @code{scm_array_handle_dims} and then add the
+offset. This gives the absolute position of the bit, which is always a
+non-negative integer.
+
+Each word of the bit array storage block contains exactly 32 bits, with
+the least significant bit in that word having the lowest absolute
+position number. The next word contains the next 32 bits.
+
+Thus, the following code can be used to access a bit whose position
+according to @code{scm_array_handle_dims} is given in @var{pos}:
+
+@example
+SCM bit_array;
+scm_t_array_handle handle;
+scm_t_uint32 *bits;
+ssize_t pos;
+size_t abs_pos;
+size_t word_pos, mask;
+
+scm_array_get_handle (&bit_array, &handle);
+bits = scm_array_handle_bit_elements (&handle);
+
+pos = ...
+abs_pos = pos + scm_array_handle_bit_elements_offset (&handle);
+word_pos = abs_pos / 32;
+mask = 1L << (abs_pos % 32);
+
+if (bits[word_pos] & mask)
+ /* bit is set. */
+
+scm_array_handle_release (&handle);
+@end example
+
+@end deftypefn
+
+@deftypefn {C Function} {scm_t_uint32 *} scm_array_handle_bit_writable_elements (scm_t_array_handle *handle)
+Like @code{scm_array_handle_bit_elements} but the pointer is good for
+reading and writing. You must take care not to modify bits outside of
+the allowed index range of the array, even for contiguous arrays.
+@end deftypefn
+
+@node VLists
+@subsection VLists
+
+@cindex vlist
+
+The @code{(ice-9 vlist)} module provides an implementation of the @dfn{VList}
+data structure designed by Phil Bagwell in 2002. VLists are immutable lists,
+which can contain any Scheme object. They improve on standard Scheme linked
+lists in several areas:
+
+@itemize
+@item
+Random access has typically constant-time complexity.
+
+@item
+Computing the length of a VList has time complexity logarithmic in the number of
+elements.
+
+@item
+VLists use less storage space than standard lists.
+
+@item
+VList elements are stored in contiguous regions, which improves memory locality
+and leads to more efficient use of hardware caches.
+@end itemize
+
+The idea behind VLists is to store vlist elements in increasingly large
+contiguous blocks (implemented as vectors here). These blocks are linked to one
+another using a pointer to the next block and an offset within that block. The
+size of these blocks form a geometric series with ratio
+@code{block-growth-factor} (2 by default).
+
+The VList structure also serves as the basis for the @dfn{VList-based hash
+lists} or ``vhashes'', an immutable dictionary type (@pxref{VHashes}).
+
+However, the current implementation in @code{(ice-9 vlist)} has several
+noteworthy shortcomings:
+
+@itemize
+
+@item
+It is @emph{not} thread-safe. Although operations on vlists are all
+@dfn{referentially transparent} (i.e., purely functional), adding elements to a
+vlist with @code{vlist-cons} mutates part of its internal structure, which makes
+it non-thread-safe. This could be fixed, but it would slow down
+@code{vlist-cons}.
+
+@item
+@code{vlist-cons} always allocates at least as much memory as @code{cons}.
+Again, Phil Bagwell describes how to fix it, but that would require tuning the
+garbage collector in a way that may not be generally beneficial.
+
+@item
+@code{vlist-cons} is a Scheme procedure compiled to bytecode, and it does not
+compete with the straightforward C implementation of @code{cons}, and with the
+fact that the VM has a special @code{cons} instruction.
+
+@end itemize
+
+We hope to address these in the future.
+
+The programming interface exported by @code{(ice-9 vlist)} is defined below.
+Most of it is the same as SRFI-1 with an added @code{vlist-} prefix to function
+names.
+
+@deffn {Scheme Procedure} vlist? obj
+Return true if @var{obj} is a VList.
+@end deffn
+
+@defvr {Scheme Variable} vlist-null
+The empty VList. Note that it's possible to create an empty VList not
+@code{eq?} to @code{vlist-null}; thus, callers should always use
+@code{vlist-null?} when testing whether a VList is empty.
+@end defvr
+
+@deffn {Scheme Procedure} vlist-null? vlist
+Return true if @var{vlist} is empty.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-cons item vlist
+Return a new vlist with @var{item} as its head and @var{vlist} as its tail.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-head vlist
+Return the head of @var{vlist}.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-tail vlist
+Return the tail of @var{vlist}.
+@end deffn
+
+@defvr {Scheme Variable} block-growth-factor
+A fluid that defines the growth factor of VList blocks, 2 by default.
+@end defvr
+
+The functions below provide the usual set of higher-level list operations.
+
+@deffn {Scheme Procedure} vlist-fold proc init vlist
+@deffnx {Scheme Procedure} vlist-fold-right proc init vlist
+Fold over @var{vlist}, calling @var{proc} for each element, as for SRFI-1
+@code{fold} and @code{fold-right} (@pxref{SRFI-1, @code{fold}}).
+@end deffn
+
+@deffn {Scheme Procedure} vlist-ref vlist index
+Return the element at index @var{index} in @var{vlist}. This is typically a
+constant-time operation.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-length vlist
+Return the length of @var{vlist}. This is typically logarithmic in the number
+of elements in @var{vlist}.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-reverse vlist
+Return a new @var{vlist} whose content are those of @var{vlist} in reverse
+order.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-map proc vlist
+Map @var{proc} over the elements of @var{vlist} and return a new vlist.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-for-each proc vlist
+Call @var{proc} on each element of @var{vlist}. The result is unspecified.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-drop vlist count
+Return a new vlist that does not contain the @var{count} first elements of
+@var{vlist}. This is typically a constant-time operation.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-take vlist count
+Return a new vlist that contains only the @var{count} first elements of
+@var{vlist}.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-filter pred vlist
+Return a new vlist containing all the elements from @var{vlist} that satisfy
+@var{pred}.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-delete x vlist [equal?]
+Return a new vlist corresponding to @var{vlist} without the elements
+@var{equal?} to @var{x}.
+@end deffn
+
+@deffn {Scheme Procedure} vlist-unfold p f g seed [tail-gen]
+@deffnx {Scheme Procedure} vlist-unfold-right p f g seed [tail]
+Return a new vlist, as for SRFI-1 @code{unfold} and @code{unfold-right}
+(@pxref{SRFI-1, @code{unfold}}).
+@end deffn
+
+@deffn {Scheme Procedure} vlist-append vlist @dots{}
+Append the given vlists and return the resulting vlist.
+@end deffn
+
+@deffn {Scheme Procedure} list->vlist lst
+Return a new vlist whose contents correspond to @var{lst}.
+@end deffn
+
+@deffn {Scheme Procedure} vlist->list vlist
+Return a new list whose contents match those of @var{vlist}.
+@end deffn
+
+@node Record Overview
+@subsection Record Overview
+
+@cindex record
+@cindex structure
+
+@dfn{Records}, also called @dfn{structures}, are Scheme's primary
+mechanism to define new disjoint types. A @dfn{record type} defines a
+list of @dfn{fields} that instances of the type consist of. This is like
+C's @code{struct}.
+
+Historically, Guile has offered several different ways to define record
+types and to create records, offering different features, and making
+different trade-offs. Over the years, each ``standard'' has also come
+with its own new record interface, leading to a maze of record APIs.
+
+At the highest level is SRFI-9, a high-level record interface
+implemented by most Scheme implementations (@pxref{SRFI-9 Records}). It
+defines a simple and efficient syntactic abstraction of record types and
+their associated type predicate, fields, and field accessors. SRFI-9 is
+suitable for most uses, and this is the recommended way to create record
+types in Guile. Similar high-level record APIs include SRFI-35
+(@pxref{SRFI-35}) and R6RS records (@pxref{rnrs records syntactic}).
+
+Then comes Guile's historical ``records'' API (@pxref{Records}). Record
+types defined this way are first-class objects. Introspection
+facilities are available, allowing users to query the list of fields or
+the value of a specific field at run-time, without prior knowledge of
+the type.
+
+Finally, the common denominator of these interfaces is Guile's
+@dfn{structure} API (@pxref{Structures}). Guile's structures are the
+low-level building block for all other record APIs. Application writers
+will normally not need to use it.
+
+Records created with these APIs may all be pattern-matched using Guile's
+standard pattern matcher (@pxref{Pattern Matching}).
+
+
+@node SRFI-9 Records
+@subsection SRFI-9 Records
+
+@cindex SRFI-9
+@cindex record
+
+SRFI-9 standardizes a syntax for defining new record types and creating
+predicate, constructor, and field getter and setter functions. In Guile
+this is the recommended option to create new record types (@pxref{Record
+Overview}). It can be used with:
+
+@example
+(use-modules (srfi srfi-9))
+@end example
+
+@deffn {Scheme Syntax} define-record-type type @* (constructor fieldname @dots{}) @* predicate @* (fieldname accessor [modifier]) @dots{}
+@sp 1
+Create a new record type, and make various @code{define}s for using
+it. This syntax can only occur at the top-level, not nested within
+some other form.
+
+@var{type} is bound to the record type, which is as per the return
+from the core @code{make-record-type}. @var{type} also provides the
+name for the record, as per @code{record-type-name}.
+
+@var{constructor} is bound to a function to be called as
+@code{(@var{constructor} fieldval @dots{})} to create a new record of
+this type. The arguments are initial values for the fields, one
+argument for each field, in the order they appear in the
+@code{define-record-type} form.
+
+The @var{fieldname}s provide the names for the record fields, as per
+the core @code{record-type-fields} etc, and are referred to in the
+subsequent accessor/modifier forms.
+
+@var{predicate} is bound to a function to be called as
+@code{(@var{predicate} obj)}. It returns @code{#t} or @code{#f}
+according to whether @var{obj} is a record of this type.
+
+Each @var{accessor} is bound to a function to be called
+@code{(@var{accessor} record)} to retrieve the respective field from a
+@var{record}. Similarly each @var{modifier} is bound to a function to
+be called @code{(@var{modifier} record val)} to set the respective
+field in a @var{record}.
+@end deffn
+
+@noindent
+An example will illustrate typical usage,
+
+@example
+(define-record-type
+ (make-employee name age salary)
+ employee?
+ (name employee-name)
+ (age employee-age set-employee-age!)
+ (salary employee-salary set-employee-salary!))
+@end example
+
+This creates a new employee data type, with name, age and salary
+fields. Accessor functions are created for each field, but no
+modifier function for the name (the intention in this example being
+that it's established only when an employee object is created). These
+can all then be used as for example,
+
+@example
+ @result{} #>
+
+(define fred (make-employee "Fred" 45 20000.00))
+
+(employee? fred) @result{} #t
+(employee-age fred) @result{} 45
+(set-employee-salary! fred 25000.00) ;; pay rise
+@end example
+
+The functions created by @code{define-record-type} are ordinary
+top-level @code{define}s. They can be redefined or @code{set!} as
+desired, exported from a module, etc.
+
+@unnumberedsubsubsec Non-toplevel Record Definitions
+
+The SRFI-9 specification explicitly disallows record definitions in a
+non-toplevel context, such as inside @code{lambda} body or inside a
+@var{let} block. However, Guile's implementation does not enforce that
+restriction.
+
+@unnumberedsubsubsec Custom Printers
+
+You may use @code{set-record-type-printer!} to customize the default printing
+behavior of records. This is a Guile extension and is not part of SRFI-9. It
+is located in the @nicode{(srfi srfi-9 gnu)} module.
+
+@deffn {Scheme Syntax} set-record-type-printer! type proc
+Where @var{type} corresponds to the first argument of @code{define-record-type},
+and @var{proc} is a procedure accepting two arguments, the record to print, and
+an output port.
+@end deffn
+
+@noindent
+This example prints the employee's name in brackets, for instance @code{[Fred]}.
+
+@example
+(set-record-type-printer!
+ (lambda (record port)
+ (write-char #\[ port)
+ (display (employee-name record) port)
+ (write-char #\] port)))
+@end example
+
+@unnumberedsubsubsec Functional ``Setters''
+
+@cindex functional setters
+
+When writing code in a functional style, it is desirable to never alter
+the contents of records. For such code, a simple way to return new
+record instances based on existing ones is highly desirable.
+
+The @code{(srfi srfi-9 gnu)} module extends SRFI-9 with facilities to
+return new record instances based on existing ones, only with one or
+more field values changed---@dfn{functional setters}. First, the
+@code{define-immutable-record-type} works like
+@code{define-record-type}, except that fields are immutable and setters
+are defined as functional setters.
+
+@deffn {Scheme Syntax} define-immutable-record-type type @* (constructor fieldname @dots{}) @* predicate @* (fieldname accessor [modifier]) @dots{}
+Define @var{type} as a new record type, like @code{define-record-type}.
+However, the record type is made @emph{immutable} (records may not be
+mutated, even with @code{struct-set!}), and any @var{modifier} is
+defined to be a functional setter---a procedure that returns a new
+record instance with the specified field changed, and leaves the
+original unchanged (see example below.)
+@end deffn
+
+@noindent
+In addition, the generic @code{set-field} and @code{set-fields} macros
+may be applied to any SRFI-9 record.
+
+@deffn {Scheme Syntax} set-field record (field sub-fields ...) value
+Return a new record of @var{record}'s type whose fields are equal to
+the corresponding fields of @var{record} except for the one specified by
+@var{field}.
+
+@var{field} must be the name of the getter corresponding to the field of
+@var{record} being ``set''. Subsequent @var{sub-fields} must be record
+getters designating sub-fields within that field value to be set (see
+example below.)
+@end deffn
+
+@deffn {Scheme Syntax} set-fields record ((field sub-fields ...) value) ...
+Like @code{set-field}, but can be used to set more than one field at a
+time. This expands to code that is more efficient than a series of
+single @code{set-field} calls.
+@end deffn
+
+To illustrate the use of functional setters, let's assume these two
+record type definitions:
+
+@example
+(define-record-type
+ (address street city country)
+ address?
+ (street address-street)
+ (city address-city)
+ (country address-country))
+
+(define-immutable-record-type
+ (person age email address)
+ person?
+ (age person-age set-person-age)
+ (email person-email set-person-email)
+ (address person-address set-person-address))
+@end example
+
+@noindent
+First, note that the @code{} record type definition introduces
+named functional setters. These may be used like this:
+
+@example
+(define fsf-address
+ (address "Franklin Street" "Boston" "USA"))
+
+(define rms
+ (person 30 "rms@@gnu.org" fsf-address))
+
+(and (equal? (set-person-age rms 60)
+ (person 60 "rms@@gnu.org" fsf-address))
+ (= (person-age rms) 30))
+@result{} #t
+@end example
+
+@noindent
+Here, the original @code{} record, to which @var{rms} is bound,
+is left unchanged.
+
+Now, suppose we want to change both the street and age of @var{rms}.
+This can be achieved using @code{set-fields}:
+
+@example
+(set-fields rms
+ ((person-age) 60)
+ ((person-address address-street) "Temple Place"))
+@result{} #< age: 60 email: "rms@@gnu.org"
+ address: #< street: "Temple Place" city: "Boston" country: "USA">>
+@end example
+
+@noindent
+Notice how the above changed two fields of @var{rms}, including the
+@code{street} field of its @code{address} field, in a concise way. Also
+note that @code{set-fields} works equally well for types defined with
+just @code{define-record-type}.
+
+@node Records
+@subsection Records
+
+A @dfn{record type} is a first class object representing a user-defined
+data type. A @dfn{record} is an instance of a record type.
+
+Note that in many ways, this interface is too low-level for every-day
+use. Most uses of records are better served by SRFI-9 records.
+@xref{SRFI-9 Records}.
+
+@deffn {Scheme Procedure} record? obj
+Return @code{#t} if @var{obj} is a record of any type and @code{#f}
+otherwise.
+
+Note that @code{record?} may be true of any Scheme value; there is no
+promise that records are disjoint with other Scheme types.
+@end deffn
+
+@deffn {Scheme Procedure} make-record-type type-name field-names [print]
+Create and return a new @dfn{record-type descriptor}.
+
+@var{type-name} is a string naming the type. Currently it's only used
+in the printed representation of records, and in diagnostics.
+@var{field-names} is a list of symbols naming the fields of a record
+of the type. Duplicates are not allowed among these symbols.
+
+@example
+(make-record-type "employee" '(name age salary))
+@end example
+
+The optional @var{print} argument is a function used by
+@code{display}, @code{write}, etc, for printing a record of the new
+type. It's called as @code{(@var{print} record port)} and should look
+at @var{record} and write to @var{port}.
+@end deffn
+
+@deffn {Scheme Procedure} record-constructor rtd [field-names]
+Return a procedure for constructing new members of the type represented
+by @var{rtd}. The returned procedure accepts exactly as many arguments
+as there are symbols in the given list, @var{field-names}; these are
+used, in order, as the initial values of those fields in a new record,
+which is returned by the constructor procedure. The values of any
+fields not named in that list are unspecified. The @var{field-names}
+argument defaults to the list of field names in the call to
+@code{make-record-type} that created the type represented by @var{rtd};
+if the @var{field-names} argument is provided, it is an error if it
+contains any duplicates or any symbols not in the default list.
+@end deffn
+
+@deffn {Scheme Procedure} record-predicate rtd
+Return a procedure for testing membership in the type represented by
+@var{rtd}. The returned procedure accepts exactly one argument and
+returns a true value if the argument is a member of the indicated record
+type; it returns a false value otherwise.
+@end deffn
+
+@deffn {Scheme Procedure} record-accessor rtd field-name
+Return a procedure for reading the value of a particular field of a
+member of the type represented by @var{rtd}. The returned procedure
+accepts exactly one argument which must be a record of the appropriate
+type; it returns the current value of the field named by the symbol
+@var{field-name} in that record. The symbol @var{field-name} must be a
+member of the list of field-names in the call to @code{make-record-type}
+that created the type represented by @var{rtd}.
+@end deffn
+
+@deffn {Scheme Procedure} record-modifier rtd field-name
+Return a procedure for writing the value of a particular field of a
+member of the type represented by @var{rtd}. The returned procedure
+accepts exactly two arguments: first, a record of the appropriate type,
+and second, an arbitrary Scheme value; it modifies the field named by
+the symbol @var{field-name} in that record to contain the given value.
+The returned value of the modifier procedure is unspecified. The symbol
+@var{field-name} must be a member of the list of field-names in the call
+to @code{make-record-type} that created the type represented by
+@var{rtd}.
+@end deffn
+
+@deffn {Scheme Procedure} record-type-descriptor record
+Return a record-type descriptor representing the type of the given
+record. That is, for example, if the returned descriptor were passed to
+@code{record-predicate}, the resulting predicate would return a true
+value when passed the given record. Note that it is not necessarily the
+case that the returned descriptor is the one that was passed to
+@code{record-constructor} in the call that created the constructor
+procedure that created the given record.
+@end deffn
+
+@deffn {Scheme Procedure} record-type-name rtd
+Return the type-name associated with the type represented by rtd. The
+returned value is @code{eqv?} to the @var{type-name} argument given in
+the call to @code{make-record-type} that created the type represented by
+@var{rtd}.
+@end deffn
+
+@deffn {Scheme Procedure} record-type-fields rtd
+Return a list of the symbols naming the fields in members of the type
+represented by @var{rtd}. The returned value is @code{equal?} to the
+field-names argument given in the call to @code{make-record-type} that
+created the type represented by @var{rtd}.
+@end deffn
+
+
+@node Structures
+@subsection Structures
+@tpindex Structures
+
+A @dfn{structure} is a first class data type which holds Scheme values
+or C words in fields numbered 0 upwards. A @dfn{vtable} is a structure
+that represents a structure type, giving field types and permissions,
+and an optional print function for @code{write} etc.
+
+Structures are lower level than records (@pxref{Records}). Usually,
+when you need to represent structured data, you just want to use
+records. But sometimes you need to implement new kinds of structured
+data abstractions, and for that purpose structures are useful. Indeed,
+records in Guile are implemented with structures.
+
+@menu
+* Vtables::
+* Structure Basics::
+* Vtable Contents::
+* Meta-Vtables::
+* Vtable Example::
+* Tail Arrays::
+@end menu
+
+@node Vtables
+@subsubsection Vtables
+
+A vtable is a structure type, specifying its layout, and other
+information. A vtable is actually itself a structure, but there's no
+need to worry about that initially (@pxref{Vtable Contents}.)
+
+@deffn {Scheme Procedure} make-vtable fields [print]
+Create a new vtable.
+
+@var{fields} is a string describing the fields in the structures to be
+created. Each field is represented by two characters, a type letter
+and a permissions letter, for example @code{"pw"}. The types are as
+follows.
+
+@itemize @bullet{}
+@item
+@code{p} -- a Scheme value. ``p'' stands for ``protected'' meaning
+it's protected against garbage collection.
+
+@item
+@code{u} -- an arbitrary word of data (an @code{scm_t_bits}). At the
+Scheme level it's read and written as an unsigned integer. ``u''
+stands for ``uninterpreted'' (it's not treated as a Scheme value), or
+``unprotected'' (it's not marked during GC), or ``unsigned long'' (its
+size), or all of these things.
+
+@item
+@code{s} -- a self-reference. Such a field holds the @code{SCM} value
+of the structure itself (a circular reference). This can be useful in
+C code where you might have a pointer to the data array, and want to
+get the Scheme @code{SCM} handle for the structure. In Scheme code it
+has no use.
+@end itemize
+
+The second letter for each field is a permission code,
+
+@itemize @bullet{}
+@item
+@code{w} -- writable, the field can be read and written.
+@item
+@code{r} -- read-only, the field can be read but not written.
+@item
+@code{o} -- opaque, the field can be neither read nor written at the
+Scheme level. This can be used for fields which should only be used
+from C code.
+@end itemize
+
+Here are some examples. @xref{Tail Arrays}, for information on the
+legacy tail array facility.
+
+@example
+(make-vtable "pw") ;; one writable field
+(make-vtable "prpw") ;; one read-only and one writable
+(make-vtable "pwuwuw") ;; one scheme and two uninterpreted
+@end example
+
+The optional @var{print} argument is a function called by
+@code{display} and @code{write} (etc) to give a printed representation
+of a structure created from this vtable. It's called
+@code{(@var{print} struct port)} and should look at @var{struct} and
+write to @var{port}. The default print merely gives a form like
+@samp{#} with a pair of machine addresses.
+
+The following print function for example shows the two fields of its
+structure.
+
+@example
+(make-vtable "prpw"
+ (lambda (struct port)
+ (format port "#<~a and ~a>"
+ (struct-ref struct 0)
+ (struct-ref struct 1))))
+@end example
+@end deffn
+
+
+@node Structure Basics
+@subsubsection Structure Basics
+
+This section describes the basic procedures for working with
+structures. @code{make-struct} creates a structure, and
+@code{struct-ref} and @code{struct-set!} access its fields.
+
+@deffn {Scheme Procedure} make-struct vtable tail-size init @dots{}
+@deffnx {Scheme Procedure} make-struct/no-tail vtable init @dots{}
+Create a new structure, with layout per the given @var{vtable}
+(@pxref{Vtables}).
+
+The optional @var{init}@dots{} arguments are initial values for the
+fields of the structure. This is the only way to
+put values in read-only fields. If there are fewer @var{init}
+arguments than fields then the defaults are @code{#f} for a Scheme
+field (type @code{p}) or 0 for an uninterpreted field (type @code{u}).
+
+Structures also have the ability to allocate a variable number of
+additional cells at the end, at their tails. However, this legacy
+@dfn{tail array} facilty is confusing and inefficient, and so we do not
+recommend it. @xref{Tail Arrays}, for more on the legacy tail array
+interface.
+
+Type @code{s} self-reference fields, permission @code{o} opaque
+fields, and the count field of a tail array are all ignored for the
+@var{init} arguments, ie.@: an argument is not consumed by such a
+field. An @code{s} is always set to the structure itself, an @code{o}
+is always set to @code{#f} or 0 (with the intention that C code will
+do something to it later), and the tail count is always the given
+@var{tail-size}.
+
+For example,
+
+@example
+(define v (make-vtable "prpwpw"))
+(define s (make-struct v 0 123 "abc" 456))
+(struct-ref s 0) @result{} 123
+(struct-ref s 1) @result{} "abc"
+@end example
+@end deffn
+
+@deftypefn {C Function} SCM scm_make_struct (SCM vtable, SCM tail_size, SCM init_list)
+@deftypefnx {C Function} SCM scm_c_make_struct (SCM vtable, SCM tail_size, SCM init, ...)
+@deftypefnx {C Function} SCM scm_c_make_structv (SCM vtable, SCM tail_size, size_t n_inits, scm_t_bits init[])
+There are a few ways to make structures from C. @code{scm_make_struct}
+takes a list, @code{scm_c_make_struct} takes variable arguments
+terminated with SCM_UNDEFINED, and @code{scm_c_make_structv} takes a
+packed array.
+@end deftypefn
+
+@deffn {Scheme Procedure} struct? obj
+@deffnx {C Function} scm_struct_p (obj)
+Return @code{#t} if @var{obj} is a structure, or @code{#f} if not.
+@end deffn
+
+@deffn {Scheme Procedure} struct-ref struct n
+@deffnx {C Function} scm_struct_ref (struct, n)
+Return the contents of field number @var{n} in @var{struct}. The
+first field is number 0.
+
+An error is thrown if @var{n} is out of range, or if the field cannot
+be read because it's @code{o} opaque.
+@end deffn
+
+@deffn {Scheme Procedure} struct-set! struct n value
+@deffnx {C Function} scm_struct_set_x (struct, n, value)
+Set field number @var{n} in @var{struct} to @var{value}. The first
+field is number 0.
+
+An error is thrown if @var{n} is out of range, or if the field cannot
+be written because it's @code{r} read-only or @code{o} opaque.
+@end deffn
+
+@deffn {Scheme Procedure} struct-vtable struct
+@deffnx {C Function} scm_struct_vtable (struct)
+Return the vtable that describes @var{struct}.
+
+The vtable is effectively the type of the structure. See @ref{Vtable
+Contents}, for more on vtables.
+@end deffn
+
+
+@node Vtable Contents
+@subsubsection Vtable Contents
+
+A vtable is itself a structure. It has a specific set of fields
+describing various aspects of its @dfn{instances}: the structures
+created from a vtable. Some of the fields are internal to Guile, some
+of them are part of the public interface, and there may be additional
+fields added on by the user.
+
+Every vtable has a field for the layout of their instances, a field for
+the procedure used to print its instances, and a field for the name of
+the vtable itself. Access to the layout and printer is exposed directly
+via field indexes. Access to the vtable name is exposed via accessor
+procedures.
+
+@defvr {Scheme Variable} vtable-index-layout
+@defvrx {C Macro} scm_vtable_index_layout
+The field number of the layout specification in a vtable. The layout
+specification is a symbol like @code{pwpw} formed from the fields
+string passed to @code{make-vtable}, or created by
+@code{make-struct-layout} (@pxref{Meta-Vtables}).
+
+@example
+(define v (make-vtable "pwpw" 0))
+(struct-ref v vtable-index-layout) @result{} pwpw
+@end example
+
+This field is read-only, since the layout of structures using a vtable
+cannot be changed.
+@end defvr
+
+@defvr {Scheme Variable} vtable-index-printer
+@defvrx {C Macro} scm_vtable_index_printer
+The field number of the printer function. This field contains @code{#f}
+if the default print function should be used.
+
+@example
+(define (my-print-func struct port)
+ ...)
+(define v (make-vtable "pwpw" my-print-func))
+(struct-ref v vtable-index-printer) @result{} my-print-func
+@end example
+
+This field is writable, allowing the print function to be changed
+dynamically.
+@end defvr
+
+@deffn {Scheme Procedure} struct-vtable-name vtable
+@deffnx {Scheme Procedure} set-struct-vtable-name! vtable name
+@deffnx {C Function} scm_struct_vtable_name (vtable)
+@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name)
+Get or set the name of @var{vtable}. @var{name} is a symbol and is
+used in the default print function when printing structures created
+from @var{vtable}.
+
+@example
+(define v (make-vtable "pw"))
+(set-struct-vtable-name! v 'my-name)
+
+(define s (make-struct v 0))
+(display s) @print{} #
+@end example
+@end deffn
+
+
+@node Meta-Vtables
+@subsubsection Meta-Vtables
+
+As a structure, a vtable also has a vtable, which is also a structure.
+Structures, their vtables, the vtables of the vtables, and so on form a
+tree of structures. Making a new structure adds a leaf to the tree, and
+if that structure is a vtable, it may be used to create other leaves.
+
+If you traverse up the tree of vtables, via calling
+@code{struct-vtable}, eventually you reach a root which is the vtable of
+itself:
+
+@example
+scheme@@(guile-user)> (current-module)
+$1 = #
+scheme@@(guile-user)> (struct-vtable $1)
+$2 = #
+scheme@@(guile-user)> (struct-vtable $2)
+$3 = #< 12c30a0>
+scheme@@(guile-user)> (struct-vtable $3)
+$4 = #< 12c3fa0>
+scheme@@(guile-user)> (struct-vtable $4)
+$5 = #< 12c3fa0>
+scheme@@(guile-user)>
+$6 = #< 12c3fa0>
+@end example
+
+In this example, we can say that @code{$1} is an instance of @code{$2},
+@code{$2} is an instance of @code{$3}, @code{$3} is an instance of
+@code{$4}, and @code{$4}, strangely enough, is an instance of itself.
+The value bound to @code{$4} in this console session also bound to
+@code{} in the default environment.
+
+@defvr {Scheme Variable}
+A meta-vtable, useful for making new vtables.
+@end defvr
+
+All of these values are structures. All but @code{$1} are vtables. As
+@code{$2} is an instance of @code{$3}, and @code{$3} is a vtable, we can
+say that @code{$3} is a @dfn{meta-vtable}: a vtable that can create
+vtables.
+
+With this definition, we can specify more precisely what a vtable is: a
+vtable is a structure made from a meta-vtable. Making a structure from
+a meta-vtable runs some special checks to ensure that the first field of
+the structure is a valid layout. Additionally, if these checks see that
+the layout of the child vtable contains all the required fields of a
+vtable, in the correct order, then the child vtable will also be a
+meta-table, inheriting a magical bit from the parent.
+
+@deffn {Scheme Procedure} struct-vtable? obj
+@deffnx {C Function} scm_struct_vtable_p (obj)
+Return @code{#t} if @var{obj} is a vtable structure: an instance of a
+meta-vtable.
+@end deffn
+
+@code{} is a root of the vtable tree. (Normally there
+is only one root in a given Guile process, but due to some legacy
+interfaces there may be more than one.)
+
+The set of required fields of a vtable is the set of fields in the
+@code{}, and is bound to @code{standard-vtable-fields}
+in the default environment. It is possible to create a meta-vtable that
+with additional fields in its layout, which can be used to create
+vtables with additional data:
+
+@example
+scheme@@(guile-user)> (struct-ref $3 vtable-index-layout)
+$6 = pruhsruhpwphuhuhprprpw
+scheme@@(guile-user)> (struct-ref $4 vtable-index-layout)
+$7 = pruhsruhpwphuhuh
+scheme@@(guile-user)> standard-vtable-fields
+$8 = "pruhsruhpwphuhuh"
+scheme@@(guile-user)> (struct-ref $2 vtable-offset-user)
+$9 = module
+@end example
+
+In this continuation of our earlier example, @code{$2} is a vtable that
+has extra fields, because its vtable, @code{$3}, was made from a
+meta-vtable with an extended layout. @code{vtable-offset-user} is a
+convenient definition that indicates the number of fields in
+@code{standard-vtable-fields}.
+
+@defvr {Scheme Variable} standard-vtable-fields
+A string containing the ordered set of fields that a vtable must have.
+@end defvr
+
+@defvr {Scheme Variable} vtable-offset-user
+The first index in a vtable that is available for a user.
+@end defvr
+
+@deffn {Scheme Procedure} make-struct-layout fields
+@deffnx {C Function} scm_make_struct_layout (fields)
+Return a structure layout symbol, from a @var{fields} string.
+@var{fields} is as described under @code{make-vtable}
+(@pxref{Vtables}). An invalid @var{fields} string is an error.
+@end deffn
+
+With these definitions, one can define @code{make-vtable} in this way:
+
+@example
+(define* (make-vtable fields #:optional printer)
+ (make-struct/no-tail
+ (make-struct-layout fields)
+ printer))
+@end example
+
+
+@node Vtable Example
+@subsubsection Vtable Example
+
+Let us bring these points together with an example. Consider a simple
+object system with single inheritance. Objects will be normal
+structures, and classes will be vtables with three extra class fields:
+the name of the class, the parent class, and the list of fields.
+
+So, first we need a meta-vtable that allocates instances with these
+extra class fields.
+
+@example
+(define
+ (make-vtable
+ (string-append standard-vtable-fields "pwpwpw")
+ (lambda (x port)
+ (format port "< ~a>" (class-name x)))))
+
+(define (class? x)
+ (and (struct? x)
+ (eq? (struct-vtable x) )))
+@end example
+
+To make a structure with a specific meta-vtable, we will use
+@code{make-struct/no-tail}, passing it the computed instance layout and
+printer, as with @code{make-vtable}, and additionally the extra three
+class fields.
+
+@example
+(define (make-class name parent fields)
+ (let* ((fields (compute-fields parent fields))
+ (layout (compute-layout fields)))
+ (make-struct/no-tail
+ layout
+ (lambda (x port)
+ (print-instance x port))
+ name
+ parent
+ fields)))
+@end example
+
+Instances will store their associated data in slots in the structure: as
+many slots as there are fields. The @code{compute-layout} procedure
+below can compute a layout, and @code{field-index} returns the slot
+corresponding to a field.
+
+@example
+(define-syntax-rule (define-accessor name n)
+ (define (name obj)
+ (struct-ref obj n)))
+
+;; Accessors for classes
+(define-accessor class-name (+ vtable-offset-user 0))
+(define-accessor class-parent (+ vtable-offset-user 1))
+(define-accessor class-fields (+ vtable-offset-user 2))
+
+(define (compute-fields parent fields)
+ (if parent
+ (append (class-fields parent) fields)
+ fields))
+
+(define (compute-layout fields)
+ (make-struct-layout
+ (string-concatenate (make-list (length fields) "pw"))))
+
+(define (field-index class field)
+ (list-index (class-fields class) field))
+
+(define (print-instance x port)
+ (format port "<~a" (class-name (struct-vtable x)))
+ (for-each (lambda (field idx)
+ (format port " ~a: ~a" field (struct-ref x idx)))
+ (class-fields (struct-vtable x))
+ (iota (length (class-fields (struct-vtable x)))))
+ (format port ">"))
+@end example
+
+So, at this point we can actually make a few classes:
+
+@example
+(define-syntax-rule (define-class name parent field ...)
+ (define name (make-class 'name parent '(field ...))))
+
+(define-class #f
+ width height)
+
+(define-class
+ x y)
+@end example
+
+And finally, make an instance:
+
+@example
+(make-struct/no-tail 400 300 10 20)
+@result{} < width: 400 height: 300 x: 10 y: 20>
+@end example
+
+And that's that. Note that there are many possible optimizations and
+feature enhancements that can be made to this object system, and the
+included GOOPS system does make most of them. For more simple use
+cases, the records facility is usually sufficient. But sometimes you
+need to make new kinds of data abstractions, and for that purpose,
+structs are here.
+
+@node Tail Arrays
+@subsubsection Tail Arrays
+
+Guile's structures have a facility whereby each instance of a vtable can
+contain a variable-length tail array of values. The length of the tail
+array is stored in the structure. This facility was originally intended
+to allow C code to expose raw C structures with word-sized tail arrays
+to Scheme.
+
+However, the tail array facility is confusing and doesn't work very
+well. It is very rarely used, but it insinuates itself into all
+invocations of @code{make-struct}. For this reason the clumsily-named
+@code{make-struct/no-tail} procedure can actually be more elegant in
+actual use, because it doesn't have a random @code{0} argument stuck in
+the middle.
+
+Tail arrays also inhibit optimization by allowing instances to affect
+their shapes. In the absence of tail arrays, all instances of a given
+vtable have the same number and kinds of fields. This uniformity can be
+exploited by the runtime and the optimizer. The presence of tail arrays
+make some of these optimizations more difficult.
+
+Finally, the tail array facility is ad-hoc and does not compose with the
+rest of Guile. If a Guile user wants an array with user-specified
+length, it's best to use a vector. It is more clear in the code, and
+the standard optimization techniques will do a good job with it.
+
+That said, we should mention some details about the interface. A vtable
+that has tail array has upper-case permission descriptors: @code{W},
+@code{R} or @code{O}, correspoding to tail arrays of writable,
+read-only, or opaque elements. A tail array permission descriptor may
+only appear in the last element of a vtable layout.
+
+For exampple, @samp{pW} indicates a tail of writable Scheme-valued
+fields. The @samp{pW} field itself holds the tail size, and the tail
+fields come after it.
+
+@example
+(define v (make-vtable "prpW")) ;; one fixed then a tail array
+(define s (make-struct v 6 "fixed field" 'x 'y))
+(struct-ref s 0) @result{} "fixed field"
+(struct-ref s 1) @result{} 2 ;; tail size
+(struct-ref s 2) @result{} x ;; tail array ...
+(struct-ref s 3) @result{} y
+(struct-ref s 4) @result{} #f
+@end example
+
+
+@node Dictionary Types
+@subsection Dictionary Types
+
+A @dfn{dictionary} object is a data structure used to index
+information in a user-defined way. In standard Scheme, the main
+aggregate data types are lists and vectors. Lists are not really
+indexed at all, and vectors are indexed only by number
+(e.g.@: @code{(vector-ref foo 5)}). Often you will find it useful
+to index your data on some other type; for example, in a library
+catalog you might want to look up a book by the name of its
+author. Dictionaries are used to help you organize information in
+such a way.
+
+An @dfn{association list} (or @dfn{alist} for short) is a list of
+key-value pairs. Each pair represents a single quantity or
+object; the @code{car} of the pair is a key which is used to
+identify the object, and the @code{cdr} is the object's value.
+
+A @dfn{hash table} also permits you to index objects with
+arbitrary keys, but in a way that makes looking up any one object
+extremely fast. A well-designed hash system makes hash table
+lookups almost as fast as conventional array or vector references.
+
+Alists are popular among Lisp programmers because they use only
+the language's primitive operations (lists, @dfn{car}, @dfn{cdr}
+and the equality primitives). No changes to the language core are
+necessary. Therefore, with Scheme's built-in list manipulation
+facilities, it is very convenient to handle data stored in an
+association list. Also, alists are highly portable and can be
+easily implemented on even the most minimal Lisp systems.
+
+However, alists are inefficient, especially for storing large
+quantities of data. Because we want Guile to be useful for large
+software systems as well as small ones, Guile provides a rich set
+of tools for using either association lists or hash tables.
+
+@node Association Lists
+@subsection Association Lists
+@tpindex Association Lists
+@tpindex Alist
+@cindex association List
+@cindex alist
+@cindex database
+
+An association list is a conventional data structure that is often used
+to implement simple key-value databases. It consists of a list of
+entries in which each entry is a pair. The @dfn{key} of each entry is
+the @code{car} of the pair and the @dfn{value} of each entry is the
+@code{cdr}.
+
+@example
+ASSOCIATION LIST ::= '( (KEY1 . VALUE1)
+ (KEY2 . VALUE2)
+ (KEY3 . VALUE3)
+ @dots{}
+ )
+@end example
+
+@noindent
+Association lists are also known, for short, as @dfn{alists}.
+
+The structure of an association list is just one example of the infinite
+number of possible structures that can be built using pairs and lists.
+As such, the keys and values in an association list can be manipulated
+using the general list structure procedures @code{cons}, @code{car},
+@code{cdr}, @code{set-car!}, @code{set-cdr!} and so on. However,
+because association lists are so useful, Guile also provides specific
+procedures for manipulating them.
+
+@menu
+* Alist Key Equality::
+* Adding or Setting Alist Entries::
+* Retrieving Alist Entries::
+* Removing Alist Entries::
+* Sloppy Alist Functions::
+* Alist Example::
+@end menu
+
+@node Alist Key Equality
+@subsubsection Alist Key Equality
+
+All of Guile's dedicated association list procedures, apart from
+@code{acons}, come in three flavours, depending on the level of equality
+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
+required entry.
+
+@itemize @bullet
+@item
+Procedures with @dfn{assq} in their name use @code{eq?} to determine key
+equality.
+
+@item
+Procedures with @dfn{assv} in their name use @code{eqv?} to determine
+key equality.
+
+@item
+Procedures with @dfn{assoc} in their name use @code{equal?} to
+determine key equality.
+@end itemize
+
+@code{acons} is an exception because it is used to build association
+lists which do not require their entries' keys to be unique.
+
+@node Adding or Setting Alist Entries
+@subsubsection Adding or Setting Alist Entries
+
+@code{acons} adds a new entry to an association list and returns the
+combined association list. The combined alist is formed by consing the
+new entry onto the head of the alist specified in the @code{acons}
+procedure call. So the specified alist is not modified, but its
+contents become shared with the tail of the combined alist that
+@code{acons} returns.
+
+In the most common usage of @code{acons}, a variable holding the
+original association list is updated with the combined alist:
+
+@example
+(set! address-list (acons name address address-list))
+@end example
+
+In such cases, it doesn't matter that the old and new values of
+@code{address-list} share some of their contents, since the old value is
+usually no longer independently accessible.
+
+Note that @code{acons} adds the specified new entry regardless of
+whether the alist may already contain entries with keys that are, in
+some sense, the same as that of the new entry. Thus @code{acons} is
+ideal for building alists where there is no concept of key uniqueness.
+
+@example
+(set! task-list (acons 3 "pay gas bill" '()))
+task-list
+@result{}
+((3 . "pay gas bill"))
+
+(set! task-list (acons 3 "tidy bedroom" task-list))
+task-list
+@result{}
+((3 . "tidy bedroom") (3 . "pay gas bill"))
+@end example
+
+@code{assq-set!}, @code{assv-set!} and @code{assoc-set!} are used to add
+or replace an entry in an association list where there @emph{is} a
+concept of key uniqueness. If the specified association list already
+contains an entry whose key is the same as that specified in the
+procedure call, the existing entry is replaced by the new one.
+Otherwise, the new entry is consed onto the head of the old association
+list to create the combined alist. In all cases, these procedures
+return the combined alist.
+
+@code{assq-set!} and friends @emph{may} destructively modify the
+structure of the old association list in such a way that an existing
+variable is correctly updated without having to @code{set!} it to the
+value returned:
+
+@example
+address-list
+@result{}
+(("mary" . "34 Elm Road") ("james" . "16 Bow Street"))
+
+(assoc-set! address-list "james" "1a London Road")
+@result{}
+(("mary" . "34 Elm Road") ("james" . "1a London Road"))
+
+address-list
+@result{}
+(("mary" . "34 Elm Road") ("james" . "1a London Road"))
+@end example
+
+Or they may not:
+
+@example
+(assoc-set! address-list "bob" "11 Newington Avenue")
+@result{}
+(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road")
+ ("james" . "1a London Road"))
+
+address-list
+@result{}
+(("mary" . "34 Elm Road") ("james" . "1a London Road"))
+@end example
+
+The only safe way to update an association list variable when adding or
+replacing an entry like this is to @code{set!} the variable to the
+returned value:
+
+@example
+(set! address-list
+ (assoc-set! address-list "bob" "11 Newington Avenue"))
+address-list
+@result{}
+(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road")
+ ("james" . "1a London Road"))
+@end example
+
+Because of this slight inconvenience, you may find it more convenient to
+use hash tables to store dictionary data. If your application will not
+be modifying the contents of an alist very often, this may not make much
+difference to you.
+
+If you need to keep the old value of an association list in a form
+independent from the list that results from modification by
+@code{acons}, @code{assq-set!}, @code{assv-set!} or @code{assoc-set!},
+use @code{list-copy} to copy the old association list before modifying
+it.
+
+@deffn {Scheme Procedure} acons key value alist
+@deffnx {C Function} scm_acons (key, value, alist)
+Add a new key-value pair to @var{alist}. A new pair is
+created whose car is @var{key} and whose cdr is @var{value}, and the
+pair is consed onto @var{alist}, and the new list is returned. This
+function is @emph{not} destructive; @var{alist} is not modified.
+@end deffn
+
+@deffn {Scheme Procedure} assq-set! alist key val
+@deffnx {Scheme Procedure} assv-set! alist key value
+@deffnx {Scheme Procedure} assoc-set! alist key value
+@deffnx {C Function} scm_assq_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)
+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{value}. If @var{alist} does not contain an entry for @var{key},
+add a new one. Return the (possibly new) alist.
+
+These functions do not attempt to verify the structure of @var{alist},
+and so may cause unusual results if passed an object that is not an
+association list.
+@end deffn
+
+@node Retrieving Alist Entries
+@subsubsection Retrieving Alist Entries
+@rnindex assq
+@rnindex assv
+@rnindex assoc
+
+@code{assq}, @code{assv} and @code{assoc} find the entry in an alist
+for a given key, and return the @code{(@var{key} . @var{value})} pair.
+@code{assq-ref}, @code{assv-ref} and @code{assoc-ref} do a similar
+lookup, but return just the @var{value}.
+
+@deffn {Scheme Procedure} assq key alist
+@deffnx {Scheme Procedure} assv key alist
+@deffnx {Scheme Procedure} assoc key alist
+@deffnx {C Function} scm_assq (key, alist)
+@deffnx {C Function} scm_assv (key, alist)
+@deffnx {C Function} scm_assoc (key, alist)
+Return the first entry in @var{alist} with the given @var{key}. The
+return is the pair @code{(KEY . VALUE)} from @var{alist}. If there's
+no matching entry the return is @code{#f}.
+
+@code{assq} compares keys with @code{eq?}, @code{assv} uses
+@code{eqv?} and @code{assoc} uses @code{equal?}. See also SRFI-1
+which has an extended @code{assoc} (@ref{SRFI-1 Association Lists}).
+@end deffn
+
+@deffn {Scheme Procedure} assq-ref alist key
+@deffnx {Scheme Procedure} assv-ref alist key
+@deffnx {Scheme Procedure} assoc-ref alist key
+@deffnx {C Function} scm_assq_ref (alist, key)
+@deffnx {C Function} scm_assv_ref (alist, key)
+@deffnx {C Function} scm_assoc_ref (alist, key)
+Return the value from the first entry in @var{alist} with the given
+@var{key}, or @code{#f} if there's no such entry.
+
+@code{assq-ref} compares keys with @code{eq?}, @code{assv-ref} uses
+@code{eqv?} and @code{assoc-ref} uses @code{equal?}.
+
+Notice these functions have the @var{key} argument last, like other
+@code{-ref} functions, but this is opposite to what @code{assq}
+etc above use.
+
+When the return is @code{#f} it can be either @var{key} not found, or
+an entry which happens to have value @code{#f} in the @code{cdr}. Use
+@code{assq} etc above if you need to differentiate these cases.
+@end deffn
+
+
+@node Removing Alist Entries
+@subsubsection Removing Alist Entries
+
+To remove the element from an association list whose key matches a
+specified key, use @code{assq-remove!}, @code{assv-remove!} or
+@code{assoc-remove!} (depending, as usual, on the level of equality
+required between the key that you specify and the keys in the
+association list).
+
+As with @code{assq-set!} and friends, the specified alist may or may not
+be modified destructively, and the only safe way to update a variable
+containing the alist is to @code{set!} it to the value that
+@code{assq-remove!} and friends return.
+
+@example
+address-list
+@result{}
+(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road")
+ ("james" . "1a London Road"))
+
+(set! address-list (assoc-remove! address-list "mary"))
+address-list
+@result{}
+(("bob" . "11 Newington Avenue") ("james" . "1a London Road"))
+@end example
+
+Note that, when @code{assq/v/oc-remove!} is used to modify an
+association list that has been constructed only using the corresponding
+@code{assq/v/oc-set!}, there can be at most one matching entry in the
+alist, so the question of multiple entries being removed in one go does
+not arise. If @code{assq/v/oc-remove!} is applied to an association
+list that has been constructed using @code{acons}, or an
+@code{assq/v/oc-set!} with a different level of equality, or any mixture
+of these, it removes only the first matching entry from the alist, even
+if the alist might contain further matching entries. For example:
+
+@example
+(define address-list '())
+(set! address-list (assq-set! address-list "mary" "11 Elm Street"))
+(set! address-list (assq-set! address-list "mary" "57 Pine Drive"))
+address-list
+@result{}
+(("mary" . "57 Pine Drive") ("mary" . "11 Elm Street"))
+
+(set! address-list (assoc-remove! address-list "mary"))
+address-list
+@result{}
+(("mary" . "11 Elm Street"))
+@end example
+
+In this example, the two instances of the string "mary" are not the same
+when compared using @code{eq?}, so the two @code{assq-set!} calls add
+two distinct entries to @code{address-list}. When compared using
+@code{equal?}, both "mary"s in @code{address-list} are the same as the
+"mary" in the @code{assoc-remove!} call, but @code{assoc-remove!} stops
+after removing the first matching entry that it finds, and so one of the
+"mary" entries is left in place.
+
+@deffn {Scheme Procedure} assq-remove! alist key
+@deffnx {Scheme Procedure} assv-remove! alist key
+@deffnx {Scheme Procedure} assoc-remove! alist key
+@deffnx {C Function} scm_assq_remove_x (alist, key)
+@deffnx {C Function} scm_assv_remove_x (alist, key)
+@deffnx {C Function} scm_assoc_remove_x (alist, key)
+Delete the first entry in @var{alist} associated with @var{key}, and return
+the resulting alist.
+@end deffn
+
+@node Sloppy Alist Functions
+@subsubsection Sloppy Alist Functions
+
+@code{sloppy-assq}, @code{sloppy-assv} and @code{sloppy-assoc} behave
+like the corresponding non-@code{sloppy-} procedures, except that they
+return @code{#f} when the specified association list is not well-formed,
+where the non-@code{sloppy-} versions would signal an error.
+
+Specifically, there are two conditions for which the non-@code{sloppy-}
+procedures signal an error, which the @code{sloppy-} procedures handle
+instead by returning @code{#f}. Firstly, if the specified alist as a
+whole is not a proper list:
+
+@example
+(assoc "mary" '((1 . 2) ("key" . "door") . "open sesame"))
+@result{}
+ERROR: In procedure assoc in expression (assoc "mary" (quote #)):
+ERROR: Wrong type argument in position 2 (expecting
+ association list): ((1 . 2) ("key" . "door") . "open sesame")
+
+(sloppy-assoc "mary" '((1 . 2) ("key" . "door") . "open sesame"))
+@result{}
+#f
+@end example
+
+@noindent
+Secondly, if one of the entries in the specified alist is not a pair:
+
+@example
+(assoc 2 '((1 . 1) 2 (3 . 9)))
+@result{}
+ERROR: In procedure assoc in expression (assoc 2 (quote #)):
+ERROR: Wrong type argument in position 2 (expecting
+ association list): ((1 . 1) 2 (3 . 9))
+
+(sloppy-assoc 2 '((1 . 1) 2 (3 . 9)))
+@result{}
+#f
+@end example
+
+Unless you are explicitly working with badly formed association lists,
+it is much safer to use the non-@code{sloppy-} procedures, because they
+help to highlight coding and data errors that the @code{sloppy-}
+versions would silently cover up.
+
+@deffn {Scheme Procedure} sloppy-assq key alist
+@deffnx {C Function} scm_sloppy_assq (key, alist)
+Behaves like @code{assq} but does not do any error checking.
+Recommended only for use in Guile internals.
+@end deffn
+
+@deffn {Scheme Procedure} sloppy-assv key alist
+@deffnx {C Function} scm_sloppy_assv (key, alist)
+Behaves like @code{assv} but does not do any error checking.
+Recommended only for use in Guile internals.
+@end deffn
+
+@deffn {Scheme Procedure} sloppy-assoc key alist
+@deffnx {C Function} scm_sloppy_assoc (key, alist)
+Behaves like @code{assoc} but does not do any error checking.
+Recommended only for use in Guile internals.
+@end deffn
+
+@node Alist Example
+@subsubsection Alist Example
+
+Here is a longer example of how alists may be used in practice.
+
+@lisp
+(define capitals '(("New York" . "Albany")
+ ("Oregon" . "Salem")
+ ("Florida" . "Miami")))
+
+;; What's the capital of Oregon?
+(assoc "Oregon" capitals) @result{} ("Oregon" . "Salem")
+(assoc-ref capitals "Oregon") @result{} "Salem"
+
+;; We left out South Dakota.
+(set! capitals
+ (assoc-set! capitals "South Dakota" "Pierre"))
+capitals
+@result{} (("South Dakota" . "Pierre")
+ ("New York" . "Albany")
+ ("Oregon" . "Salem")
+ ("Florida" . "Miami"))
+
+;; And we got Florida wrong.
+(set! capitals
+ (assoc-set! capitals "Florida" "Tallahassee"))
+capitals
+@result{} (("South Dakota" . "Pierre")
+ ("New York" . "Albany")
+ ("Oregon" . "Salem")
+ ("Florida" . "Tallahassee"))
+
+;; After Oregon secedes, we can remove it.
+(set! capitals
+ (assoc-remove! capitals "Oregon"))
+capitals
+@result{} (("South Dakota" . "Pierre")
+ ("New York" . "Albany")
+ ("Florida" . "Tallahassee"))
+@end lisp
+
+@node VHashes
+@subsection VList-Based Hash Lists or ``VHashes''
+
+@cindex VList-based hash lists
+@cindex VHash
+
+The @code{(ice-9 vlist)} module provides an implementation of @dfn{VList-based
+hash lists} (@pxref{VLists}). VList-based hash lists, or @dfn{vhashes}, are an
+immutable dictionary type similar to association lists that maps @dfn{keys} to
+@dfn{values}. However, unlike association lists, accessing a value given its
+key is typically a constant-time operation.
+
+The VHash programming interface of @code{(ice-9 vlist)} is mostly the same as
+that of association lists found in SRFI-1, with procedure names prefixed by
+@code{vhash-} instead of @code{alist-} (@pxref{SRFI-1 Association Lists}).
+
+In addition, vhashes can be manipulated using VList operations:
+
+@example
+(vlist-head (vhash-consq 'a 1 vlist-null))
+@result{} (a . 1)
+
+(define vh1 (vhash-consq 'b 2 (vhash-consq 'a 1 vlist-null)))
+(define vh2 (vhash-consq 'c 3 (vlist-tail vh1)))
+
+(vhash-assq 'a vh2)
+@result{} (a . 1)
+(vhash-assq 'b vh2)
+@result{} #f
+(vhash-assq 'c vh2)
+@result{} (c . 3)
+(vlist->list vh2)
+@result{} ((c . 3) (a . 1))
+@end example
+
+However, keep in mind that procedures that construct new VLists
+(@code{vlist-map}, @code{vlist-filter}, etc.) return raw VLists, not vhashes:
+
+@example
+(define vh (alist->vhash '((a . 1) (b . 2) (c . 3)) hashq))
+(vhash-assq 'a vh)
+@result{} (a . 1)
+
+(define vl
+ ;; This will create a raw vlist.
+ (vlist-filter (lambda (key+value) (odd? (cdr key+value))) vh))
+(vhash-assq 'a vl)
+@result{} ERROR: Wrong type argument in position 2
+
+(vlist->list vl)
+@result{} ((a . 1) (c . 3))
+@end example
+
+@deffn {Scheme Procedure} vhash? obj
+Return true if @var{obj} is a vhash.
+@end deffn
+
+@deffn {Scheme Procedure} vhash-cons key value vhash [hash-proc]
+@deffnx {Scheme Procedure} vhash-consq key value vhash
+@deffnx {Scheme Procedure} vhash-consv key value vhash
+Return a new hash list based on @var{vhash} where @var{key} is associated with
+@var{value}, using @var{hash-proc} to compute the hash of @var{key}.
+@var{vhash} must be either @code{vlist-null} or a vhash returned by a previous
+call to @code{vhash-cons}. @var{hash-proc} defaults to @code{hash} (@pxref{Hash
+Table Reference, @code{hash} procedure}). With @code{vhash-consq}, the
+@code{hashq} hash function is used; with @code{vhash-consv} the @code{hashv}
+hash function is used.
+
+All @code{vhash-cons} calls made to construct a vhash should use the same
+@var{hash-proc}. Failing to do that, the result is undefined.
+@end deffn
+
+@deffn {Scheme Procedure} vhash-assoc key vhash [equal? [hash-proc]]
+@deffnx {Scheme Procedure} vhash-assq key vhash
+@deffnx {Scheme Procedure} vhash-assv key vhash
+Return the first key/value pair from @var{vhash} whose key is equal to @var{key}
+according to the @var{equal?} equality predicate (which defaults to
+@code{equal?}), and using @var{hash-proc} (which defaults to @code{hash}) to
+compute the hash of @var{key}. The second form uses @code{eq?} as the equality
+predicate and @code{hashq} as the hash function; the last form uses @code{eqv?}
+and @code{hashv}.
+
+Note that it is important to consistently use the same hash function for
+@var{hash-proc} as was passed to @code{vhash-cons}. Failing to do that, the
+result is unpredictable.
+@end deffn
+
+@deffn {Scheme Procedure} vhash-delete key vhash [equal? [hash-proc]]
+@deffnx {Scheme Procedure} vhash-delq key vhash
+@deffnx {Scheme Procedure} vhash-delv key vhash
+Remove all associations from @var{vhash} with @var{key}, comparing keys with
+@var{equal?} (which defaults to @code{equal?}), and computing the hash of
+@var{key} using @var{hash-proc} (which defaults to @code{hash}). The second
+form uses @code{eq?} as the equality predicate and @code{hashq} as the hash
+function; the last one uses @code{eqv?} and @code{hashv}.
+
+Again the choice of @var{hash-proc} must be consistent with previous calls to
+@code{vhash-cons}.
+@end deffn
+
+@deffn {Scheme Procedure} vhash-fold proc init vhash
+@deffnx {Scheme Procedure} vhash-fold-right proc init vhash
+Fold over the key/value elements of @var{vhash} in the given direction,
+with each call to @var{proc} having the form @code{(@var{proc} key value
+result)}, where @var{result} is the result of the previous call to
+@var{proc} and @var{init} the value of @var{result} for the first call
+to @var{proc}.
+@end deffn
+
+@deffn {Scheme Procedure} vhash-fold* proc init key vhash [equal? [hash]]
+@deffnx {Scheme Procedure} vhash-foldq* proc init key vhash
+@deffnx {Scheme Procedure} vhash-foldv* proc init key vhash
+Fold over all the values associated with @var{key} in @var{vhash}, with each
+call to @var{proc} having the form @code{(proc value result)}, where
+@var{result} is the result of the previous call to @var{proc} and @var{init} the
+value of @var{result} for the first call to @var{proc}.
+
+Keys in @var{vhash} are hashed using @var{hash} are compared using @var{equal?}.
+The second form uses @code{eq?} as the equality predicate and @code{hashq} as
+the hash function; the third one uses @code{eqv?} and @code{hashv}.
+
+Example:
+
+@example
+(define vh
+ (alist->vhash '((a . 1) (a . 2) (z . 0) (a . 3))))
+
+(vhash-fold* cons '() 'a vh)
+@result{} (3 2 1)
+
+(vhash-fold* cons '() 'z vh)
+@result{} (0)
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} alist->vhash alist [hash-proc]
+Return the vhash corresponding to @var{alist}, an association list, using
+@var{hash-proc} to compute key hashes. When omitted, @var{hash-proc} defaults
+to @code{hash}.
+@end deffn
+
+
+@node Hash Tables
+@subsection Hash Tables
+@tpindex Hash Tables
+
+Hash tables are dictionaries which offer similar functionality as
+association lists: They provide a mapping from keys to values. The
+difference is that association lists need time linear in the size of
+elements when searching for entries, whereas hash tables can normally
+search in constant time. The drawback is that hash tables require a
+little bit more memory, and that you can not use the normal list
+procedures (@pxref{Lists}) for working with them.
+
+@menu
+* Hash Table Examples:: Demonstration of hash table usage.
+* Hash Table Reference:: Hash table procedure descriptions.
+@end menu
+
+
+@node Hash Table Examples
+@subsubsection Hash Table Examples
+
+For demonstration purposes, this section gives a few usage examples of
+some hash table procedures, together with some explanation what they do.
+
+First we start by creating a new hash table with 31 slots, and
+populate it with two key/value pairs.
+
+@lisp
+(define h (make-hash-table 31))
+
+;; This is an opaque object
+h
+@result{}
+#
+
+;; Inserting into a hash table can be done with hashq-set!
+(hashq-set! h 'foo "bar")
+@result{}
+"bar"
+
+(hashq-set! h 'braz "zonk")
+@result{}
+"zonk"
+
+;; Or with hash-create-handle!
+(hashq-create-handle! h 'frob #f)
+@result{}
+(frob . #f)
+@end lisp
+
+You can get the value for a given key with the procedure
+@code{hashq-ref}, but the problem with this procedure is that you
+cannot reliably determine whether a key does exists in the table. The
+reason is that the procedure returns @code{#f} if the key is not in
+the table, but it will return the same value if the key is in the
+table and just happens to have the value @code{#f}, as you can see in
+the following examples.
+
+@lisp
+(hashq-ref h 'foo)
+@result{}
+"bar"
+
+(hashq-ref h 'frob)
+@result{}
+#f
+
+(hashq-ref h 'not-there)
+@result{}
+#f
+@end lisp
+
+It is often better is to use the procedure @code{hashq-get-handle},
+which makes a distinction between the two cases. Just like @code{assq},
+this procedure returns a key/value-pair on success, and @code{#f} if the
+key is not found.
+
+@lisp
+(hashq-get-handle h 'foo)
+@result{}
+(foo . "bar")
+
+(hashq-get-handle h 'not-there)
+@result{}
+#f
+@end lisp
+
+Interesting results can be computed by using @code{hash-fold} to work
+through each element. This example will count the total number of
+elements:
+
+@lisp
+(hash-fold (lambda (key value seed) (+ 1 seed)) 0 h)
+@result{}
+3
+@end lisp
+
+The same thing can be done with the procedure @code{hash-count}, which
+can also count the number of elements matching a particular predicate.
+For example, count the number of elements with string values:
+
+@lisp
+(hash-count (lambda (key value) (string? value)) h)
+@result{}
+2
+@end lisp
+
+Counting all the elements is a simple task using @code{const}:
+
+@lisp
+(hash-count (const #t) h)
+@result{}
+3
+@end lisp
+
+@node Hash Table Reference
+@subsubsection Hash Table Reference
+
+@c FIXME: Describe in broad terms what happens for resizing, and what
+@c the initial size means for this.
+
+Like the association list functions, the hash table functions come in
+several varieties, according to the equality test used for the keys.
+Plain @code{hash-} functions use @code{equal?}, @code{hashq-}
+functions use @code{eq?}, @code{hashv-} functions use @code{eqv?}, and
+the @code{hashx-} functions use an application supplied test.
+
+A single @code{make-hash-table} creates a hash table suitable for use
+with any set of functions, but it's imperative that just one set is
+then used consistently, or results will be unpredictable.
+
+Hash tables are implemented as a vector indexed by a hash value formed
+from the key, with an association list of key/value pairs for each
+bucket in case distinct keys hash together. Direct access to the
+pairs in those lists is provided by the @code{-handle-} functions.
+
+When the number of entries in a hash table goes above a threshold, the
+vector is made larger and the entries are rehashed, to prevent the
+bucket lists from becoming too long and slowing down accesses. When the
+number of entries goes below a threshold, the vector is shrunk to save
+space.
+
+For the @code{hashx-} ``extended'' routines, an application supplies a
+@var{hash} function producing an integer index like @code{hashq} etc
+below, and an @var{assoc} alist search function like @code{assq} etc
+(@pxref{Retrieving Alist Entries}). Here's an example of such
+functions implementing case-insensitive hashing of string keys,
+
+@example
+(use-modules (srfi srfi-1)
+ (srfi srfi-13))
+
+(define (my-hash str size)
+ (remainder (string-hash-ci str) size))
+(define (my-assoc str alist)
+ (find (lambda (pair) (string-ci=? str (car pair))) alist))
+
+(define my-table (make-hash-table))
+(hashx-set! my-hash my-assoc my-table "foo" 123)
+
+(hashx-ref my-hash my-assoc my-table "FOO")
+@result{} 123
+@end example
+
+In a @code{hashx-} @var{hash} function the aim is to spread keys
+across the vector, so bucket lists don't become long. But the actual
+values are arbitrary as long as they're in the range 0 to
+@math{@var{size}-1}. Helpful functions for forming a hash value, in
+addition to @code{hashq} etc below, include @code{symbol-hash}
+(@pxref{Symbol Keys}), @code{string-hash} and @code{string-hash-ci}
+(@pxref{String Comparison}), and @code{char-set-hash}
+(@pxref{Character Set Predicates/Comparison}).
+
+@sp 1
+@deffn {Scheme Procedure} make-hash-table [size]
+Create a new hash table object, with an optional minimum
+vector @var{size}.
+
+When @var{size} is given, the table vector will still grow and shrink
+automatically, as described above, but with @var{size} as a minimum.
+If an application knows roughly how many entries the table will hold
+then it can use @var{size} to avoid rehashing when initial entries are
+added.
+@end deffn
+
+@deffn {Scheme Procedure} alist->hash-table alist
+@deffnx {Scheme Procedure} alist->hashq-table alist
+@deffnx {Scheme Procedure} alist->hashv-table alist
+@deffnx {Scheme Procedure} alist->hashx-table hash assoc alist
+Convert @var{alist} into a hash table. When keys are repeated in
+@var{alist}, the leftmost association takes precedence.
+
+@example
+(use-modules (ice-9 hash-table))
+(alist->hash-table '((foo . 1) (bar . 2)))
+@end example
+
+When converting to an extended hash table, custom @var{hash} and
+@var{assoc} procedures must be provided.
+
+@example
+(alist->hashx-table hash assoc '((foo . 1) (bar . 2)))
+@end example
+
+@end deffn
+
+@deffn {Scheme Procedure} hash-table? obj
+@deffnx {C Function} scm_hash_table_p (obj)
+Return @code{#t} if @var{obj} is a abstract hash table object.
+@end deffn
+
+@deffn {Scheme Procedure} hash-clear! table
+@deffnx {C Function} scm_hash_clear_x (table)
+Remove all items from @var{table} (without triggering a resize).
+@end deffn
+
+@deffn {Scheme Procedure} hash-ref table key [dflt]
+@deffnx {Scheme Procedure} hashq-ref table key [dflt]
+@deffnx {Scheme Procedure} hashv-ref table key [dflt]
+@deffnx {Scheme Procedure} hashx-ref hash assoc table key [dflt]
+@deffnx {C Function} scm_hash_ref (table, key, dflt)
+@deffnx {C Function} scm_hashq_ref (table, key, dflt)
+@deffnx {C Function} scm_hashv_ref (table, key, dflt)
+@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt)
+Lookup @var{key} in the given hash @var{table}, and return the
+associated value. If @var{key} is not found, return @var{dflt}, or
+@code{#f} if @var{dflt} is not given.
+@end deffn
+
+@deffn {Scheme Procedure} hash-set! table key val
+@deffnx {Scheme Procedure} hashq-set! table key val
+@deffnx {Scheme Procedure} hashv-set! table key val
+@deffnx {Scheme Procedure} hashx-set! hash assoc table key val
+@deffnx {C Function} scm_hash_set_x (table, key, val)
+@deffnx {C Function} scm_hashq_set_x (table, key, val)
+@deffnx {C Function} scm_hashv_set_x (table, key, val)
+@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val)
+Associate @var{val} with @var{key} in the given hash @var{table}. If
+@var{key} is already present then it's associated value is changed.
+If it's not present then a new entry is created.
+@end deffn
+
+@deffn {Scheme Procedure} hash-remove! table key
+@deffnx {Scheme Procedure} hashq-remove! table key
+@deffnx {Scheme Procedure} hashv-remove! table key
+@deffnx {Scheme Procedure} hashx-remove! hash assoc table key
+@deffnx {C Function} scm_hash_remove_x (table, key)
+@deffnx {C Function} scm_hashq_remove_x (table, key)
+@deffnx {C Function} scm_hashv_remove_x (table, key)
+@deffnx {C Function} scm_hashx_remove_x (hash, assoc, table, key)
+Remove any association for @var{key} in the given hash @var{table}.
+If @var{key} is not in @var{table} then nothing is done.
+@end deffn
+
+@deffn {Scheme Procedure} hash key size
+@deffnx {Scheme Procedure} hashq key size
+@deffnx {Scheme Procedure} hashv key size
+@deffnx {C Function} scm_hash (key, size)
+@deffnx {C Function} scm_hashq (key, size)
+@deffnx {C Function} scm_hashv (key, size)
+Return a hash value for @var{key}. This is a number in the range
+@math{0} to @math{@var{size}-1}, which is suitable for use in a hash
+table of the given @var{size}.
+
+Note that @code{hashq} and @code{hashv} may use internal addresses of
+objects, so if an object is garbage collected and re-created it can
+have a different hash value, even when the two are notionally
+@code{eq?}. For instance with symbols,
+
+@example
+(hashq 'something 123) @result{} 19
+(gc)
+(hashq 'something 123) @result{} 62
+@end example
+
+In normal use this is not a problem, since an object entered into a
+hash table won't be garbage collected until removed. It's only if
+hashing calculations are somehow separated from normal references that
+its lifetime needs to be considered.
+@end deffn
+
+@deffn {Scheme Procedure} hash-get-handle table key
+@deffnx {Scheme Procedure} hashq-get-handle table key
+@deffnx {Scheme Procedure} hashv-get-handle table key
+@deffnx {Scheme Procedure} hashx-get-handle hash assoc table key
+@deffnx {C Function} scm_hash_get_handle (table, key)
+@deffnx {C Function} scm_hashq_get_handle (table, key)
+@deffnx {C Function} scm_hashv_get_handle (table, key)
+@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key)
+Return the @code{(@var{key} . @var{value})} pair for @var{key} in the
+given hash @var{table}, or @code{#f} if @var{key} is not in
+@var{table}.
+@end deffn
+
+@deffn {Scheme Procedure} hash-create-handle! table key init
+@deffnx {Scheme Procedure} hashq-create-handle! table key init
+@deffnx {Scheme Procedure} hashv-create-handle! table key init
+@deffnx {Scheme Procedure} hashx-create-handle! hash assoc table key init
+@deffnx {C Function} scm_hash_create_handle_x (table, key, init)
+@deffnx {C Function} scm_hashq_create_handle_x (table, key, init)
+@deffnx {C Function} scm_hashv_create_handle_x (table, key, init)
+@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init)
+Return the @code{(@var{key} . @var{value})} pair for @var{key} in the
+given hash @var{table}. If @var{key} is not in @var{table} then
+create an entry for it with @var{init} as the value, and return that
+pair.
+@end deffn
+
+@deffn {Scheme Procedure} hash-map->list proc table
+@deffnx {Scheme Procedure} hash-for-each proc table
+@deffnx {C Function} scm_hash_map_to_list (proc, table)
+@deffnx {C Function} scm_hash_for_each (proc, table)
+Apply @var{proc} to the entries in the given hash @var{table}. Each
+call is @code{(@var{proc} @var{key} @var{value})}. @code{hash-map->list}
+returns a list of the results from these calls, @code{hash-for-each}
+discards the results and returns an unspecified value.
+
+Calls are made over the table entries in an unspecified order, and for
+@code{hash-map->list} the order of the values in the returned list is
+unspecified. Results will be unpredictable if @var{table} is modified
+while iterating.
+
+For example the following returns a new alist comprising all the
+entries from @code{mytable}, in no particular order.
+
+@example
+(hash-map->list cons mytable)
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} hash-for-each-handle proc table
+@deffnx {C Function} scm_hash_for_each_handle (proc, table)
+Apply @var{proc} to the entries in the given hash @var{table}. Each
+call is @code{(@var{proc} @var{handle})}, where @var{handle} is a
+@code{(@var{key} . @var{value})} pair. Return an unspecified value.
+
+@code{hash-for-each-handle} differs from @code{hash-for-each} only in
+the argument list of @var{proc}.
+@end deffn
+
+@deffn {Scheme Procedure} hash-fold proc init table
+@deffnx {C Function} scm_hash_fold (proc, init, table)
+Accumulate a result by applying @var{proc} to the elements of the
+given hash @var{table}. Each call is @code{(@var{proc} @var{key}
+@var{value} @var{prior-result})}, where @var{key} and @var{value} are
+from the @var{table} and @var{prior-result} is the return from the
+previous @var{proc} call. For the first call, @var{prior-result} is
+the given @var{init} value.
+
+Calls are made over the table entries in an unspecified order.
+Results will be unpredictable if @var{table} is modified while
+@code{hash-fold} is running.
+
+For example, the following returns a count of how many keys in
+@code{mytable} are strings.
+
+@example
+(hash-fold (lambda (key value prior)
+ (if (string? key) (1+ prior) prior))
+ 0 mytable)
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} hash-count pred table
+@deffnx {C Function} scm_hash_count (pred, table)
+Return the number of elements in the given hash @var{table} that cause
+@code{(@var{pred} @var{key} @var{value})} to return true. To quickly
+determine the total number of elements, use @code{(const #t)} for
+@var{pred}.
+@end deffn
+
+@node Other Types
+@subsection Other Types
+
+Procedures are documented in their own section. @xref{Procedures}.
Variable objects are documented as part of the description of Guile's
module system: see @ref{Variables}.
-Asyncs, dynamic roots and fluids are described in the section on
-scheduling: see @ref{Scheduling}.
-
-Hooks are documented in the section on general utility functions: see
-@ref{Hooks}.
+@xref{Scheduling}, for discussion of threads, mutexes, and so on.
Ports are described in the section on I/O: see @ref{Input and Output}.
Regular expressions are described in their own section: see @ref{Regular
Expressions}.
+There are quite a number of additional data types documented in this
+manual; if you feel a link is missing here, please file a bug.
+
@c Local Variables:
@c TeX-master: "guile.texi"
@c End:
diff --git a/doc/ref/api-debug.texi b/doc/ref/api-debug.texi
index bf25c74c9..a6cfd7b03 100644
--- a/doc/ref/api-debug.texi
+++ b/doc/ref/api-debug.texi
@@ -177,10 +177,10 @@ Return the previous frame of @var{frame}, or @code{#f} if
@var{frame} is the first frame in its stack.
@end deffn
-@deffn {Scheme Procedure} frame-procedure frame
-@deffnx {C Function} scm_frame_procedure (frame)
-Return the procedure for @var{frame}, or @code{#f} if no
-procedure is associated with @var{frame}.
+@deffn {Scheme Procedure} frame-procedure-name frame
+@deffnx {C Function} scm_frame_procedure_name (frame)
+Return the name of the procedure being applied in @var{frame}, as a
+symbol, or @code{#f} if the procedure has no name.
@end deffn
@deffn {Scheme Procedure} frame-arguments frame
@@ -201,16 +201,32 @@ respectively. @xref{VM Concepts}, for more information.
@deffnx {Scheme Procedure} frame-mv-return-address frame
Accessors for the three saved VM registers in a frame: the previous
frame pointer, the single-value return address, and the multiple-value
-return address. @xref{Stack Layout}, for more information.
+return address. @xref{Stack Layout}, for more information.
@end deffn
-@deffn {Scheme Procedure} frame-num-locals frame
-@deffnx {Scheme Procedure} frame-local-ref frame i
-@deffnx {Scheme Procedure} frame-local-set! frame i val
-Accessors for the temporary values corresponding to @var{frame}'s
-procedure application. The first local is the first argument given to
-the procedure. After the arguments, there are the local variables, and
-after that temporary values. @xref{Stack Layout}, for more information.
+@deffn {Scheme Procedure} frame-bindings frame
+Return a list of binding records indicating the local variables that are
+live in a frame.
+@end deffn
+
+@deffn {Scheme Procedure} frame-lookup-binding frame var
+Fetch the bindings in @var{frame}, and return the first one whose name
+is @var{var}, or @code{#f} otherwise.
+@end deffn
+
+@deffn {Scheme Procedure} binding-index binding
+@deffnx {Scheme Procedure} binding-name binding
+@deffnx {Scheme Procedure} binding-slot binding
+@deffnx {Scheme Procedure} binding-representation binding
+Accessors for the various fields in a binding. The implicit ``callee''
+argument is index 0, the first argument is index 1, and so on to the end
+of the arguments. After that are temporary variables. Note that if a
+variable is dead, it might not be available.
+@end deffn
+
+@deffn {Scheme Procedure} binding-ref binding
+@deffnx {Scheme Procedure} binding-set! binding val
+Accessors for the values of local variables in a frame.
@end deffn
@deffn {Scheme Procedure} display-application frame [port [indent]]
@@ -1088,11 +1104,6 @@ separately, we discuss them all together here:
@table @code
@item #:vm
The VM to instrument. Defaults to the current thread's VM.
-@item #:closure?
-For traps that depend on the current frame's procedure, this argument
-specifies whether to trap on the only the specific procedure given, or
-on any closure that has the given procedure's code. Defaults to
-@code{#f}.
@item #:current-frame
For traps that enable more hooks depending on their dynamic context,
this argument gives the current frame that the trap is running in.
@@ -1107,12 +1118,12 @@ To have access to these procedures, you'll need to have imported the
@end lisp
@deffn {Scheme Procedure} trap-at-procedure-call proc handler @
- [#:vm] [#:closure?]
+ [#:vm]
A trap that calls @var{handler} when @var{proc} is applied.
@end deffn
@deffn {Scheme Procedure} trap-in-procedure proc @
- enter-handler exit-handler [#:current-frame] [#:vm] [#:closure?]
+ enter-handler exit-handler [#:current-frame] [#:vm]
A trap that calls @var{enter-handler} when control enters @var{proc},
and @var{exit-handler} when control leaves @var{proc}.
@@ -1140,13 +1151,13 @@ An abort.
@end deffn
@deffn {Scheme Procedure} trap-instructions-in-procedure proc @
- next-handler exit-handler [#:current-frame] [#:vm] [#:closure?]
+ next-handler exit-handler [#:current-frame] [#:vm]
A trap that calls @var{next-handler} for every instruction executed in
@var{proc}, and @var{exit-handler} when execution leaves @var{proc}.
@end deffn
@deffn {Scheme Procedure} trap-at-procedure-ip-in-range proc range @
- handler [#:current-frame] [#:vm] [#:closure?]
+ handler [#:current-frame] [#:vm]
A trap that calls @var{handler} when execution enters a range of
instructions in @var{proc}. @var{range} is a simple of pairs,
@code{((@var{start} . @var{end}) ...)}. The @var{start} addresses are
@@ -1169,7 +1180,7 @@ exit.
@end deffn
@deffn {Scheme Procedure} trap-in-dynamic-extent proc @
- enter-handler return-handler abort-handler [#:vm] [#:closure?]
+ enter-handler return-handler abort-handler [#:vm]
A more traditional dynamic-wind trap, which fires @var{enter-handler}
when control enters @var{proc}, @var{return-handler} on a normal return,
and @var{abort-handler} on a nonlocal exit.
@@ -1178,14 +1189,14 @@ Note that rewinds are not handled, so there is no rewind handler.
@end deffn
@deffn {Scheme Procedure} trap-calls-in-dynamic-extent proc @
- apply-handler return-handler [#:current-frame] [#:vm] [#:closure?]
+ apply-handler return-handler [#:current-frame] [#:vm]
A trap that calls @var{apply-handler} every time a procedure is applied,
and @var{return-handler} for returns, but only during the dynamic extent
of an application of @var{proc}.
@end deffn
@deffn {Scheme Procedure} trap-instructions-in-dynamic-extent proc @
- next-handler [#:current-frame] [#:vm] [#:closure?]
+ next-handler [#:current-frame] [#:vm]
A trap that calls @var{next-handler} for all retired instructions within
the dynamic extent of a call to @var{proc}.
@end deffn
diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index 296f1da5a..7a4c8c975 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -22,6 +22,7 @@ loading, evaluating, and compiling Scheme code at run time.
* Delayed Evaluation:: Postponing evaluation until it is needed.
* Local Evaluation:: Evaluation in a local lexical environment.
* Local Inclusion:: Compile-time inclusion of one file in another.
+* Sandboxed Evaluation:: Evaluation with limited capabilities.
* REPL Servers:: Serving a REPL over a socket.
* Cooperative REPL Servers:: REPL server for single-threaded applications.
@end menu
@@ -136,6 +137,7 @@ an expression to be evaluated and inserted. The comma syntax @code{,}
is simply a shorthand for an @code{unquote} form. For example,
@example
+`(1 2 (* 9 9) 3 4) @result{} (1 2 (* 9 9) 3 4)
`(1 2 ,(* 9 9) 3 4) @result{} (1 2 81 3 4)
`(1 (unquote (+ 1 1)) 3) @result{} (1 2 3)
`#(1 ,(/ 12 2)) @result{} #(1 6)
@@ -153,8 +155,9 @@ the returned list inserted. @var{expr} must evaluate to a list. The
@example
(define x '(2 3))
+`(1 ,x 4) @result{} (1 (2 3) 4)
`(1 ,@@x 4) @result{} (1 2 3 4)
-`(1 (unquote-splicing (map 1+ x))) @result{} (1 3 4)
+`(1 (unquote-splicing (map 1+ x))) @result{} (1 3 4)
`#(9 ,@@x 9) @result{} #(9 2 3 9)
@end example
@@ -1225,6 +1228,270 @@ the source files for a package (as you should!). It makes it possible
to evaluate an installed file from source, instead of relying on the
@code{.go} file being up to date.
+@node Sandboxed Evaluation
+@subsection Sandboxed Evaluation
+
+Sometimes you would like to evaluate code that comes from an untrusted
+party. The safest way to do this is to buy a new computer, evaluate the
+code on that computer, then throw the machine away. However if you are
+unwilling to take this simple approach, Guile does include a limited
+``sandbox'' facility that can allow untrusted code to be evaluated with
+some confidence.
+
+To use the sandboxed evaluator, load its module:
+
+@example
+(use-modules (ice-9 sandbox))
+@end example
+
+Guile's sandboxing facility starts with the ability to restrict the time
+and space used by a piece of code.
+
+@deffn {Scheme Procedure} call-with-time-limit limit thunk limit-reached
+Call @var{thunk}, but cancel it if @var{limit} seconds of wall-clock
+time have elapsed. If the computation is cancelled, call
+@var{limit-reached} in tail position. @var{thunk} must not disable
+interrupts or prevent an abort via a @code{dynamic-wind} unwind handler.
+@end deffn
+
+@deffn {Scheme Procedure} call-with-allocation-limit limit thunk limit-reached
+Call @var{thunk}, but cancel it if @var{limit} bytes have been
+allocated. If the computation is cancelled, call @var{limit-reached} in
+tail position. @var{thunk} must not disable interrupts or prevent an
+abort via a @code{dynamic-wind} unwind handler.
+
+This limit applies to both stack and heap allocation. The computation
+will not be aborted before @var{limit} bytes have been allocated, but
+for the heap allocation limit, the check may be postponed until the next garbage collection.
+
+Note that as a current shortcoming, the heap size limit applies to all
+threads; concurrent allocation by other unrelated threads counts towards
+the allocation limit.
+@end deffn
+
+@deffn {Scheme Procedure} call-with-time-and-allocation-limits time-limit allocation-limit thunk
+Invoke @var{thunk} in a dynamic extent in which its execution is limited
+to @var{time-limit} seconds of wall-clock time, and its allocation to
+@var{allocation-limit} bytes. @var{thunk} must not disable interrupts
+or prevent an abort via a @code{dynamic-wind} unwind handler.
+
+If successful, return all values produced by invoking @var{thunk}. Any
+uncaught exception thrown by the thunk will propagate out. If the time
+or allocation limit is exceeded, an exception will be thrown to the
+@code{limit-exceeded} key.
+@end deffn
+
+The time limit and stack limit are both very precise, but the heap limit
+only gets checked asynchronously, after a garbage collection. In
+particular, if the heap is already very large, the number of allocated
+bytes between garbage collections will be large, and therefore the
+precision of the check is reduced.
+
+Additionally, due to the mechanism used by the allocation limit (the
+@code{after-gc-hook}), large single allocations like @code{(make-vector
+#e1e7)} are only detected after the allocation completes, even if the
+allocation itself causes garbage collection. It's possible therefore
+for user code to not only exceed the allocation limit set, but also to
+exhaust all available memory, causing out-of-memory conditions at any
+allocation site. Failure to allocate memory in Guile itself should be
+safe and cause an exception to be thrown, but most systems are not
+designed to handle @code{malloc} failures. An allocation failure may
+therefore exercise unexpected code paths in your system, so it is a
+weakness of the sandbox (and therefore an interesting point of attack).
+
+The main sandbox interface is @code{eval-in-sandbox}.
+
+@deffn {Scheme Procedure} eval-in-sandbox exp [#:time-limit 0.1] @
+ [#:allocation-limit #e10e6] @
+ [#:bindings all-pure-bindings] @
+ [#:module (make-sandbox-module bindings)] @
+ [#:sever-module? #t]
+Evaluate the Scheme expression @var{exp} within an isolated
+"sandbox". Limit its execution to @var{time-limit} seconds of
+wall-clock time, and limit its allocation to @var{allocation-limit}
+bytes.
+
+The evaluation will occur in @var{module}, which defaults to the result
+of calling @code{make-sandbox-module} on @var{bindings}, which itself
+defaults to @code{all-pure-bindings}. This is the core of the
+sandbox: creating a scope for the expression that is @dfn{safe}.
+
+A safe sandbox module has two characteristics. Firstly, it will not
+allow the expression being evaluated to avoid being cancelled due to
+time or allocation limits. This ensures that the expression terminates
+in a timely fashion.
+
+Secondly, a safe sandbox module will prevent the evaluation from
+receiving information from previous evaluations, or from affecting
+future evaluations. All combinations of binding sets exported by
+@code{(ice-9 sandbox)} form safe sandbox modules.
+
+The @var{bindings} should be given as a list of import sets. One import
+set is a list whose car names an interface, like @code{(ice-9 q)}, and
+whose cdr is a list of imports. An import is either a bare symbol or a
+pair of @code{(@var{out} . @var{in})}, where @var{out} and @var{in} are
+both symbols and denote the name under which a binding is exported from
+the module, and the name under which to make the binding available,
+respectively. Note that @var{bindings} is only used as an input to the
+default initializer for the @var{module} argument; if you pass
+@code{#:module}, @var{bindings} is unused. If @var{sever-module?} is
+true (the default), the module will be unlinked from the global module
+tree after the evaluation returns, to allow @var{mod} to be
+garbage-collected.
+
+If successful, return all values produced by @var{exp}. Any uncaught
+exception thrown by the expression will propagate out. If the time or
+allocation limit is exceeded, an exception will be thrown to the
+@code{limit-exceeded} key.
+@end deffn
+
+Constructing a safe sandbox module is tricky in general. Guile defines
+an easy way to construct safe modules from predefined sets of bindings.
+Before getting to that interface, here are some general notes on safety.
+
+@enumerate
+@item The time and allocation limits rely on the ability to interrupt
+and cancel a computation. For this reason, no binding included in a
+sandbox module should be able to indefinitely postpone interrupt
+handling, nor should a binding be able to prevent an abort. In practice
+this second consideration means that @code{dynamic-wind} should not be
+included in any binding set.
+@item The time and allocation limits apply only to the
+@code{eval-in-sandbox} call. If the call returns a procedure which is
+later called, no limit is ``automatically'' in place. Users of
+@code{eval-in-sandbox} have to be very careful to reimpose limits when
+calling procedures that escape from sandboxes.
+@item Similarly, the dynamic environment of the @code{eval-in-sandbox}
+call is not necessarily in place when any procedure that escapes from
+the sandbox is later called.
+
+This detail prevents us from exposing @code{primitive-eval} to the
+sandbox, for two reasons. The first is that it's possible for legacy
+code to forge references to any binding, if the
+@code{allow-legacy-syntax-objects?} parameter is true. The default for
+this parameter is true; @pxref{Syntax Transformer Helpers} for the
+details. The parameter is bound to @code{#f} for the duration of the
+@code{eval-in-sandbox} call itself, but that will not be in place during
+calls to escaped procedures.
+
+The second reason we don't expose @code{primitive-eval} is that
+@code{primitive-eval} implicitly works in the current module, which for
+an escaped procedure will probably be different than the module that is
+current for the @code{eval-in-sandbox} call itself.
+
+The common denominator here is that if an interface exposed to the
+sandbox relies on dynamic environments, it is easy to mistakenly grant
+the sandboxed procedure additional capabilities in the form of bindings
+that it should not have access to. For this reason, the default sets of
+predefined bindings do not depend on any dynamically scoped value.
+@item Mutation may allow a sandboxed evaluation to break some invariant
+in users of data supplied to it. A lot of code culturally doesn't
+expect mutation, but if you hand mutable data to a sandboxed evaluation
+and you also grant mutating capabilities to that evaluation, then the
+sandboxed code may indeed mutate that data. The default set of bindings
+to the sandbox do not include any mutating primitives.
+
+Relatedly, @code{set!} may allow a sandbox to mutate a primitive,
+invalidating many system-wide invariants. Guile is currently quite
+permissive when it comes to imported bindings and mutability. Although
+@code{set!} to a module-local or lexically bound variable would be fine,
+we don't currently have an easy way to disallow @code{set!} to an
+imported binding, so currently no binding set includes @code{set!}.
+@item Mutation may allow a sandboxed evaluation to keep state, or
+make a communication mechanism with other code. On the one hand this
+sounds cool, but on the other hand maybe this is part of your threat
+model. Again, the default set of bindings doesn't include mutating
+primitives, preventing sandboxed evaluations from keeping state.
+@item The sandbox should probably not be able to open a network
+connection, or write to a file, or open a file from disk. The default
+binding set includes no interaction with the operating system.
+@end enumerate
+
+If you, dear reader, find the above discussion interesting, you will
+enjoy Jonathan Rees' dissertation, ``A Security Kernel Based on the
+Lambda Calculus''.
+
+@defvr {Scheme Variable} all-pure-bindings
+All ``pure'' bindings that together form a safe subset of those bindings
+available by default to Guile user code.
+@end defvr
+
+@defvr {Scheme Variable} all-pure-and-impure-bindings
+Like @code{all-pure-bindings}, but additionally including mutating
+primitives like @code{vector-set!}. This set is still safe in the sense
+mentioned above, with the caveats about mutation.
+@end defvr
+
+The components of these composite sets are as follows:
+@defvr {Scheme Variable} alist-bindings
+@defvrx {Scheme Variable} array-bindings
+@defvrx {Scheme Variable} bit-bindings
+@defvrx {Scheme Variable} bitvector-bindings
+@defvrx {Scheme Variable} char-bindings
+@defvrx {Scheme Variable} char-set-bindings
+@defvrx {Scheme Variable} clock-bindings
+@defvrx {Scheme Variable} core-bindings
+@defvrx {Scheme Variable} error-bindings
+@defvrx {Scheme Variable} fluid-bindings
+@defvrx {Scheme Variable} hash-bindings
+@defvrx {Scheme Variable} iteration-bindings
+@defvrx {Scheme Variable} keyword-bindings
+@defvrx {Scheme Variable} list-bindings
+@defvrx {Scheme Variable} macro-bindings
+@defvrx {Scheme Variable} nil-bindings
+@defvrx {Scheme Variable} number-bindings
+@defvrx {Scheme Variable} pair-bindings
+@defvrx {Scheme Variable} predicate-bindings
+@defvrx {Scheme Variable} procedure-bindings
+@defvrx {Scheme Variable} promise-bindings
+@defvrx {Scheme Variable} prompt-bindings
+@defvrx {Scheme Variable} regexp-bindings
+@defvrx {Scheme Variable} sort-bindings
+@defvrx {Scheme Variable} srfi-4-bindings
+@defvrx {Scheme Variable} string-bindings
+@defvrx {Scheme Variable} symbol-bindings
+@defvrx {Scheme Variable} unspecified-bindings
+@defvrx {Scheme Variable} variable-bindings
+@defvrx {Scheme Variable} vector-bindings
+@defvrx {Scheme Variable} version-bindings
+The components of @code{all-pure-bindings}.
+@end defvr
+
+@defvr {Scheme Variable} mutating-alist-bindings
+@defvrx {Scheme Variable} mutating-array-bindings
+@defvrx {Scheme Variable} mutating-bitvector-bindings
+@defvrx {Scheme Variable} mutating-fluid-bindings
+@defvrx {Scheme Variable} mutating-hash-bindings
+@defvrx {Scheme Variable} mutating-list-bindings
+@defvrx {Scheme Variable} mutating-pair-bindings
+@defvrx {Scheme Variable} mutating-sort-bindings
+@defvrx {Scheme Variable} mutating-srfi-4-bindings
+@defvrx {Scheme Variable} mutating-string-bindings
+@defvrx {Scheme Variable} mutating-variable-bindings
+@defvrx {Scheme Variable} mutating-vector-bindings
+The additional components of @code{all-pure-and-impure-bindings}.
+@end defvr
+
+Finally, what do you do with a binding set? What is a binding set
+anyway? @code{make-sandbox-module} is here for you.
+
+@deffn {Scheme Procedure} make-sandbox-module bindings
+Return a fresh module that only contains @var{bindings}.
+
+The @var{bindings} should be given as a list of import sets. One import
+set is a list whose car names an interface, like @code{(ice-9 q)}, and
+whose cdr is a list of imports. An import is either a bare symbol or a
+pair of @code{(@var{out} . @var{in})}, where @var{out} and @var{in} are
+both symbols and denote the name under which a binding is exported from
+the module, and the name under which to make the binding available,
+respectively.
+@end deffn
+
+So you see that binding sets are just lists, and
+@code{all-pure-and-impure-bindings} is really just the result of
+appending all of the component binding sets.
+
+
@node REPL Servers
@subsection REPL Servers
diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index c2c49ec48..bb93d6d1f 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2008,
-@c 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+@c Copyright (C) 1996, 1997, 2000-2004, 2007-2014, 2016-2017
+@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Foreign Function Interface
@@ -52,7 +52,7 @@ automatically the next time they are run.
Now, when all the necessary machinery is there to perform part of the
linking at run-time, why not take the next step and allow the programmer
-to explicitly take advantage of it from within his program? Of course,
+to explicitly take advantage of it from within their program? Of course,
many operating systems that support shared libraries do just that, and
chances are that Guile will allow you to access this feature from within
your Scheme programs. As you might have guessed already, this feature
@@ -89,6 +89,11 @@ When @var{library} is omitted, a @dfn{global symbol handle} is returned. This
handle provides access to the symbols available to the program at run-time,
including those exported by the program itself and the shared libraries already
loaded.
+
+Note that on hosts that use dynamic-link libraries (DLLs), the global
+symbol handle may not be able to provide access to symbols from
+recursively-loaded DLLs. Only exported symbols from those DLLs directly
+loaded by the program may be available.
@end deffn
@deffn {Scheme Procedure} dynamic-object? obj
@@ -488,6 +493,8 @@ platform-dependent size:
@defvrx {Scheme Variable} unsigned-int
@defvrx {Scheme Variable} long
@defvrx {Scheme Variable} unsigned-long
+@defvrx {Scheme Variable} short
+@defvrx {Scheme Variable} unsigned-short
@defvrx {Scheme Variable} size_t
@defvrx {Scheme Variable} ssize_t
@defvrx {Scheme Variable} ptrdiff_t
@@ -813,8 +820,11 @@ tightly packed structs and unions by hand. See the code for
Of course, the land of C is not all nouns and no verbs: there are
functions too, and Guile allows you to call them.
-@deffn {Scheme Procedure} pointer->procedure return_type func_ptr arg_types
-@deffnx {C Procedure} scm_pointer_to_procedure (return_type, func_ptr, arg_types)
+@deffn {Scheme Procedure} pointer->procedure return_type func_ptr arg_types @
+ [#:return-errno?=#f]
+@deffnx {C Function} scm_pointer_to_procedure (return_type, func_ptr, arg_types)
+@deffnx {C Function} scm_pointer_to_procedure_with_errno (return_type, func_ptr, arg_types)
+
Make a foreign function.
Given the foreign void pointer @var{func_ptr}, its argument and
@@ -825,6 +835,10 @@ and return appropriate values.
@var{arg_types} should be a list of foreign types.
@code{return_type} should be a foreign type. @xref{Foreign Types}, for
more information on foreign types.
+
+If @var{return-errno?} is true, or when calling
+@code{scm_pointer_to_procedure_with_errno}, the returned procedure will
+return two values, with @code{errno} as the second value.
@end deffn
Here is a better definition of @code{(math bessel)}:
diff --git a/doc/ref/api-i18n.texi b/doc/ref/api-i18n.texi
index fa3fe99d0..0a27285b1 100644
--- a/doc/ref/api-i18n.texi
+++ b/doc/ref/api-i18n.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2009, 2010
-@c Free Software Foundation, Inc.
+@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007,
+@c 2009, 2010, 2017 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Internationalization
@@ -263,8 +263,10 @@ Reference Manual}).
@deffn {Scheme Procedure} number->locale-string number [fraction-digits [locale]]
Convert @var{number} (an inexact) into a string according to the
cultural conventions of either @var{locale} (a locale object) or the
-current locale. Optionally, @var{fraction-digits} may be bound to an
-integer specifying the number of fractional digits to be displayed.
+current locale. By default, print as many fractional digits as
+necessary, up to an upper bound. Optionally, @var{fraction-digits} may
+be bound to an integer specifying the number of fractional digits to be
+displayed.
@end deffn
@deffn {Scheme Procedure} monetary-amount->locale-string amount intl? [locale]
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index e1501e2b4..9bd78d229 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1,24 +1,27 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2009,
-@c 2010, 2011, 2013 Free Software Foundation, Inc.
+@c 2010, 2011, 2013, 2016 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Input and Output
@section Input and Output
@menu
-* Ports:: The idea of the port abstraction.
-* Reading:: Procedures for reading from a port.
-* Writing:: Procedures for writing to a port.
-* Closing:: Procedures to close a port.
+* Ports:: What's a port?
+* Binary I/O:: Reading and writing bytes.
+* Encoding:: Characters as bytes.
+* Textual I/O:: Reading and writing characters.
+* Simple Output:: Simple syntactic sugar solution.
+* Buffering:: Controlling when data is written to ports.
* Random Access:: Moving around a random access port.
* Line/Delimited:: Read and write lines or delimited text.
-* Block Reading and Writing:: Reading and writing blocks of text.
* Default Ports:: Defaults for input, output and errors.
* Port Types:: Types of port and how to make them.
-* R6RS I/O Ports:: The R6RS port API.
-* I/O Extensions:: Using and extending ports in C.
+* Venerable Port Interfaces:: Procedures from the last millenium.
+* Using Ports from C:: Nice interfaces for C.
+* I/O Extensions:: Implementing new port types in C.
+* Non-Blocking I/O:: How Guile deals with EWOULDBLOCK.
* BOM Handling:: Handling of Unicode byte order marks.
@end menu
@@ -27,66 +30,67 @@
@subsection Ports
@cindex Port
-Sequential input/output in Scheme is represented by operations on a
-@dfn{port}. This chapter explains the operations that Guile provides
-for working with ports.
+Ports are the way that Guile performs input and output. Guile can read
+in characters or bytes from an @dfn{input port}, or write them out to an
+@dfn{output port}. Some ports support both interfaces.
-Ports are created by opening, for instance @code{open-file} for a file
-(@pxref{File Ports}). Characters can be read from an input port and
-written to an output port, or both on an input/output port. A port
-can be closed (@pxref{Closing}) when no longer required, after which
-any attempt to read or write is an error.
+There are a number of different port types implemented in Guile. File
+ports provide input and output over files, as you might imagine. For
+example, we might display a string to a file like this:
-The formal definition of a port is very generic: an input port is
-simply ``an object which can deliver characters on demand,'' and an
-output port is ``an object which can accept characters.'' Because
-this definition is so loose, it is easy to write functions that
-simulate ports in software. @dfn{Soft ports} and @dfn{string ports}
-are two interesting and powerful examples of this technique.
-(@pxref{Soft Ports}, and @ref{String Ports}.)
+@example
+(let ((port (open-output-file "foo.txt")))
+ (display "Hello, world!\n" port)
+ (close-port port))
+@end example
-Ports are garbage collected in the usual way (@pxref{Memory
-Management}), and will be closed at that time if not already closed.
-In this case any errors occurring in the close will not be reported.
-Usually a program will want to explicitly close so as to be sure all
-its operations have been successful. Of course if a program has
-abandoned something due to an error or other condition then closing
-problems are probably not of interest.
+There are also string ports, for taking input from a string, or
+collecting output to a string; bytevector ports, for doing the same but
+using a bytevector as a source or sink of data; and soft ports, for
+arranging to call Scheme functions to provide input or handle output.
+@xref{Port Types}.
-It is strongly recommended that file ports be closed explicitly when
-no longer required. Most systems have limits on how many files can be
-open, both on a per-process and a system-wide basis. A program that
-uses many files should take care not to hit those limits. The same
-applies to similar system resources such as pipes and sockets.
+Ports should be @dfn{closed} when they are not needed by calling
+@code{close-port} on them, as in the example above. This will make sure
+that any pending output is successfully written out to disk, in the case
+of a file port, or otherwise to whatever mutable store is backed by the
+port. Any error that occurs while writing out that buffered data would
+also be raised promptly at the @code{close-port}, and not later when the
+port is closed by the garbage collector. @xref{Buffering}, for more on
+buffered output.
-Note that automatic garbage collection is triggered only by memory
-consumption, not by file or other resource usage, so a program cannot
-rely on that to keep it away from system limits. An explicit call to
-@code{gc} can of course be relied on to pick up unreferenced ports.
-If program flow makes it hard to be certain when to close then this
-may be an acceptable way to control resource usage.
+Closing a port also releases any precious resource the file might have.
+Usually in Scheme a programmer doesn't have to clean up after their data
+structures (@pxref{Memory Management}), but most systems have strict
+limits on how many files can be open, both on a per-process and a
+system-wide basis. A program that uses many files should take care not
+to hit those limits. The same applies to similar system resources such
+as pipes and sockets.
-All file access uses the ``LFS'' large file support functions when
-available, so files bigger than 2 Gbytes (@math{2^31} bytes) can be
-read and written on a 32-bit system.
+Indeed for these reasons the above example is not the most idiomatic way
+to use ports. It is more common to acquire ports via procedures like
+@code{call-with-output-file}, which handle the @code{close-port}
+automatically:
-Each port has an associated character encoding that controls how bytes
-read from the port are converted to characters and string and controls
-how characters and strings written to the port are converted to bytes.
-When ports are created, they inherit their character encoding from the
-current locale, but, that can be modified after the port is created.
+@example
+(call-with-output-file "foo.txt"
+ (lambda (port)
+ (display "Hello, world!\n" port)))
+@end example
-Currently, the ports only work with @emph{non-modal} encodings. Most
-encodings are non-modal, meaning that the conversion of bytes to a
-string doesn't depend on its context: the same byte sequence will always
-return the same string. A couple of modal encodings are in common use,
-like ISO-2022-JP and ISO-2022-KR, and they are not yet supported.
+Finally, all ports have associated input and output buffers, as
+appropriate. Buffering is a common strategy to limit the overhead of
+small reads and writes: without buffering, each character fetched from a
+file would involve at least one call into the kernel, and maybe more
+depending on the character and the encoding. Instead, Guile will batch
+reads and writes into internal buffers. However, sometimes you want to
+make output on a port show up immediately. @xref{Buffering}, for more
+on interfaces to control port buffering.
-Each port also has an associated conversion strategy: what to do when
-a Guile character can't be converted to the port's encoded character
-representation for output. There are three possible strategies: to
-raise an error, to replace the character with a hex escape, or to
-replace the character with a substitute character.
+@deffn {Scheme Procedure} port? x
+@deffnx {C Function} scm_port_p (x)
+Return a boolean indicating whether @var{x} is a port.
+@end deffn
@rnindex input-port?
@deffn {Scheme Procedure} input-port? x
@@ -104,184 +108,542 @@ Return @code{#t} if @var{x} is an output port, otherwise return
@code{port?}.
@end deffn
-@deffn {Scheme Procedure} port? x
-@deffnx {C Function} scm_port_p (x)
-Return a boolean indicating whether @var{x} is a port.
-Equivalent to @code{(or (input-port? @var{x}) (output-port?
-@var{x}))}.
+@cindex Closing ports
+@cindex Port, close
+@deffn {Scheme Procedure} close-port port
+@deffnx {C Function} scm_close_port (port)
+Close the specified port object. Return @code{#t} if it successfully
+closes a port or @code{#f} if it was already closed. An exception may
+be raised if an error occurs, for example when flushing buffered output.
+@xref{Buffering}, for more on buffered output. See also @ref{Ports and
+File Descriptors, close}, for a procedure which can close file
+descriptors.
+@end deffn
+
+@deffn {Scheme Procedure} port-closed? port
+@deffnx {C Function} scm_port_closed_p (port)
+Return @code{#t} if @var{port} is closed or @code{#f} if it is
+open.
+@end deffn
+
+
+@node Binary I/O
+@subsection Binary I/O
+
+Guile's ports are fundamentally binary in nature: at the lowest level,
+they work on bytes. This section describes Guile's core binary I/O
+operations. @xref{Textual I/O}, for input and output of strings and
+characters.
+
+To use these routines, first include the binary I/O module:
+
+@example
+(use-modules (ice-9 binary-ports))
+@end example
+
+Note that although this module's name suggests that binary ports are
+some different kind of port, that's not the case: all ports in Guile are
+both binary and textual ports.
+
+@cindex binary input
+@deffn {Scheme Procedure} get-u8 port
+@deffnx {C Function} scm_get_u8 (port)
+Return an octet read from @var{port}, an input port, blocking as
+necessary, or the end-of-file object.
+@end deffn
+
+@deffn {Scheme Procedure} lookahead-u8 port
+@deffnx {C Function} scm_lookahead_u8 (port)
+Like @code{get-u8} but does not update @var{port}'s position to point
+past the octet.
+@end deffn
+
+The end-of-file object is unlike any other kind of object: it's not a
+pair, a symbol, or anything else. To check if a value is the
+end-of-file object, use the @code{eof-object?} predicate.
+
+@rnindex eof-object?
+@cindex End of file object
+@deffn {Scheme Procedure} eof-object? x
+@deffnx {C Function} scm_eof_object_p (x)
+Return @code{#t} if @var{x} is an end-of-file object, or @code{#f}
+otherwise.
+@end deffn
+
+Note that unlike other procedures in this module, @code{eof-object?} is
+defined in the default environment.
+
+@deffn {Scheme Procedure} get-bytevector-n port count
+@deffnx {C Function} scm_get_bytevector_n (port, count)
+Read @var{count} octets from @var{port}, blocking as necessary and
+return a bytevector containing the octets read. If fewer bytes are
+available, a bytevector smaller than @var{count} is returned.
+@end deffn
+
+@deffn {Scheme Procedure} get-bytevector-n! port bv start count
+@deffnx {C Function} scm_get_bytevector_n_x (port, bv, start, count)
+Read @var{count} bytes from @var{port} and store them in @var{bv}
+starting at index @var{start}. Return either the number of bytes
+actually read or the end-of-file object.
+@end deffn
+
+@deffn {Scheme Procedure} get-bytevector-some port
+@deffnx {C Function} scm_get_bytevector_some (port)
+Read from @var{port}, blocking as necessary, until bytes are available
+or an end-of-file is reached. Return either the end-of-file object or a
+new bytevector containing some of the available bytes (at least one),
+and update the port position to point just past these bytes.
+@end deffn
+
+@deffn {Scheme Procedure} get-bytevector-all port
+@deffnx {C Function} scm_get_bytevector_all (port)
+Read from @var{port}, blocking as necessary, until the end-of-file is
+reached. Return either a new bytevector containing the data read or the
+end-of-file object (if no data were available).
+@end deffn
+
+@deffn {Scheme Procedure} unget-bytevector port bv [start [count]]
+@deffnx {C Function} scm_unget_bytevector (port, bv, start, count)
+Place the contents of @var{bv} in @var{port}, optionally starting at
+index @var{start} and limiting to @var{count} octets, so that its bytes
+will be read from left-to-right as the next bytes from @var{port} during
+subsequent read operations. If called multiple times, the unread bytes
+will be read again in last-in first-out order.
+@end deffn
+
+@cindex binary output
+To perform binary output on a port, use @code{put-u8} or
+@code{put-bytevector}.
+
+@deffn {Scheme Procedure} put-u8 port octet
+@deffnx {C Function} scm_put_u8 (port, octet)
+Write @var{octet}, an integer in the 0--255 range, to @var{port}, a
+binary output port.
+@end deffn
+
+@deffn {Scheme Procedure} put-bytevector port bv [start [count]]
+@deffnx {C Function} scm_put_bytevector (port, bv, start, count)
+Write the contents of @var{bv} to @var{port}, optionally starting at
+index @var{start} and limiting to @var{count} octets.
+@end deffn
+
+@node Encoding
+@subsection Encoding
+
+Textual input and output on Guile ports is layered on top of binary
+operations. To this end, each port has an associated character encoding
+that controls how bytes read from the port are converted to characters,
+and how characters written to the port are converted to bytes.
+
+@deffn {Scheme Procedure} port-encoding port
+@deffnx {C Function} scm_port_encoding (port)
+Returns, as a string, the character encoding that @var{port} uses to
+interpret its input and output.
@end deffn
@deffn {Scheme Procedure} set-port-encoding! port enc
@deffnx {C Function} scm_set_port_encoding_x (port, enc)
-Sets the character encoding that will be used to interpret all port I/O.
-@var{enc} is a string containing the name of an encoding. Valid
-encoding names are those
-@url{http://www.iana.org/assignments/character-sets, defined by IANA}.
+Sets the character encoding that will be used to interpret I/O to
+@var{port}. @var{enc} is a string containing the name of an encoding.
+Valid encoding names are those
+@url{http://www.iana.org/assignments/character-sets, defined by IANA},
+for example @code{"UTF-8"} or @code{"ISO-8859-1"}.
@end deffn
+When ports are created, they are assigned an encoding. The usual
+process to determine the initial encoding for a port is to take the
+value of the @code{%default-port-encoding} fluid.
+
@defvr {Scheme Variable} %default-port-encoding
-A fluid containing @code{#f} or the name of the encoding to
-be used by default for newly created ports (@pxref{Fluids and Dynamic
-States}). The value @code{#f} is equivalent to @code{"ISO-8859-1"}.
-
-New ports are created with the encoding appropriate for the current
-locale if @code{setlocale} has been called or the value specified by
-this fluid otherwise.
+A fluid containing name of the encoding to be used by default for newly
+created ports (@pxref{Fluids and Dynamic States}). As a special case,
+the value @code{#f} is equivalent to @code{"ISO-8859-1"}.
@end defvr
-@deffn {Scheme Procedure} port-encoding port
-@deffnx {C Function} scm_port_encoding (port)
-Returns, as a string, the character encoding that @var{port} uses to interpret
-its input and output. The value @code{#f} is equivalent to @code{"ISO-8859-1"}.
-@end deffn
+The @code{%default-port-encoding} itself defaults to the encoding
+appropriate for the current locale, if @code{setlocale} has been called.
+@xref{Locales}, for more on locales and when you might need to call
+@code{setlocale} explicitly.
-@deffn {Scheme Procedure} set-port-conversion-strategy! port sym
-@deffnx {C Function} scm_set_port_conversion_strategy_x (port, sym)
-Sets the behavior of the interpreter when outputting a character that
-is not representable in the port's current encoding. @var{sym} can be
-either @code{'error}, @code{'substitute}, or @code{'escape}. If it is
-@code{'error}, an error will be thrown when an nonconvertible character
-is encountered. If it is @code{'substitute}, then nonconvertible
-characters will be replaced with approximate characters, or with
-question marks if no approximately correct character is available. If
-it is @code{'escape}, it will appear as a hex escape when output.
+Some port types have other ways of determining their initial locales.
+String ports, for example, default to the UTF-8 encoding, in order to be
+able to represent all characters regardless of the current locale. File
+ports can optionally sniff their file for a @code{coding:} declaration;
+@xref{File Ports}. Binary ports might be initialized to the ISO-8859-1
+encoding in which each codepoint between 0 and 255 corresponds to a byte
+with that value.
-If @var{port} is an open port, the conversion error behavior
-is set for that port. If it is @code{#f}, it is set as the
-default behavior for any future ports that get created in
-this thread.
-@end deffn
+Currently, the ports only work with @emph{non-modal} encodings. Most
+encodings are non-modal, meaning that the conversion of bytes to a
+string doesn't depend on its context: the same byte sequence will always
+return the same string. A couple of modal encodings are in common use,
+like ISO-2022-JP and ISO-2022-KR, and they are not yet supported.
+
+@cindex port conversion strategy
+@cindex conversion strategy, port
+@cindex decoding error
+@cindex encoding error
+Each port also has an associated conversion strategy, which determines
+what to do when a Guile character can't be converted to the port's
+encoded character representation for output. There are three possible
+strategies: to raise an error, to replace the character with a hex
+escape, or to replace the character with a substitute character. Port
+conversion strategies are also used when decoding characters from an
+input port.
@deffn {Scheme Procedure} port-conversion-strategy port
@deffnx {C Function} scm_port_conversion_strategy (port)
-Returns the behavior of the port when outputting a character that is
-not representable in the port's current encoding. It returns the
-symbol @code{error} if unrepresentable characters should cause
-exceptions, @code{substitute} if the port should try to replace
-unrepresentable characters with question marks or approximate
-characters, or @code{escape} if unrepresentable characters should be
-converted to string escapes.
+Returns the behavior of the port when outputting a character that is not
+representable in the port's current encoding.
If @var{port} is @code{#f}, then the current default behavior will be
returned. New ports will have this default behavior when they are
created.
@end deffn
+@deffn {Scheme Procedure} set-port-conversion-strategy! port sym
+@deffnx {C Function} scm_set_port_conversion_strategy_x (port, sym)
+Sets the behavior of Guile when outputting a character that is not
+representable in the port's current encoding, or when Guile encounters a
+decoding error when trying to read a character. @var{sym} can be either
+@code{error}, @code{substitute}, or @code{escape}.
+
+If @var{port} is an open port, the conversion error behavior is set for
+that port. If it is @code{#f}, it is set as the default behavior for
+any future ports that get created in this thread.
+@end deffn
+
+As with port encodings, there is a fluid which determines the initial
+conversion strategy for a port.
+
@deffn {Scheme Variable} %default-port-conversion-strategy
The fluid that defines the conversion strategy for newly created ports,
-and for other conversion routines such as @code{scm_to_stringn},
+and also for other conversion routines such as @code{scm_to_stringn},
@code{scm_from_stringn}, @code{string->pointer}, and
@code{pointer->string}.
Its value must be one of the symbols described above, with the same
-semantics: @code{'error}, @code{'substitute}, or @code{'escape}.
+semantics: @code{error}, @code{substitute}, or @code{escape}.
-When Guile starts, its value is @code{'substitute}.
+When Guile starts, its value is @code{substitute}.
Note that @code{(set-port-conversion-strategy! #f @var{sym})} is
equivalent to @code{(fluid-set! %default-port-conversion-strategy
@var{sym})}.
@end deffn
+As mentioned above, for an output port there are three possible port
+conversion strategies. The @code{error} strategy will throw an error
+when a nonconvertible character is encountered. The @code{substitute}
+strategy will replace nonconvertible characters with a question mark
+(@samp{?}). Finally the @code{escape} strategy will print
+nonconvertible characters as a hex escape, using the escaping that is
+recognized by Guile's string syntax. Note that if the port's encoding
+is a Unicode encoding, like @code{UTF-8}, then encoding errors are
+impossible.
-@node Reading
-@subsection Reading
-@cindex Reading
+For an input port, the @code{error} strategy will cause Guile to throw
+an error if it encounters an invalid encoding, such as might happen if
+you tried to read @code{ISO-8859-1} as @code{UTF-8}. The error is
+thrown before advancing the read position. The @code{substitute}
+strategy will replace the bad bytes with a U+FFFD replacement character,
+in accordance with Unicode recommendations. When reading from an input
+port, the @code{escape} strategy is treated as if it were @code{error}.
-[Generic procedures for reading from ports.]
-These procedures pertain to reading characters and strings from
-ports. To read general S-expressions from ports, @xref{Scheme Read}.
+@node Textual I/O
+@subsection Textual I/O
+@cindex textual input
+@cindex textual output
-@rnindex eof-object?
-@cindex End of file object
-@deffn {Scheme Procedure} eof-object? x
-@deffnx {C Function} scm_eof_object_p (x)
-Return @code{#t} if @var{x} is an end-of-file object; otherwise
-return @code{#f}.
+This section describes Guile's core textual I/O operations on characters
+and strings. @xref{Binary I/O}, for input and output of bytes and
+bytevectors. @xref{Encoding}, for more on how characters relate to
+bytes. To read general S-expressions from ports, @xref{Scheme Read}.
+@xref{Scheme Write}, for interfaces that write generic Scheme datums.
+
+To use these routines, first include the textual I/O module:
+
+@example
+(use-modules (ice-9 textual-ports))
+@end example
+
+Note that although this module's name suggests that textual ports are
+some different kind of port, that's not the case: all ports in Guile are
+both binary and textual ports.
+
+@deffn {Scheme Procedure} get-char input-port
+Reads from @var{input-port}, blocking as necessary, until a
+complete character is available from @var{input-port},
+or until an end of file is reached.
+
+If a complete character is available before the next end of file,
+@code{get-char} returns that character and updates the input port to
+point past the character. If an end of file is reached before any
+character is read, @code{get-char} returns the end-of-file object.
@end deffn
-@rnindex char-ready?
-@deffn {Scheme Procedure} char-ready? [port]
-@deffnx {C Function} scm_char_ready_p (port)
-Return @code{#t} if a character is ready on input @var{port}
-and return @code{#f} otherwise. If @code{char-ready?} returns
-@code{#t} then the next @code{read-char} operation on
-@var{port} is guaranteed not to hang. If @var{port} is a file
-port at end of file then @code{char-ready?} returns @code{#t}.
-
-@code{char-ready?} exists to make it possible for a
-program to accept characters from interactive ports without
-getting stuck waiting for input. Any input editors associated
-with such ports must make sure that characters whose existence
-has been asserted by @code{char-ready?} cannot be rubbed out.
-If @code{char-ready?} were to return @code{#f} at end of file,
-a port at end of file would be indistinguishable from an
-interactive port that has no ready characters.
+@deffn {Scheme Procedure} lookahead-char input-port
+The @code{lookahead-char} procedure is like @code{get-char}, but it does
+not update @var{input-port} to point past the character.
@end deffn
-@rnindex read-char
-@deffn {Scheme Procedure} read-char [port]
-@deffnx {C Function} scm_read_char (port)
-Return the next character available from @var{port}, updating
-@var{port} to point to the following character. If no more
-characters are available, the end-of-file object is returned.
+In the same way that it's possible to "unget" a byte or bytes, it's
+possible to "unget" the bytes corresponding to an encoded character.
-When @var{port}'s data cannot be decoded according to its
-character encoding, a @code{decoding-error} is raised and
-@var{port} points past the erroneous byte sequence.
-@end deffn
-
-@deftypefn {C Function} size_t scm_c_read (SCM port, void *buffer, size_t size)
-Read up to @var{size} bytes from @var{port} and store them in
-@var{buffer}. The return value is the number of bytes actually read,
-which can be less than @var{size} if end-of-file has been reached.
-
-Note that this function does not update @code{port-line} and
-@code{port-column} below.
-@end deftypefn
-
-@rnindex peek-char
-@deffn {Scheme Procedure} peek-char [port]
-@deffnx {C Function} scm_peek_char (port)
-Return the next character available from @var{port},
-@emph{without} updating @var{port} to point to the following
-character. If no more characters are available, the
-end-of-file object is returned.
-
-The value returned by
-a call to @code{peek-char} is the same as the value that would
-have been returned by a call to @code{read-char} on the same
-port. The only difference is that the very next call to
-@code{read-char} or @code{peek-char} on that @var{port} will
-return the value returned by the preceding call to
-@code{peek-char}. In particular, a call to @code{peek-char} on
-an interactive port will hang waiting for input whenever a call
-to @code{read-char} would have hung.
-
-As for @code{read-char}, a @code{decoding-error} may be raised
-if such a situation occurs. However, unlike with @code{read-char},
-@var{port} still points at the beginning of the erroneous byte
-sequence when the error is raised.
-@end deffn
-
-@deffn {Scheme Procedure} unread-char cobj [port]
-@deffnx {C Function} scm_unread_char (cobj, port)
-Place character @var{cobj} in @var{port} so that it will be read by the
+@deffn {Scheme Procedure} unget-char port char
+Place character @var{char} in @var{port} so that it will be read by the
next read operation. If called multiple times, the unread characters
-will be read again in last-in first-out order. If @var{port} is
-not supplied, the current input port is used.
+will be read again in last-in first-out order.
@end deffn
-@deffn {Scheme Procedure} unread-string str port
-@deffnx {C Function} scm_unread_string (str, port)
+@deffn {Scheme Procedure} unget-string port str
Place the string @var{str} in @var{port} so that its characters will
be read from left-to-right as the next characters from @var{port}
during subsequent read operations. If called multiple times, the
-unread characters will be read again in last-in first-out order. If
-@var{port} is not supplied, the @code{current-input-port} is used.
+unread characters will be read again in last-in first-out order.
@end deffn
+Reading in a character at a time can be inefficient. If it's possible
+to perform I/O over multiple characters at a time, via strings, that
+might be faster.
+
+@deffn {Scheme Procedure} get-string-n input-port count
+The @code{get-string-n} procedure reads from @var{input-port}, blocking
+as necessary, until @var{count} characters are available, or until an
+end of file is reached. @var{count} must be an exact, non-negative
+integer, representing the number of characters to be read.
+
+If @var{count} characters are available before end of file,
+@code{get-string-n} returns a string consisting of those @var{count}
+characters. If fewer characters are available before an end of file, but
+one or more characters can be read, @code{get-string-n} returns a string
+containing those characters. In either case, the input port is updated
+to point just past the characters read. If no characters can be read
+before an end of file, the end-of-file object is returned.
+@end deffn
+
+@deffn {Scheme Procedure} get-string-n! input-port string start count
+The @code{get-string-n!} procedure reads from @var{input-port} in the
+same manner as @code{get-string-n}. @var{start} and @var{count} must be
+exact, non-negative integer objects, with @var{count} representing the
+number of characters to be read. @var{string} must be a string with at
+least $@var{start} + @var{count}$ characters.
+
+If @var{count} characters are available before an end of file, they are
+written into @var{string} starting at index @var{start}, and @var{count}
+is returned. If fewer characters are available before an end of file,
+but one or more can be read, those characters are written into
+@var{string} starting at index @var{start} and the number of characters
+actually read is returned as an exact integer object. If no characters
+can be read before an end of file, the end-of-file object is returned.
+@end deffn
+
+@deffn {Scheme Procedure} get-string-all input-port
+Reads from @var{input-port} until an end of file, decoding characters in
+the same manner as @code{get-string-n} and @code{get-string-n!}.
+
+If characters are available before the end of file, a string containing
+all the characters decoded from that data are returned. If no character
+precedes the end of file, the end-of-file object is returned.
+@end deffn
+
+@deffn {Scheme Procedure} get-line input-port
+Reads from @var{input-port} up to and including the linefeed
+character or end of file, decoding characters in the same manner as
+@code{get-string-n} and @code{get-string-n!}.
+
+If a linefeed character is read, a string containing all of the text up
+to (but not including) the linefeed character is returned, and the port
+is updated to point just past the linefeed character. If an end of file
+is encountered before any linefeed character is read, but some
+characters have been read and decoded as characters, a string containing
+those characters is returned. If an end of file is encountered before
+any characters are read, the end-of-file object is returned.
+@end deffn
+
+Finally, there are just two core procedures to write characters to a
+port.
+
+@deffn {Scheme Procedure} put-char port char
+Writes @var{char} to the port. The @code{put-char} procedure returns
+an unspecified value.
+@end deffn
+
+@deffn {Scheme Procedure} put-string port string
+@deffnx {Scheme Procedure} put-string port string start
+@deffnx {Scheme Procedure} put-string port string start count
+Write the @var{count} characters of @var{string} starting at index
+@var{start} to the port.
+
+@var{start} and @var{count} must be non-negative exact integer objects.
+@var{string} must have a length of at least @math{@var{start} +
+@var{count}}. @var{start} defaults to 0. @var{count} defaults to
+@math{@code{(string-length @var{string})} - @var{start}}$.
+
+Calling @code{put-string} is equivalent in all respects to calling
+@code{put-char} on the relevant sequence of characters, except that it
+will attempt to write multiple characters to the port at a time, even if
+the port is unbuffered.
+
+The @code{put-string} procedure returns an unspecified value.
+@end deffn
+
+Textual ports have a textual position associated with them: a line and a
+column. Reading in characters or writing them out advances the line and
+the column appropriately.
+
+@deffn {Scheme Procedure} port-column port
+@deffnx {Scheme Procedure} port-line port
+@deffnx {C Function} scm_port_column (port)
+@deffnx {C Function} scm_port_line (port)
+Return the current column number or line number of @var{port}.
+@end deffn
+
+Port lines and positions are represented as 0-origin integers, which is
+to say that the the first character of the first line is line 0, column
+0. However, when you display a line number, for example in an error
+message, we recommend you add 1 to get 1-origin integers. This is
+because lines numbers traditionally start with 1, and that is what
+non-programmers will find most natural.
+
+@deffn {Scheme Procedure} set-port-column! port column
+@deffnx {Scheme Procedure} set-port-line! port line
+@deffnx {C Function} scm_set_port_column_x (port, column)
+@deffnx {C Function} scm_set_port_line_x (port, line)
+Set the current column or line number of @var{port}.
+@end deffn
+
+@node Simple Output
+@subsection Simple Textual Output
+
+Guile exports a simple formatted output function, @code{simple-format}.
+For a more capable formatted output facility, @xref{Formatted Output}.
+
+@deffn {Scheme Procedure} simple-format destination message . args
+@deffnx {C Function} scm_simple_format (destination, message, args)
+Write @var{message} to @var{destination}, defaulting to the current
+output port. @var{message} can contain @code{~A} and @code{~S} escapes.
+When printed, the escapes are replaced with corresponding members of
+@var{args}: @code{~A} formats using @code{display} and @code{~S} formats
+using @code{write}. If @var{destination} is @code{#t}, then use the
+current output port, if @var{destination} is @code{#f}, then return a
+string containing the formatted text. Does not add a trailing newline.
+@end deffn
+
+Somewhat confusingly, Guile binds the @code{format} identifier to
+@code{simple-format} at startup. Once @code{(ice-9 format)} loads, it
+actually replaces the core @code{format} binding, so depending on
+whether you or a module you use has loaded @code{(ice-9 format)}, you
+may be using the simple or the more capable version.
+
+@node Buffering
+@subsection Buffering
+@cindex Port, buffering
+
+Every port has associated input and output buffers. You can think of
+ports as being backed by some mutable store, and that store might be far
+away. For example, ports backed by file descriptors have to go all the
+way to the kernel to read and write their data. To avoid this
+round-trip cost, Guile usually reads in data from the mutable store in
+chunks, and then services small requests like @code{get-char} out of
+that intermediate buffer. Similarly, small writes like
+@code{write-char} first go to a buffer, and are sent to the store when
+the buffer is full (or when port is flushed). Buffered ports speed up
+your program by reducing the number of round-trips to the mutable store,
+and they do so in a way that is mostly transparent to the user.
+
+There are two major ways, however, in which buffering affects program
+semantics. Building correct, performant programs requires understanding
+these situations.
+
+The first case is in random-access read/write ports (@pxref{Random
+Access}). These ports, usually backed by a file, logically operate over
+the same mutable store when both reading and writing. So, if you read a
+character, causing the buffer to fill, then write a character, the bytes
+you filled in your read buffer are now invalid. Every time you switch
+between reading and writing, Guile has to flush any pending buffer. If
+this happens frequently, the cost can be high. In that case you should
+reduce the amount that you buffer, in both directions. Similarly, Guile
+has to flush buffers before seeking. None of these considerations apply
+to sockets, which don't logically read from and write to the same
+mutable store, and are not seekable. Note also that sockets are
+unbuffered by default. @xref{Network Sockets and Communication}.
+
+The second case is the more pernicious one. If you write data to a
+buffered port, it probably doesn't go out to the mutable store directly.
+(This ``probably'' introduces some indeterminism in your program: what
+goes to the store, and when, depends on how full the buffer is. It is
+something that the user needs to explicitly be aware of.) The data is
+written to the store later -- when the buffer fills up due to another
+write, or when @code{force-output} is called, or when @code{close-port}
+is called, or when the program exits, or even when the garbage collector
+runs. The salient point is, @emph{the errors are signalled then too}.
+Buffered writes defer error detection (and defer the side effects to the
+mutable store), perhaps indefinitely if the port type does not need to
+be closed at GC.
+
+One common heuristic that works well for textual ports is to flush
+output when a newline (@code{\n}) is written. This @dfn{line buffering}
+mode is on by default for TTY ports. Most other ports are @dfn{block
+buffered}, meaning that once the output buffer reaches the block size,
+which depends on the port and its configuration, the output is flushed
+as a block, without regard to what is in the block. Likewise reads are
+read in at the block size, though if there are fewer bytes available to
+read, the buffer may not be entirely filled.
+
+Note that binary reads or writes that are larger than the buffer size go
+directly to the mutable store without passing through the buffers. If
+your access pattern involves many big reads or writes, buffering might
+not matter so much to you.
+
+To control the buffering behavior of a port, use @code{setvbuf}.
+
+@deffn {Scheme Procedure} setvbuf port mode [size]
+@deffnx {C Function} scm_setvbuf (port, mode, size)
+@cindex port buffering
+Set the buffering mode for @var{port}. @var{mode} can be one of the
+following symbols:
+
+@table @code
+@item none
+non-buffered
+@item line
+line buffered
+@item block
+block buffered, using a newly allocated buffer of @var{size} bytes.
+If @var{size} is omitted, a default size will be used.
+@end table
+@end deffn
+
+Another way to set the buffering, for file ports, is to open the file
+with @code{0} or @code{l} as part of the mode string, for unbuffered or
+line-buffered ports, respectively. @xref{File Ports}, for more.
+
+Any buffered output data will be written out when the port is closed.
+To make sure to flush it at specific points in your program, use
+@code{force-otput}.
+
+@findex fflush
+@deffn {Scheme Procedure} force-output [port]
+@deffnx {C Function} scm_force_output (port)
+Flush the specified output port, or the current output port if
+@var{port} is omitted. The current output buffer contents, if any, are
+passed to the underlying port implementation.
+
+The return value is unspecified.
+@end deffn
+
+@deffn {Scheme Procedure} flush-all-ports
+@deffnx {C Function} scm_flush_all_ports ()
+Equivalent to calling @code{force-output} on all open output ports. The
+return value is unspecified.
+@end deffn
+
+Similarly, sometimes you might want to switch from using Guile's ports
+to working directly on file descriptors. In that case, for input ports
+use @code{drain-input} to get any buffered input from that port.
+
@deffn {Scheme Procedure} drain-input port
@deffnx {C Function} scm_drain_input (port)
This procedure clears a port's input buffers, similar
@@ -294,145 +656,13 @@ contents of the buffers are returned as a single string, e.g.,
(unread-char (read-char p) p)
(drain-input p) => initial chars from p, up to the buffer size.
@end lisp
-
-Draining the buffers may be useful for cleanly finishing
-buffered I/O so that the file descriptor can be used directly
-for further input.
@end deffn
-@deffn {Scheme Procedure} port-column port
-@deffnx {Scheme Procedure} port-line port
-@deffnx {C Function} scm_port_column (port)
-@deffnx {C Function} scm_port_line (port)
-Return the current column number or line number of @var{port}.
-If the number is
-unknown, the result is #f. Otherwise, the result is a 0-origin integer
-- i.e.@: the first character of the first line is line 0, column 0.
-(However, when you display a file position, for example in an error
-message, we recommend you add 1 to get 1-origin integers. This is
-because lines and column numbers traditionally start with 1, and that is
-what non-programmers will find most natural.)
-@end deffn
-
-@deffn {Scheme Procedure} set-port-column! port column
-@deffnx {Scheme Procedure} set-port-line! port line
-@deffnx {C Function} scm_set_port_column_x (port, column)
-@deffnx {C Function} scm_set_port_line_x (port, line)
-Set the current column or line number of @var{port}.
-@end deffn
-
-@node Writing
-@subsection Writing
-@cindex Writing
-
-[Generic procedures for writing to ports.]
-
-These procedures are for writing characters and strings to
-ports. For more information on writing arbitrary Scheme objects to
-ports, @xref{Scheme Write}.
-
-@deffn {Scheme Procedure} get-print-state port
-@deffnx {C Function} scm_get_print_state (port)
-Return the print state of the port @var{port}. If @var{port}
-has no associated print state, @code{#f} is returned.
-@end deffn
-
-@rnindex newline
-@deffn {Scheme Procedure} newline [port]
-@deffnx {C Function} scm_newline (port)
-Send a newline to @var{port}.
-If @var{port} is omitted, send to the current output port.
-@end deffn
-
-@deffn {Scheme Procedure} port-with-print-state port [pstate]
-@deffnx {C Function} scm_port_with_print_state (port, pstate)
-Create a new port which behaves like @var{port}, but with an
-included print state @var{pstate}. @var{pstate} is optional.
-If @var{pstate} isn't supplied and @var{port} already has
-a print state, the old print state is reused.
-@end deffn
-
-@deffn {Scheme Procedure} simple-format destination message . args
-@deffnx {C Function} scm_simple_format (destination, message, args)
-Write @var{message} to @var{destination}, defaulting to
-the current output port.
-@var{message} can contain @code{~A} (was @code{%s}) and
-@code{~S} (was @code{%S}) escapes. When printed,
-the escapes are replaced with corresponding members of
-@var{args}:
-@code{~A} formats using @code{display} and @code{~S} formats
-using @code{write}.
-If @var{destination} is @code{#t}, then use the current output
-port, if @var{destination} is @code{#f}, then return a string
-containing the formatted text. Does not add a trailing newline.
-@end deffn
-
-@rnindex write-char
-@deffn {Scheme Procedure} write-char chr [port]
-@deffnx {C Function} scm_write_char (chr, port)
-Send character @var{chr} to @var{port}.
-@end deffn
-
-@deftypefn {C Function} void scm_c_write (SCM port, const void *buffer, size_t size)
-Write @var{size} bytes at @var{buffer} to @var{port}.
-
-Note that this function does not update @code{port-line} and
-@code{port-column} (@pxref{Reading}).
-@end deftypefn
-
-@findex fflush
-@deffn {Scheme Procedure} force-output [port]
-@deffnx {C Function} scm_force_output (port)
-Flush the specified output port, or the current output port if @var{port}
-is omitted. The current output buffer contents are passed to the
-underlying port implementation (e.g., in the case of fports, the
-data will be written to the file and the output buffer will be cleared.)
-It has no effect on an unbuffered port.
-
-The return value is unspecified.
-@end deffn
-
-@deffn {Scheme Procedure} flush-all-ports
-@deffnx {C Function} scm_flush_all_ports ()
-Equivalent to calling @code{force-output} on
-all open output ports. The return value is unspecified.
-@end deffn
-
-
-@node Closing
-@subsection Closing
-@cindex Closing ports
-@cindex Port, close
-
-@deffn {Scheme Procedure} close-port port
-@deffnx {C Function} scm_close_port (port)
-Close the specified port object. Return @code{#t} if it
-successfully closes a port or @code{#f} if it was already
-closed. An exception may be raised if an error occurs, for
-example when flushing buffered output. See also @ref{Ports and
-File Descriptors, close}, for a procedure which can close file
-descriptors.
-@end deffn
-
-@deffn {Scheme Procedure} close-input-port port
-@deffnx {Scheme Procedure} close-output-port port
-@deffnx {C Function} scm_close_input_port (port)
-@deffnx {C Function} scm_close_output_port (port)
-@rnindex close-input-port
-@rnindex close-output-port
-Close the specified input or output @var{port}. An exception may be
-raised if an error occurs while closing. If @var{port} is already
-closed, nothing is done. The return value is unspecified.
-
-See also @ref{Ports and File Descriptors, close}, for a procedure
-which can close file descriptors.
-@end deffn
-
-@deffn {Scheme Procedure} port-closed? port
-@deffnx {C Function} scm_port_closed_p (port)
-Return @code{#t} if @var{port} is closed or @code{#f} if it is
-open.
-@end deffn
+All of these considerations are very similar to those of streams in the
+C library, although Guile's ports are not built on top of C streams.
+Still, it is useful to read what other systems do.
+@xref{Streams,,,libc,The GNU C Library Reference Manual}, for more
+discussion on C streams.
@node Random Access
@@ -509,11 +739,8 @@ The delimited-I/O module can be accessed with:
@end lisp
It can be used to read or write lines of text, or read text delimited by
-a specified set of characters. It's similar to the @code{(scsh rdelim)}
-module from guile-scsh, but does not use multiple values or character
-sets and has an extra procedure @code{write-line}.
+a specified set of characters.
-@c begin (scm-doc-string "rdelim.scm" "read-line")
@deffn {Scheme Procedure} read-line [port] [handle-delim]
Return a line of text from @var{port} if specified, otherwise from the
value returned by @code{(current-input-port)}. Under Unix, a line of text
@@ -534,26 +761,21 @@ Push the terminating delimiter (if any) back on to the port.
Return a pair containing the string read from the port and the
terminating delimiter or end-of-file object.
@end table
-
-Like @code{read-char}, this procedure can throw to @code{decoding-error}
-(@pxref{Reading, @code{read-char}}).
@end deffn
-@c begin (scm-doc-string "rdelim.scm" "read-line!")
@deffn {Scheme Procedure} read-line! buf [port]
Read a line of text into the supplied string @var{buf} and return the
number of characters added to @var{buf}. If @var{buf} is filled, then
-@code{#f} is returned.
-Read from @var{port} if
-specified, otherwise from the value returned by @code{(current-input-port)}.
+@code{#f} is returned. Read from @var{port} if specified, otherwise
+from the value returned by @code{(current-input-port)}.
@end deffn
-@c begin (scm-doc-string "rdelim.scm" "read-delimited")
@deffn {Scheme Procedure} read-delimited delims [port] [handle-delim]
-Read text until one of the characters in the string @var{delims} is found
-or end-of-file is reached. Read from @var{port} if supplied, otherwise
-from the value returned by @code{(current-input-port)}.
-@var{handle-delim} takes the same values as described for @code{read-line}.
+Read text until one of the characters in the string @var{delims} is
+found or end-of-file is reached. Read from @var{port} if supplied,
+otherwise from the value returned by @code{(current-input-port)}.
+@var{handle-delim} takes the same values as described for
+@code{read-line}.
@end deffn
@c begin (scm-doc-string "rdelim.scm" "read-delimited!")
@@ -571,48 +793,6 @@ buffer was full, @code{#f} is returned.
It's something of a wacky interface, to be honest.
@end deffn
-@deffn {Scheme Procedure} write-line obj [port]
-@deffnx {C Function} scm_write_line (obj, port)
-Display @var{obj} and a newline character to @var{port}. If
-@var{port} is not specified, @code{(current-output-port)} is
-used. This function is equivalent to:
-@lisp
-(display obj [port])
-(newline [port])
-@end lisp
-@end deffn
-
-In the past, Guile did not have a procedure that would just read out all
-of the characters from a port. As a workaround, many people just called
-@code{read-delimited} with no delimiters, knowing that would produce the
-behavior they wanted. This prompted Guile developers to add some
-routines that would read all characters from a port. So it is that
-@code{(ice-9 rdelim)} is also the home for procedures that can reading
-undelimited text:
-
-@deffn {Scheme Procedure} read-string [port] [count]
-Read all of the characters out of @var{port} and return them as a
-string. If the @var{count} is present, treat it as a limit to the
-number of characters to read.
-
-By default, read from the current input port, with no size limit on the
-result. This procedure always returns a string, even if no characters
-were read.
-@end deffn
-
-@deffn {Scheme Procedure} read-string! buf [port] [start] [end]
-Fill @var{buf} with characters read from @var{port}, defaulting to the
-current input port. Return the number of characters read.
-
-If @var{start} or @var{end} are specified, store data only into the
-substring of @var{str} bounded by @var{start} and @var{end} (which
-default to the beginning and end of the string, respectively).
-@end deffn
-
-Some of the aforementioned I/O functions rely on the following C
-primitives. These will mainly be of interest to people hacking Guile
-internals.
-
@deffn {Scheme Procedure} %read-delimited! delims str gobble [port [start [end]]]
@deffnx {C Function} scm_read_delimited_x (delims, str, gobble, port, start, end)
Read characters from @var{port} into @var{str} until one of the
@@ -642,106 +822,6 @@ delimiter may be either a newline or the @var{eof-object}; if
@code{(# . #)}.
@end deffn
-@node Block Reading and Writing
-@subsection Block reading and writing
-@cindex Block read/write
-@cindex Port, block read/write
-
-The Block-string-I/O module can be accessed with:
-
-@lisp
-(use-modules (ice-9 rw))
-@end lisp
-
-It currently contains procedures that help to implement the
-@code{(scsh rw)} module in guile-scsh.
-
-@deffn {Scheme Procedure} read-string!/partial str [port_or_fdes [start [end]]]
-@deffnx {C Function} scm_read_string_x_partial (str, port_or_fdes, start, end)
-Read characters from a port or file descriptor into a
-string @var{str}. A port must have an underlying file
-descriptor --- a so-called fport. This procedure is
-scsh-compatible and can efficiently read large strings.
-It will:
-
-@itemize
-@item
-attempt to fill the entire string, unless the @var{start}
-and/or @var{end} arguments are supplied. i.e., @var{start}
-defaults to 0 and @var{end} defaults to
-@code{(string-length str)}
-@item
-use the current input port if @var{port_or_fdes} is not
-supplied.
-@item
-return fewer than the requested number of characters in some
-cases, e.g., on end of file, if interrupted by a signal, or if
-not all the characters are immediately available.
-@item
-wait indefinitely for some input if no characters are
-currently available,
-unless the port is in non-blocking mode.
-@item
-read characters from the port's input buffers if available,
-instead from the underlying file descriptor.
-@item
-return @code{#f} if end-of-file is encountered before reading
-any characters, otherwise return the number of characters
-read.
-@item
-return 0 if the port is in non-blocking mode and no characters
-are immediately available.
-@item
-return 0 if the request is for 0 bytes, with no
-end-of-file check.
-@end itemize
-@end deffn
-
-@deffn {Scheme Procedure} write-string/partial str [port_or_fdes [start [end]]]
-@deffnx {C Function} scm_write_string_partial (str, port_or_fdes, start, end)
-Write characters from a string @var{str} to a port or file
-descriptor. A port must have an underlying file descriptor
---- a so-called fport. This procedure is
-scsh-compatible and can efficiently write large strings.
-It will:
-
-@itemize
-@item
-attempt to write the entire string, unless the @var{start}
-and/or @var{end} arguments are supplied. i.e., @var{start}
-defaults to 0 and @var{end} defaults to
-@code{(string-length str)}
-@item
-use the current output port if @var{port_of_fdes} is not
-supplied.
-@item
-in the case of a buffered port, store the characters in the
-port's output buffer, if all will fit. If they will not fit
-then any existing buffered characters will be flushed
-before attempting
-to write the new characters directly to the underlying file
-descriptor. If the port is in non-blocking mode and
-buffered characters can not be flushed immediately, then an
-@code{EAGAIN} system-error exception will be raised (Note:
-scsh does not support the use of non-blocking buffered ports.)
-@item
-write fewer than the requested number of
-characters in some cases, e.g., if interrupted by a signal or
-if not all of the output can be accepted immediately.
-@item
-wait indefinitely for at least one character
-from @var{str} to be accepted by the port, unless the port is
-in non-blocking mode.
-@item
-return the number of characters accepted by the port.
-@item
-return 0 if the port is in non-blocking mode and can not accept
-at least one character from @var{str} immediately
-@item
-return 0 immediately if the request size is 0 bytes.
-@end itemize
-@end deffn
-
@node Default Ports
@subsection Default Ports for Input, Output and Errors
@cindex Default ports
@@ -782,7 +862,7 @@ Unbuffered output to a tty is good for ensuring progress output or a
prompt is seen. But an application which always prints whole lines
could change to line buffered, or an application with a lot of output
could go fully buffered and perhaps make explicit @code{force-output}
-calls (@pxref{Writing}) at selected points.
+calls (@pxref{Buffering}) at selected points.
@end deffn
@deffn {Scheme Procedure} current-error-port
@@ -806,6 +886,14 @@ Change the ports returned by @code{current-input-port},
so that they use the supplied @var{port} for input or output.
@end deffn
+@deffn {Scheme Procedure} with-input-from-port port thunk
+@deffnx {Scheme Procedure} with-output-to-port port thunk
+@deffnx {Scheme Procedure} with-error-to-port port thunk
+Call @var{thunk} in a dynamic environment in which
+@code{current-input-port}, @code{current-output-port} or
+@code{current-error-port} is rebound to the given @var{port}.
+@end deffn
+
@deftypefn {C Function} void scm_dynwind_current_input_port (SCM port)
@deftypefnx {C Function} void scm_dynwind_current_output_port (SCM port)
@deftypefnx {C Function} void scm_dynwind_current_error_port (SCM port)
@@ -824,12 +912,12 @@ initialized with the @var{port} argument.
@cindex Types of ports
@cindex Port, types
-[Types of port; how to make them.]
-
@menu
* File Ports:: Ports on an operating system file.
+* Bytevector Ports:: Ports on a bytevector.
* String Ports:: Ports on a Scheme string.
-* Soft Ports:: Ports on arbitrary Scheme procedures.
+* Custom Ports:: Ports whose implementation you control.
+* Soft Ports:: An older version of custom ports.
* Void Ports:: Ports on nothing at all.
@end menu
@@ -843,6 +931,10 @@ The following procedures are used to open file ports.
See also @ref{Ports and File Descriptors, open}, for an interface
to the Unix @code{open} system call.
+All file access uses the ``LFS'' large file support functions when
+available, so files bigger than 2 Gbytes (@math{2^31} bytes) can be
+read and written on a 32-bit system.
+
Most systems have limits on how many files can be open, so it's
strongly recommended that file ports be closed explicitly when no
longer required (@pxref{Ports}).
@@ -882,8 +974,7 @@ Create an "unbuffered" port. In this case input and output
operations are passed directly to the underlying port
implementation without additional buffering. This is likely to
slow down I/O operations. The buffering mode can be changed
-while a port is in use @pxref{Ports and File Descriptors,
-setvbuf}
+while a port is in use (@pxref{Buffering}).
@item l
Add line-buffering to the port. The port output buffer will be
automatically flushed whenever a newline character is written.
@@ -897,8 +988,7 @@ character encoding "ISO-8859-1", ignoring the default port encoding.
Note that while it is possible to read and write binary data as
characters or strings, it is usually better to treat bytes as octets,
-and byte sequences as bytevectors. @xref{R6RS Binary Input}, and
-@ref{R6RS Binary Output}, for more.
+and byte sequences as bytevectors. @xref{Binary I/O}, for more.
This option had another historical meaning, for DOS compatibility: in
the default (textual) mode, DOS reads a CR-LF sequence as one LF byte.
@@ -919,25 +1009,6 @@ is requested.
If a file cannot be opened with the access requested, @code{open-file}
throws an exception.
-
-When the file is opened, its encoding is set to the current
-@code{%default-port-encoding}, unless the @code{b} flag was supplied.
-Sometimes it is desirable to honor Emacs-style coding declarations in
-files@footnote{Guile 2.0.0 to 2.0.7 would do this by default. This
-behavior was deemed inappropriate and disabled starting from Guile
-2.0.8.}. When that is the case, the @code{file-encoding} procedure can
-be used as follows (@pxref{Character Encoding of Source Files,
-@code{file-encoding}}):
-
-@example
-(let* ((port (open-input-file file))
- (encoding (file-encoding port)))
- (set-port-encoding! port (or encoding (port-encoding port))))
-@end example
-
-In theory we could create read/write ports which were buffered
-in one direction only. However this isn't included in the
-current interfaces.
@end deffn
@rnindex open-input-file
@@ -1032,7 +1103,7 @@ used only during port creation are not retained.
Return the filename associated with @var{port}, or @code{#f} if no
filename is associated with the port.
-@var{port} must be open, @code{port-filename} cannot be used once the
+@var{port} must be open; @code{port-filename} cannot be used once the
port is closed.
@end deffn
@@ -1050,21 +1121,45 @@ Determine whether @var{obj} is a port that is related to a file.
@end deffn
+@node Bytevector Ports
+@subsubsection Bytevector Ports
+
+@deffn {Scheme Procedure} open-bytevector-input-port bv [transcoder]
+@deffnx {C Function} scm_open_bytevector_input_port (bv, transcoder)
+Return an input port whose contents are drawn from bytevector @var{bv}
+(@pxref{Bytevectors}).
+
+@c FIXME: Update description when implemented.
+The @var{transcoder} argument is currently not supported.
+@end deffn
+
+@deffn {Scheme Procedure} open-bytevector-output-port [transcoder]
+@deffnx {C Function} scm_open_bytevector_output_port (transcoder)
+Return two values: a binary output port and a procedure. The latter
+should be called with zero arguments to obtain a bytevector containing
+the data accumulated by the port, as illustrated below.
+
+@lisp
+(call-with-values
+ (lambda ()
+ (open-bytevector-output-port))
+ (lambda (port get-bytevector)
+ (display "hello" port)
+ (get-bytevector)))
+
+@result{} #vu8(104 101 108 108 111)
+@end lisp
+
+@c FIXME: Update description when implemented.
+The @var{transcoder} argument is currently not supported.
+@end deffn
+
+
@node String Ports
@subsubsection String Ports
@cindex String port
@cindex Port, string
-The following allow string ports to be opened by analogy to R4RS
-file port facilities:
-
-With string ports, the port-encoding is treated differently than other
-types of ports. When string ports are created, they do not inherit a
-character encoding from the current locale. They are given a
-default locale that allows them to handle all valid string characters.
-Typically one should not modify a string port's character encoding
-away from its default.
-
@deffn {Scheme Procedure} call-with-output-string proc
@deffnx {C Function} scm_call_with_output_string (proc)
Calls the one-argument procedure @var{proc} with a newly created output
@@ -1118,22 +1213,114 @@ output to the port so far.
closed the string cannot be obtained.
@end deffn
-A string port can be used in many procedures which accept a port
-but which are not dependent on implementation details of fports.
-E.g., seeking and truncating will work on a string port,
-but trying to extract the file descriptor number will fail.
+With string ports, the port-encoding is treated differently than other
+types of ports. When string ports are created, they do not inherit a
+character encoding from the current locale. They are given a
+default locale that allows them to handle all valid string characters.
+Typically one should not modify a string port's character encoding
+away from its default. @xref{Encoding}.
+@node Custom Ports
+@subsubsection Custom Ports
+
+Custom ports allow the user to provide input and handle output via
+user-supplied procedures. Guile currently only provides custom binary
+ports, not textual ports; for custom textual ports, @xref{Soft Ports}.
+We should add the R6RS custom textual port interfaces though.
+Contributions are appreciated.
+
+@cindex custom binary input ports
+@deffn {Scheme Procedure} make-custom-binary-input-port id read! get-position set-position! close
+Return a new custom binary input port@footnote{This is similar in spirit
+to Guile's @dfn{soft ports} (@pxref{Soft Ports}).} named @var{id} (a
+string) whose input is drained by invoking @var{read!} and passing it a
+bytevector, an index where bytes should be written, and the number of
+bytes to read. The @code{read!} procedure must return an integer
+indicating the number of bytes read, or @code{0} to indicate the
+end-of-file.
+
+Optionally, if @var{get-position} is not @code{#f}, it must be a thunk
+that will be called when @code{port-position} is invoked on the custom
+binary port and should return an integer indicating the position within
+the underlying data stream; if @var{get-position} was not supplied, the
+returned port does not support @code{port-position}.
+
+Likewise, if @var{set-position!} is not @code{#f}, it should be a
+one-argument procedure. When @code{set-port-position!} is invoked on the
+custom binary input port, @var{set-position!} is passed an integer
+indicating the position of the next byte is to read.
+
+Finally, if @var{close} is not @code{#f}, it must be a thunk. It is
+invoked when the custom binary input port is closed.
+
+The returned port is fully buffered by default, but its buffering mode
+can be changed using @code{setvbuf} (@pxref{Buffering}).
+
+Using a custom binary input port, the @code{open-bytevector-input-port}
+procedure (@pxref{Bytevector Ports}) could be implemented as follows:
+
+@lisp
+(define (open-bytevector-input-port source)
+ (define position 0)
+ (define length (bytevector-length source))
+
+ (define (read! bv start count)
+ (let ((count (min count (- length position))))
+ (bytevector-copy! source position
+ bv start count)
+ (set! position (+ position count))
+ count))
+
+ (define (get-position) position)
+
+ (define (set-position! new-position)
+ (set! position new-position))
+
+ (make-custom-binary-input-port "the port" read!
+ get-position set-position!
+ #f))
+
+(read (open-bytevector-input-port (string->utf8 "hello")))
+@result{} hello
+@end lisp
+@end deffn
+
+@cindex custom binary output ports
+@deffn {Scheme Procedure} make-custom-binary-output-port id write! get-position set-position! close
+Return a new custom binary output port named @var{id} (a string) whose
+output is sunk by invoking @var{write!} and passing it a bytevector, an
+index where bytes should be read from this bytevector, and the number of
+bytes to be ``written''. The @code{write!} procedure must return an
+integer indicating the number of bytes actually written; when it is
+passed @code{0} as the number of bytes to write, it should behave as
+though an end-of-file was sent to the byte sink.
+
+The other arguments are as for @code{make-custom-binary-input-port}.
+@end deffn
+
+@cindex custom binary input/output ports
+@deffn {Scheme Procedure} make-custom-binary-input/output-port id read! write! get-position set-position! close
+Return a new custom binary input/output port named @var{id} (a string).
+The various arguments are the same as for The other arguments are as for
+@code{make-custom-binary-input-port} and
+@code{make-custom-binary-output-port}. If buffering is enabled on the
+port, as is the case by default, input will be buffered in both
+directions; @xref{Buffering}. If the @var{set-position!} function is
+provided and not @code{#f}, then the port will also be marked as
+random-access, causing the buffer to be flushed between reads and
+writes.
+@end deffn
+
@node Soft Ports
@subsubsection Soft Ports
@cindex Soft port
@cindex Port, soft
-A @dfn{soft-port} is a port based on a vector of procedures capable of
+A @dfn{soft port} is a port based on a vector of procedures capable of
accepting or delivering characters. It allows emulation of I/O ports.
@deffn {Scheme Procedure} make-soft-port pv modes
-@deffnx {C Function} scm_make_soft_port (pv, modes)
Return a port capable of receiving or delivering characters as
specified by the @var{modes} string (@pxref{File Ports,
open-file}). @var{pv} must be a vector of length 5 or 6. Its
@@ -1198,1223 +1385,446 @@ documentation for @code{open-file} in @ref{File Ports}.
@end deffn
-@node R6RS I/O Ports
-@subsection R6RS I/O Ports
+@node Venerable Port Interfaces
+@subsection Venerable Port Interfaces
-@cindex R6RS
-@cindex R6RS ports
+Over the 25 years or so that Guile has been around, its port system has
+evolved, adding many useful features. At the same time there have been
+four major Scheme standards released in those 25 years, which also
+evolve the common Scheme understanding of what a port interface should
+be. Alas, it would be too much to ask for all of these evolutionary
+branches to be consistent. Some of Guile's original interfaces don't
+mesh with the later Scheme standards, and yet Guile can't just drop old
+interfaces. Sadly as well, the R6RS and R7RS standards both part from a
+base of R5RS, but end up in different and somewhat incompatible designs.
-The I/O port API of the @uref{http://www.r6rs.org/, Revised Report^6 on
-the Algorithmic Language Scheme (R6RS)} is provided by the @code{(rnrs
-io ports)} module. It provides features, such as binary I/O and Unicode
-string I/O, that complement or refine Guile's historical port API
-presented above (@pxref{Input and Output}). Note that R6RS ports are not
-disjoint from Guile's native ports, so Guile-specific procedures will
-work on ports created using the R6RS API, and vice versa.
+Guile's approach is to pick a set of port primitives that make sense
+together. We document that set of primitives, design our internal
+interfaces around them, and recommend them to users. As the R6RS I/O
+system is the most capable standard that Scheme has yet produced in this
+domain, we mostly recommend that; @code{(ice-9 binary-ports)} and
+@code{(ice-9 textual-ports)} are wholly modelled on @code{(rnrs io
+ports)}. Guile does not wholly copy R6RS, however; @xref{R6RS
+Incompatibilities}.
-The text in this section is taken from the R6RS standard libraries
-document, with only minor adaptions for inclusion in this manual. The
-Guile developers offer their thanks to the R6RS editors for having
-provided the report's text under permissive conditions making this
-possible.
+At the same time, we have many venerable port interfaces, lore handed
+down to us from our hacker ancestors. Most of these interfaces even
+predate the expectation that Scheme should have modules, so they are
+present in the default environment. In Guile we support them as well
+and we have no plans to remove them, but again we don't recommend them
+for new users.
-@c FIXME: Update description when implemented.
-@emph{Note}: The implementation of this R6RS API is not complete yet.
+@rnindex char-ready?
+@deffn {Scheme Procedure} char-ready? [port]
+Return @code{#t} if a character is ready on input @var{port}
+and return @code{#f} otherwise. If @code{char-ready?} returns
+@code{#t} then the next @code{read-char} operation on
+@var{port} is guaranteed not to hang. If @var{port} is a file
+port at end of file then @code{char-ready?} returns @code{#t}.
-@menu
-* R6RS File Names:: File names.
-* R6RS File Options:: Options for opening files.
-* R6RS Buffer Modes:: Influencing buffering behavior.
-* R6RS Transcoders:: Influencing port encoding.
-* R6RS End-of-File:: The end-of-file object.
-* R6RS Port Manipulation:: Manipulating R6RS ports.
-* R6RS Input Ports:: Input Ports.
-* R6RS Binary Input:: Binary input.
-* R6RS Textual Input:: Textual input.
-* R6RS Output Ports:: Output Ports.
-* R6RS Binary Output:: Binary output.
-* R6RS Textual Output:: Textual output.
-@end menu
+@code{char-ready?} exists to make it possible for a
+program to accept characters from interactive ports without
+getting stuck waiting for input. Any input editors associated
+with such ports must make sure that characters whose existence
+has been asserted by @code{char-ready?} cannot be rubbed out.
+If @code{char-ready?} were to return @code{#f} at end of file,
+a port at end of file would be indistinguishable from an
+interactive port that has no ready characters.
-A subset of the @code{(rnrs io ports)} module, plus one non-standard
-procedure @code{unget-bytevector} (@pxref{R6RS Binary Input}), is
-provided by the @code{(ice-9 binary-ports)} module. It contains binary
-input/output procedures and does not rely on R6RS support.
+Note that @code{char-ready?} only works reliably for terminals and
+sockets with one-byte encodings. Under the hood it will return
+@code{#t} if the port has any input buffered, or if the file descriptor
+that backs the port polls as readable, indicating that Guile can fetch
+more bytes from the kernel. However being able to fetch one byte
+doesn't mean that a full character is available; @xref{Encoding}. Also,
+on many systems it's possible for a file descriptor to poll as readable,
+but then block when it comes time to read bytes. Note also that on
+Linux kernels, all file ports backed by files always poll as readable.
+For non-file ports, this procedure always returns @code{#t}, except for
+soft ports, which have a @code{char-ready?} handler. @xref{Soft Ports}.
-@node R6RS File Names
-@subsubsection File Names
-
-Some of the procedures described in this chapter accept a file name as an
-argument. Valid values for such a file name include strings that name a file
-using the native notation of file system paths on an implementation's
-underlying operating system, and may include implementation-dependent
-values as well.
-
-A @var{filename} parameter name means that the
-corresponding argument must be a file name.
-
-@node R6RS File Options
-@subsubsection File Options
-@cindex file options
-
-When opening a file, the various procedures in this library accept a
-@code{file-options} object that encapsulates flags to specify how the
-file is to be opened. A @code{file-options} object is an enum-set
-(@pxref{rnrs enums}) over the symbols constituting valid file options.
-
-A @var{file-options} parameter name means that the corresponding
-argument must be a file-options object.
-
-@deffn {Scheme Syntax} file-options @var{file-options-symbol} ...
-
-Each @var{file-options-symbol} must be a symbol.
-
-The @code{file-options} syntax returns a file-options object that
-encapsulates the specified options.
-
-When supplied to an operation that opens a file for output, the
-file-options object returned by @code{(file-options)} specifies that the
-file is created if it does not exist and an exception with condition
-type @code{&i/o-file-already-exists} is raised if it does exist. The
-following standard options can be included to modify the default
-behavior.
-
-@table @code
-@item no-create
- If the file does not already exist, it is not created;
- instead, an exception with condition type @code{&i/o-file-does-not-exist}
- is raised.
- If the file already exists, the exception with condition type
- @code{&i/o-file-already-exists} is not raised
- and the file is truncated to zero length.
-@item no-fail
- If the file already exists, the exception with condition type
- @code{&i/o-file-already-exists} is not raised,
- even if @code{no-create} is not included,
- and the file is truncated to zero length.
-@item no-truncate
- If the file already exists and the exception with condition type
- @code{&i/o-file-already-exists} has been inhibited by inclusion of
- @code{no-create} or @code{no-fail}, the file is not truncated, but
- the port's current position is still set to the beginning of the
- file.
-@end table
-
-These options have no effect when a file is opened only for input.
-Symbols other than those listed above may be used as
-@var{file-options-symbol}s; they have implementation-specific meaning,
-if any.
-
-@quotation Note
- Only the name of @var{file-options-symbol} is significant.
-@end quotation
+In short, this is a legacy procedure whose semantics are hard to
+provide. However it is a useful check to see if any input is buffered.
+@xref{Non-Blocking I/O}.
@end deffn
-@node R6RS Buffer Modes
-@subsubsection Buffer Modes
-
-Each port has an associated buffer mode. For an output port, the
-buffer mode defines when an output operation flushes the buffer
-associated with the output port. For an input port, the buffer mode
-defines how much data will be read to satisfy read operations. The
-possible buffer modes are the symbols @code{none} for no buffering,
-@code{line} for flushing upon line endings and reading up to line
-endings, or other implementation-dependent behavior,
-and @code{block} for arbitrary buffering. This section uses
-the parameter name @var{buffer-mode} for arguments that must be
-buffer-mode symbols.
-
-If two ports are connected to the same mutable source, both ports
-are unbuffered, and reading a byte or character from that shared
-source via one of the two ports would change the bytes or characters
-seen via the other port, a lookahead operation on one port will
-render the peeked byte or character inaccessible via the other port,
-while a subsequent read operation on the peeked port will see the
-peeked byte or character even though the port is otherwise unbuffered.
-
-In other words, the semantics of buffering is defined in terms of side
-effects on shared mutable sources, and a lookahead operation has the
-same side effect on the shared source as a read operation.
-
-@deffn {Scheme Syntax} buffer-mode @var{buffer-mode-symbol}
-
-@var{buffer-mode-symbol} must be a symbol whose name is one of
-@code{none}, @code{line}, and @code{block}. The result is the
-corresponding symbol, and specifies the associated buffer mode.
-
-@quotation Note
- Only the name of @var{buffer-mode-symbol} is significant.
-@end quotation
+@rnindex read-char
+@deffn {Scheme Procedure} read-char [port]
+The same as @code{get-char}, except that @var{port} defaults to the
+current input port. @xref{Textual I/O}.
@end deffn
-@deffn {Scheme Procedure} buffer-mode? obj
-Returns @code{#t} if the argument is a valid buffer-mode symbol, and
-returns @code{#f} otherwise.
+@rnindex peek-char
+@deffn {Scheme Procedure} peek-char [port]
+The same as @code{lookahead-char}, except that @var{port} defaults to
+the current input port. @xref{Textual I/O}.
@end deffn
-@node R6RS Transcoders
-@subsubsection Transcoders
-@cindex codec
-@cindex end-of-line style
-@cindex transcoder
-@cindex binary port
-@cindex textual port
-
-Several different Unicode encoding schemes describe standard ways to
-encode characters and strings as byte sequences and to decode those
-sequences. Within this document, a @dfn{codec} is an immutable Scheme
-object that represents a Unicode or similar encoding scheme.
-
-An @dfn{end-of-line style} is a symbol that, if it is not @code{none},
-describes how a textual port transcodes representations of line endings.
-
-A @dfn{transcoder} is an immutable Scheme object that combines a codec
-with an end-of-line style and a method for handling decoding errors.
-Each transcoder represents some specific bidirectional (but not
-necessarily lossless), possibly stateful translation between byte
-sequences and Unicode characters and strings. Every transcoder can
-operate in the input direction (bytes to characters) or in the output
-direction (characters to bytes). A @var{transcoder} parameter name
-means that the corresponding argument must be a transcoder.
-
-A @dfn{binary port} is a port that supports binary I/O, does not have an
-associated transcoder and does not support textual I/O. A @dfn{textual
-port} is a port that supports textual I/O, and does not support binary
-I/O. A textual port may or may not have an associated transcoder.
-
-@deffn {Scheme Procedure} latin-1-codec
-@deffnx {Scheme Procedure} utf-8-codec
-@deffnx {Scheme Procedure} utf-16-codec
-
-These are predefined codecs for the ISO 8859-1, UTF-8, and UTF-16
-encoding schemes.
-
-A call to any of these procedures returns a value that is equal in the
-sense of @code{eqv?} to the result of any other call to the same
-procedure.
+@deffn {Scheme Procedure} unread-char cobj [port]
+The same as @code{unget-char}, except that @var{port} defaults to the
+current input port, and the arguments are swapped. @xref{Textual I/O}.
@end deffn
-@deffn {Scheme Syntax} eol-style @var{eol-style-symbol}
-
-@var{eol-style-symbol} should be a symbol whose name is one of
-@code{lf}, @code{cr}, @code{crlf}, @code{nel}, @code{crnel}, @code{ls},
-and @code{none}.
-
-The form evaluates to the corresponding symbol. If the name of
-@var{eol-style-symbol} is not one of these symbols, the effect and
-result are implementation-dependent; in particular, the result may be an
-eol-style symbol acceptable as an @var{eol-style} argument to
-@code{make-transcoder}. Otherwise, an exception is raised.
-
-All eol-style symbols except @code{none} describe a specific
-line-ending encoding:
-
-@table @code
-@item lf
-linefeed
-@item cr
-carriage return
-@item crlf
-carriage return, linefeed
-@item nel
-next line
-@item crnel
-carriage return, next line
-@item ls
-line separator
-@end table
-
-For a textual port with a transcoder, and whose transcoder has an
-eol-style symbol @code{none}, no conversion occurs. For a textual input
-port, any eol-style symbol other than @code{none} means that all of the
-above line-ending encodings are recognized and are translated into a
-single linefeed. For a textual output port, @code{none} and @code{lf}
-are equivalent. Linefeed characters are encoded according to the
-specified eol-style symbol, and all other characters that participate in
-possible line endings are encoded as is.
-
-@quotation Note
- Only the name of @var{eol-style-symbol} is significant.
-@end quotation
+@deffn {Scheme Procedure} unread-string str port
+@deffnx {C Function} scm_unread_string (str, port)
+The same as @code{unget-string}, except that @var{port} defaults to the
+current input port, and the arguments are swapped. @xref{Textual I/O}.
@end deffn
-@deffn {Scheme Procedure} native-eol-style
-Returns the default end-of-line style of the underlying platform, e.g.,
-@code{lf} on Unix and @code{crlf} on Windows.
+@rnindex newline
+@deffn {Scheme Procedure} newline [port]
+Send a newline to @var{port}. If @var{port} is omitted, send to the
+current output port. Equivalent to @code{(put-char port #\newline)}.
@end deffn
-@deffn {Condition Type} &i/o-decoding
-@deffnx {Scheme Procedure} make-i/o-decoding-error port
-@deffnx {Scheme Procedure} i/o-decoding-error? obj
-
-This condition type could be defined by
-
-@lisp
-(define-condition-type &i/o-decoding &i/o-port
- make-i/o-decoding-error i/o-decoding-error?)
-@end lisp
-
-An exception with this type is raised when one of the operations for
-textual input from a port encounters a sequence of bytes that cannot be
-translated into a character or string by the input direction of the
-port's transcoder.
-
-When such an exception is raised, the port's position is past the
-invalid encoding.
+@rnindex write-char
+@deffn {Scheme Procedure} write-char chr [port]
+The same as @code{put-char}, except that @var{port} defaults to the
+current input port, and the arguments are swapped. @xref{Textual I/O}.
@end deffn
-@deffn {Condition Type} &i/o-encoding
-@deffnx {Scheme Procedure} make-i/o-encoding-error port char
-@deffnx {Scheme Procedure} i/o-encoding-error? obj
-@deffnx {Scheme Procedure} i/o-encoding-error-char condition
-
-This condition type could be defined by
-
-@lisp
-(define-condition-type &i/o-encoding &i/o-port
- make-i/o-encoding-error i/o-encoding-error?
- (char i/o-encoding-error-char))
-@end lisp
-
-An exception with this type is raised when one of the operations for
-textual output to a port encounters a character that cannot be
-translated into bytes by the output direction of the port's transcoder.
-@var{char} is the character that could not be encoded.
-@end deffn
-
-@deffn {Scheme Syntax} error-handling-mode @var{error-handling-mode-symbol}
-
-@var{error-handling-mode-symbol} should be a symbol whose name is one of
-@code{ignore}, @code{raise}, and @code{replace}. The form evaluates to
-the corresponding symbol. If @var{error-handling-mode-symbol} is not
-one of these identifiers, effect and result are
-implementation-dependent: The result may be an error-handling-mode
-symbol acceptable as a @var{handling-mode} argument to
-@code{make-transcoder}. If it is not acceptable as a
-@var{handling-mode} argument to @code{make-transcoder}, an exception is
-raised.
-
-@quotation Note
- Only the name of @var{error-handling-mode-symbol} is significant.
-@end quotation
-
-The error-handling mode of a transcoder specifies the behavior
-of textual I/O operations in the presence of encoding or decoding
-errors.
-
-If a textual input operation encounters an invalid or incomplete
-character encoding, and the error-handling mode is @code{ignore}, an
-appropriate number of bytes of the invalid encoding are ignored and
-decoding continues with the following bytes.
-
-If the error-handling mode is @code{replace}, the replacement
-character U+FFFD is injected into the data stream, an appropriate
-number of bytes are ignored, and decoding
-continues with the following bytes.
-
-If the error-handling mode is @code{raise}, an exception with condition
-type @code{&i/o-decoding} is raised.
-
-If a textual output operation encounters a character it cannot encode,
-and the error-handling mode is @code{ignore}, the character is ignored
-and encoding continues with the next character. If the error-handling
-mode is @code{replace}, a codec-specific replacement character is
-emitted by the transcoder, and encoding continues with the next
-character. The replacement character is U+FFFD for transcoders whose
-codec is one of the Unicode encodings, but is the @code{?} character
-for the Latin-1 encoding. If the error-handling mode is @code{raise},
-an exception with condition type @code{&i/o-encoding} is raised.
-@end deffn
-
-@deffn {Scheme Procedure} make-transcoder codec
-@deffnx {Scheme Procedure} make-transcoder codec eol-style
-@deffnx {Scheme Procedure} make-transcoder codec eol-style handling-mode
-
-@var{codec} must be a codec; @var{eol-style}, if present, an eol-style
-symbol; and @var{handling-mode}, if present, an error-handling-mode
-symbol.
-
-@var{eol-style} may be omitted, in which case it defaults to the native
-end-of-line style of the underlying platform. @var{handling-mode} may
-be omitted, in which case it defaults to @code{replace}. The result is
-a transcoder with the behavior specified by its arguments.
-@end deffn
-
-@deffn {Scheme procedure} native-transcoder
-Returns an implementation-dependent transcoder that represents a
-possibly locale-dependent ``native'' transcoding.
-@end deffn
-
-@deffn {Scheme Procedure} transcoder-codec transcoder
-@deffnx {Scheme Procedure} transcoder-eol-style transcoder
-@deffnx {Scheme Procedure} transcoder-error-handling-mode transcoder
-
-These are accessors for transcoder objects; when applied to a
-transcoder returned by @code{make-transcoder}, they return the
-@var{codec}, @var{eol-style}, and @var{handling-mode} arguments,
-respectively.
-@end deffn
-
-@deffn {Scheme Procedure} bytevector->string bytevector transcoder
-
-Returns the string that results from transcoding the
-@var{bytevector} according to the input direction of the transcoder.
-@end deffn
-
-@deffn {Scheme Procedure} string->bytevector string transcoder
-
-Returns the bytevector that results from transcoding the
-@var{string} according to the output direction of the transcoder.
-@end deffn
-
-@node R6RS End-of-File
-@subsubsection The End-of-File Object
-
-@cindex EOF
-@cindex end-of-file
-
-R5RS' @code{eof-object?} procedure is provided by the @code{(rnrs io
-ports)} module:
-
-@deffn {Scheme Procedure} eof-object? obj
-@deffnx {C Function} scm_eof_object_p (obj)
-Return true if @var{obj} is the end-of-file (EOF) object.
-@end deffn
-
-In addition, the following procedure is provided:
-
-@deffn {Scheme Procedure} eof-object
-@deffnx {C Function} scm_eof_object ()
-Return the end-of-file (EOF) object.
-
-@lisp
-(eof-object? (eof-object))
-@result{} #t
-@end lisp
-@end deffn
-
-
-@node R6RS Port Manipulation
-@subsubsection Port Manipulation
-
-The procedures listed below operate on any kind of R6RS I/O port.
-
-@deffn {Scheme Procedure} port? obj
-Returns @code{#t} if the argument is a port, and returns @code{#f}
-otherwise.
-@end deffn
-
-@deffn {Scheme Procedure} port-transcoder port
-Returns the transcoder associated with @var{port} if @var{port} is
-textual and has an associated transcoder, and returns @code{#f} if
-@var{port} is binary or does not have an associated transcoder.
-@end deffn
-
-@deffn {Scheme Procedure} binary-port? port
-Return @code{#t} if @var{port} is a @dfn{binary port}, suitable for
-binary data input/output.
-
-Note that internally Guile does not differentiate between binary and
-textual ports, unlike the R6RS. Thus, this procedure returns true when
-@var{port} does not have an associated encoding---i.e., when
-@code{(port-encoding @var{port})} is @code{#f} (@pxref{Ports,
-port-encoding}). This is the case for ports returned by R6RS procedures
-such as @code{open-bytevector-input-port} and
-@code{make-custom-binary-output-port}.
-
-However, Guile currently does not prevent use of textual I/O procedures
-such as @code{display} or @code{read-char} with binary ports. Doing so
-``upgrades'' the port from binary to textual, under the ISO-8859-1
-encoding. Likewise, Guile does not prevent use of
-@code{set-port-encoding!} on a binary port, which also turns it into a
-``textual'' port.
-@end deffn
-
-@deffn {Scheme Procedure} textual-port? port
-Always return @code{#t}, as all ports can be used for textual I/O in
-Guile.
-@end deffn
-
-@deffn {Scheme Procedure} transcoded-port binary-port transcoder
-The @code{transcoded-port} procedure
-returns a new textual port with the specified @var{transcoder}.
-Otherwise the new textual port's state is largely the same as
-that of @var{binary-port}.
-If @var{binary-port} is an input port, the new textual
-port will be an input port and
-will transcode the bytes that have not yet been read from
-@var{binary-port}.
-If @var{binary-port} is an output port, the new textual
-port will be an output port and
-will transcode output characters into bytes that are
-written to the byte sink represented by @var{binary-port}.
-
-As a side effect, however, @code{transcoded-port}
-closes @var{binary-port} in
-a special way that allows the new textual port to continue to
-use the byte source or sink represented by @var{binary-port},
-even though @var{binary-port} itself is closed and cannot
-be used by the input and output operations described in this
-chapter.
-@end deffn
-
-@deffn {Scheme Procedure} port-position port
-If @var{port} supports it (see below), return the offset (an integer)
-indicating where the next octet will be read from/written to in
-@var{port}. If @var{port} does not support this operation, an error
-condition is raised.
-
-This is similar to Guile's @code{seek} procedure with the
-@code{SEEK_CUR} argument (@pxref{Random Access}).
-@end deffn
-
-@deffn {Scheme Procedure} port-has-port-position? port
-Return @code{#t} is @var{port} supports @code{port-position}.
-@end deffn
-
-@deffn {Scheme Procedure} set-port-position! port offset
-If @var{port} supports it (see below), set the position where the next
-octet will be read from/written to @var{port} to @var{offset} (an
-integer). If @var{port} does not support this operation, an error
-condition is raised.
-
-This is similar to Guile's @code{seek} procedure with the
-@code{SEEK_SET} argument (@pxref{Random Access}).
-@end deffn
-
-@deffn {Scheme Procedure} port-has-set-port-position!? port
-Return @code{#t} is @var{port} supports @code{set-port-position!}.
-@end deffn
-
-@deffn {Scheme Procedure} call-with-port port proc
-Call @var{proc}, passing it @var{port} and closing @var{port} upon exit
-of @var{proc}. Return the return values of @var{proc}.
-@end deffn
-
-@node R6RS Input Ports
-@subsubsection Input Ports
-
-@deffn {Scheme Procedure} input-port? obj
-Returns @code{#t} if the argument is an input port (or a combined input
-and output port), and returns @code{#f} otherwise.
-@end deffn
-
-@deffn {Scheme Procedure} port-eof? input-port
-Returns @code{#t}
-if the @code{lookahead-u8} procedure (if @var{input-port} is a binary port)
-or the @code{lookahead-char} procedure (if @var{input-port} is a textual port)
-would return
-the end-of-file object, and @code{#f} otherwise.
-The operation may block indefinitely if no data is available
-but the port cannot be determined to be at end of file.
-@end deffn
-
-@deffn {Scheme Procedure} open-file-input-port filename
-@deffnx {Scheme Procedure} open-file-input-port filename file-options
-@deffnx {Scheme Procedure} open-file-input-port filename file-options buffer-mode
-@deffnx {Scheme Procedure} open-file-input-port filename file-options buffer-mode maybe-transcoder
-@var{maybe-transcoder} must be either a transcoder or @code{#f}.
-
-The @code{open-file-input-port} procedure returns an
-input port for the named file. The @var{file-options} and
-@var{maybe-transcoder} arguments are optional.
-
-The @var{file-options} argument, which may determine
-various aspects of the returned port (@pxref{R6RS File Options}),
-defaults to the value of @code{(file-options)}.
-
-The @var{buffer-mode} argument, if supplied,
-must be one of the symbols that name a buffer mode.
-The @var{buffer-mode} argument defaults to @code{block}.
-
-If @var{maybe-transcoder} is a transcoder, it becomes the transcoder associated
-with the returned port.
-
-If @var{maybe-transcoder} is @code{#f} or absent,
-the port will be a binary port and will support the
-@code{port-position} and @code{set-port-position!} operations.
-Otherwise the port will be a textual port, and whether it supports
-the @code{port-position} and @code{set-port-position!} operations
-is implementation-dependent (and possibly transcoder-dependent).
-@end deffn
-
-@deffn {Scheme Procedure} standard-input-port
-Returns a fresh binary input port connected to standard input. Whether
-the port supports the @code{port-position} and @code{set-port-position!}
-operations is implementation-dependent.
-@end deffn
-
-@deffn {Scheme Procedure} current-input-port
-This returns a default textual port for input. Normally, this default
-port is associated with standard input, but can be dynamically
-re-assigned using the @code{with-input-from-file} procedure from the
-@code{io simple (6)} library (@pxref{rnrs io simple}). The port may or
-may not have an associated transcoder; if it does, the transcoder is
-implementation-dependent.
-@end deffn
-
-@node R6RS Binary Input
-@subsubsection Binary Input
-
-@cindex binary input
-
-R6RS binary input ports can be created with the procedures described
-below.
-
-@deffn {Scheme Procedure} open-bytevector-input-port bv [transcoder]
-@deffnx {C Function} scm_open_bytevector_input_port (bv, transcoder)
-Return an input port whose contents are drawn from bytevector @var{bv}
-(@pxref{Bytevectors}).
-
-@c FIXME: Update description when implemented.
-The @var{transcoder} argument is currently not supported.
-@end deffn
-
-@cindex custom binary input ports
-
-@deffn {Scheme Procedure} make-custom-binary-input-port id read! get-position set-position! close
-@deffnx {C Function} scm_make_custom_binary_input_port (id, read!, get-position, set-position!, close)
-Return a new custom binary input port@footnote{This is similar in spirit
-to Guile's @dfn{soft ports} (@pxref{Soft Ports}).} named @var{id} (a
-string) whose input is drained by invoking @var{read!} and passing it a
-bytevector, an index where bytes should be written, and the number of
-bytes to read. The @code{read!} procedure must return an integer
-indicating the number of bytes read, or @code{0} to indicate the
-end-of-file.
-
-Optionally, if @var{get-position} is not @code{#f}, it must be a thunk
-that will be called when @code{port-position} is invoked on the custom
-binary port and should return an integer indicating the position within
-the underlying data stream; if @var{get-position} was not supplied, the
-returned port does not support @code{port-position}.
-
-Likewise, if @var{set-position!} is not @code{#f}, it should be a
-one-argument procedure. When @code{set-port-position!} is invoked on the
-custom binary input port, @var{set-position!} is passed an integer
-indicating the position of the next byte is to read.
-
-Finally, if @var{close} is not @code{#f}, it must be a thunk. It is
-invoked when the custom binary input port is closed.
-
-The returned port is fully buffered by default, but its buffering mode
-can be changed using @code{setvbuf} (@pxref{Ports and File Descriptors,
-@code{setvbuf}}).
-
-Using a custom binary input port, the @code{open-bytevector-input-port}
-procedure could be implemented as follows:
-
-@lisp
-(define (open-bytevector-input-port source)
- (define position 0)
- (define length (bytevector-length source))
-
- (define (read! bv start count)
- (let ((count (min count (- length position))))
- (bytevector-copy! source position
- bv start count)
- (set! position (+ position count))
- count))
-
- (define (get-position) position)
-
- (define (set-position! new-position)
- (set! position new-position))
-
- (make-custom-binary-input-port "the port" read!
- get-position
- set-position!))
-
-(read (open-bytevector-input-port (string->utf8 "hello")))
-@result{} hello
-@end lisp
-@end deffn
-
-@cindex binary input
-Binary input is achieved using the procedures below:
-
-@deffn {Scheme Procedure} get-u8 port
-@deffnx {C Function} scm_get_u8 (port)
-Return an octet read from @var{port}, a binary input port, blocking as
-necessary, or the end-of-file object.
-@end deffn
-
-@deffn {Scheme Procedure} lookahead-u8 port
-@deffnx {C Function} scm_lookahead_u8 (port)
-Like @code{get-u8} but does not update @var{port}'s position to point
-past the octet.
-@end deffn
-
-@deffn {Scheme Procedure} get-bytevector-n port count
-@deffnx {C Function} scm_get_bytevector_n (port, count)
-Read @var{count} octets from @var{port}, blocking as necessary and
-return a bytevector containing the octets read. If fewer bytes are
-available, a bytevector smaller than @var{count} is returned.
-@end deffn
-
-@deffn {Scheme Procedure} get-bytevector-n! port bv start count
-@deffnx {C Function} scm_get_bytevector_n_x (port, bv, start, count)
-Read @var{count} bytes from @var{port} and store them in @var{bv}
-starting at index @var{start}. Return either the number of bytes
-actually read or the end-of-file object.
-@end deffn
-
-@deffn {Scheme Procedure} get-bytevector-some port
-@deffnx {C Function} scm_get_bytevector_some (port)
-Read from @var{port}, blocking as necessary, until bytes are available
-or an end-of-file is reached. Return either the end-of-file object or a
-new bytevector containing some of the available bytes (at least one),
-and update the port position to point just past these bytes.
-@end deffn
-
-@deffn {Scheme Procedure} get-bytevector-all port
-@deffnx {C Function} scm_get_bytevector_all (port)
-Read from @var{port}, blocking as necessary, until the end-of-file is
-reached. Return either a new bytevector containing the data read or the
-end-of-file object (if no data were available).
-@end deffn
-
-The @code{(ice-9 binary-ports)} module provides the following procedure
-as an extension to @code{(rnrs io ports)}:
-
-@deffn {Scheme Procedure} unget-bytevector port bv [start [count]]
-@deffnx {C Function} scm_unget_bytevector (port, bv, start, count)
-Place the contents of @var{bv} in @var{port}, optionally starting at
-index @var{start} and limiting to @var{count} octets, so that its bytes
-will be read from left-to-right as the next bytes from @var{port} during
-subsequent read operations. If called multiple times, the unread bytes
-will be read again in last-in first-out order.
-@end deffn
-
-@node R6RS Textual Input
-@subsubsection Textual Input
-
-@deffn {Scheme Procedure} get-char textual-input-port
-Reads from @var{textual-input-port}, blocking as necessary, until a
-complete character is available from @var{textual-input-port},
-or until an end of file is reached.
-
-If a complete character is available before the next end of file,
-@code{get-char} returns that character and updates the input port to
-point past the character. If an end of file is reached before any
-character is read, @code{get-char} returns the end-of-file object.
-@end deffn
-
-@deffn {Scheme Procedure} lookahead-char textual-input-port
-The @code{lookahead-char} procedure is like @code{get-char}, but it does
-not update @var{textual-input-port} to point past the character.
-@end deffn
-
-@deffn {Scheme Procedure} get-string-n textual-input-port count
-
-@var{count} must be an exact, non-negative integer object, representing
-the number of characters to be read.
-
-The @code{get-string-n} procedure reads from @var{textual-input-port},
-blocking as necessary, until @var{count} characters are available, or
-until an end of file is reached.
-
-If @var{count} characters are available before end of file,
-@code{get-string-n} returns a string consisting of those @var{count}
-characters. If fewer characters are available before an end of file, but
-one or more characters can be read, @code{get-string-n} returns a string
-containing those characters. In either case, the input port is updated
-to point just past the characters read. If no characters can be read
-before an end of file, the end-of-file object is returned.
-@end deffn
-
-@deffn {Scheme Procedure} get-string-n! textual-input-port string start count
-
-@var{start} and @var{count} must be exact, non-negative integer objects,
-with @var{count} representing the number of characters to be read.
-@var{string} must be a string with at least $@var{start} + @var{count}$
-characters.
-
-The @code{get-string-n!} procedure reads from @var{textual-input-port}
-in the same manner as @code{get-string-n}. If @var{count} characters
-are available before an end of file, they are written into @var{string}
-starting at index @var{start}, and @var{count} is returned. If fewer
-characters are available before an end of file, but one or more can be
-read, those characters are written into @var{string} starting at index
-@var{start} and the number of characters actually read is returned as an
-exact integer object. If no characters can be read before an end of
-file, the end-of-file object is returned.
-@end deffn
-
-@deffn {Scheme Procedure} get-string-all textual-input-port
-Reads from @var{textual-input-port} until an end of file, decoding
-characters in the same manner as @code{get-string-n} and
-@code{get-string-n!}.
-
-If characters are available before the end of file, a string containing
-all the characters decoded from that data are returned. If no character
-precedes the end of file, the end-of-file object is returned.
-@end deffn
-
-@deffn {Scheme Procedure} get-line textual-input-port
-Reads from @var{textual-input-port} up to and including the linefeed
-character or end of file, decoding characters in the same manner as
-@code{get-string-n} and @code{get-string-n!}.
-
-If a linefeed character is read, a string containing all of the text up
-to (but not including) the linefeed character is returned, and the port
-is updated to point just past the linefeed character. If an end of file
-is encountered before any linefeed character is read, but some
-characters have been read and decoded as characters, a string containing
-those characters is returned. If an end of file is encountered before
-any characters are read, the end-of-file object is returned.
-
-@quotation Note
- The end-of-line style, if not @code{none}, will cause all line endings
- to be read as linefeed characters. @xref{R6RS Transcoders}.
-@end quotation
-@end deffn
-
-@deffn {Scheme Procedure} get-datum textual-input-port count
-Reads an external representation from @var{textual-input-port} and returns the
-datum it represents. The @code{get-datum} procedure returns the next
-datum that can be parsed from the given @var{textual-input-port}, updating
-@var{textual-input-port} to point exactly past the end of the external
-representation of the object.
-
-Any @emph{interlexeme space} (comment or whitespace, @pxref{Scheme
-Syntax}) in the input is first skipped. If an end of file occurs after
-the interlexeme space, the end-of-file object (@pxref{R6RS End-of-File})
-is returned.
-
-If a character inconsistent with an external representation is
-encountered in the input, an exception with condition types
-@code{&lexical} and @code{&i/o-read} is raised. Also, if the end of
-file is encountered after the beginning of an external representation,
-but the external representation is incomplete and therefore cannot be
-parsed, an exception with condition types @code{&lexical} and
-@code{&i/o-read} is raised.
-@end deffn
-
-@node R6RS Output Ports
-@subsubsection Output Ports
-
-@deffn {Scheme Procedure} output-port? obj
-Returns @code{#t} if the argument is an output port (or a
-combined input and output port), @code{#f} otherwise.
-@end deffn
-
-@deffn {Scheme Procedure} flush-output-port port
-Flushes any buffered output from the buffer of @var{output-port} to the
-underlying file, device, or object. The @code{flush-output-port}
-procedure returns an unspecified values.
-@end deffn
-
-@deffn {Scheme Procedure} open-file-output-port filename
-@deffnx {Scheme Procedure} open-file-output-port filename file-options
-@deffnx {Scheme Procedure} open-file-output-port filename file-options buffer-mode
-@deffnx {Scheme Procedure} open-file-output-port filename file-options buffer-mode maybe-transcoder
-
-@var{maybe-transcoder} must be either a transcoder or @code{#f}.
-
-The @code{open-file-output-port} procedure returns an output port for the named file.
-
-The @var{file-options} argument, which may determine various aspects of
-the returned port (@pxref{R6RS File Options}), defaults to the value of
-@code{(file-options)}.
-
-The @var{buffer-mode} argument, if supplied,
-must be one of the symbols that name a buffer mode.
-The @var{buffer-mode} argument defaults to @code{block}.
-
-If @var{maybe-transcoder} is a transcoder, it becomes the transcoder
-associated with the port.
-
-If @var{maybe-transcoder} is @code{#f} or absent,
-the port will be a binary port and will support the
-@code{port-position} and @code{set-port-position!} operations.
-Otherwise the port will be a textual port, and whether it supports
-the @code{port-position} and @code{set-port-position!} operations
-is implementation-dependent (and possibly transcoder-dependent).
-@end deffn
-
-@deffn {Scheme Procedure} standard-output-port
-@deffnx {Scheme Procedure} standard-error-port
-Returns a fresh binary output port connected to the standard output or
-standard error respectively. Whether the port supports the
-@code{port-position} and @code{set-port-position!} operations is
-implementation-dependent.
-@end deffn
-
-@deffn {Scheme Procedure} current-output-port
-@deffnx {Scheme Procedure} current-error-port
-These return default textual ports for regular output and error output.
-Normally, these default ports are associated with standard output, and
-standard error, respectively. The return value of
-@code{current-output-port} can be dynamically re-assigned using the
-@code{with-output-to-file} procedure from the @code{io simple (6)}
-library (@pxref{rnrs io simple}). A port returned by one of these
-procedures may or may not have an associated transcoder; if it does, the
-transcoder is implementation-dependent.
-@end deffn
-
-@node R6RS Binary Output
-@subsubsection Binary Output
-
-Binary output ports can be created with the procedures below.
-
-@deffn {Scheme Procedure} open-bytevector-output-port [transcoder]
-@deffnx {C Function} scm_open_bytevector_output_port (transcoder)
-Return two values: a binary output port and a procedure. The latter
-should be called with zero arguments to obtain a bytevector containing
-the data accumulated by the port, as illustrated below.
-
-@lisp
-(call-with-values
- (lambda ()
- (open-bytevector-output-port))
- (lambda (port get-bytevector)
- (display "hello" port)
- (get-bytevector)))
-
-@result{} #vu8(104 101 108 108 111)
-@end lisp
-
-@c FIXME: Update description when implemented.
-The @var{transcoder} argument is currently not supported.
-@end deffn
-
-@cindex custom binary output ports
-
-@deffn {Scheme Procedure} make-custom-binary-output-port id write! get-position set-position! close
-@deffnx {C Function} scm_make_custom_binary_output_port (id, write!, get-position, set-position!, close)
-Return a new custom binary output port named @var{id} (a string) whose
-output is sunk by invoking @var{write!} and passing it a bytevector, an
-index where bytes should be read from this bytevector, and the number of
-bytes to be ``written''. The @code{write!} procedure must return an
-integer indicating the number of bytes actually written; when it is
-passed @code{0} as the number of bytes to write, it should behave as
-though an end-of-file was sent to the byte sink.
-
-The other arguments are as for @code{make-custom-binary-input-port}
-(@pxref{R6RS Binary Input, @code{make-custom-binary-input-port}}).
-@end deffn
-
-@cindex binary output
-Writing to a binary output port can be done using the following
-procedures:
-
-@deffn {Scheme Procedure} put-u8 port octet
-@deffnx {C Function} scm_put_u8 (port, octet)
-Write @var{octet}, an integer in the 0--255 range, to @var{port}, a
-binary output port.
-@end deffn
-
-@deffn {Scheme Procedure} put-bytevector port bv [start [count]]
-@deffnx {C Function} scm_put_bytevector (port, bv, start, count)
-Write the contents of @var{bv} to @var{port}, optionally starting at
-index @var{start} and limiting to @var{count} octets.
-@end deffn
-
-@node R6RS Textual Output
-@subsubsection Textual Output
-
-@deffn {Scheme Procedure} put-char port char
-Writes @var{char} to the port. The @code{put-char} procedure returns
-an unspecified value.
-@end deffn
-
-@deffn {Scheme Procedure} put-string port string
-@deffnx {Scheme Procedure} put-string port string start
-@deffnx {Scheme Procedure} put-string port string start count
-
-@var{start} and @var{count} must be non-negative exact integer objects.
-@var{string} must have a length of at least @math{@var{start} +
-@var{count}}. @var{start} defaults to 0. @var{count} defaults to
-@math{@code{(string-length @var{string})} - @var{start}}$. The
-@code{put-string} procedure writes the @var{count} characters of
-@var{string} starting at index @var{start} to the port. The
-@code{put-string} procedure returns an unspecified value.
-@end deffn
-
-@deffn {Scheme Procedure} put-datum textual-output-port datum
-@var{datum} should be a datum value. The @code{put-datum} procedure
-writes an external representation of @var{datum} to
-@var{textual-output-port}. The specific external representation is
-implementation-dependent. However, whenever possible, an implementation
-should produce a representation for which @code{get-datum}, when reading
-the representation, will return an object equal (in the sense of
-@code{equal?}) to @var{datum}.
-
-@quotation Note
- Not all datums may allow producing an external representation for which
- @code{get-datum} will produce an object that is equal to the
- original. Specifically, NaNs contained in @var{datum} may make
- this impossible.
-@end quotation
-
-@quotation Note
- The @code{put-datum} procedure merely writes the external
- representation, but no trailing delimiter. If @code{put-datum} is
- used to write several subsequent external representations to an
- output port, care should be taken to delimit them properly so they can
- be read back in by subsequent calls to @code{get-datum}.
-@end quotation
-@end deffn
+@node Using Ports from C
+@subsection Using Ports from C
+
+Guile's C interfaces provides some niceties for sending and receiving
+bytes and characters in a way that works better with C.
+
+@deftypefn {C Function} size_t scm_c_read (SCM port, void *buffer, size_t size)
+Read up to @var{size} bytes from @var{port} and store them in
+@var{buffer}. The return value is the number of bytes actually read,
+which can be less than @var{size} if end-of-file has been reached.
+
+Note that as this is a binary input procedure, this function does not
+update @code{port-line} and @code{port-column} (@pxref{Textual I/O}).
+@end deftypefn
+
+@deftypefn {C Function} void scm_c_write (SCM port, const void *buffer, size_t size)
+Write @var{size} bytes at @var{buffer} to @var{port}.
+
+Note that as this is a binary output procedure, this function does not
+update @code{port-line} and @code{port-column} (@pxref{Textual I/O}).
+@end deftypefn
+
+@deftypefn {C Function} size_t scm_c_read_bytes (SCM port, SCM bv, size_t start, size_t count)
+@deftypefnx {C Function} void scm_c_write_bytes (SCM port, SCM bv, size_t start, size_t count)
+Like @code{scm_c_read} and @code{scm_c_write}, but reading into or
+writing from the bytevector @var{bv}. @var{count} indicates the byte
+index at which to start in the bytevector, and the read or write will
+continue for @var{count} bytes.
+@end deftypefn
+
+@deftypefn {C Function} void scm_unget_bytes (const unsigned char *buf, size_t len, SCM port)
+@deftypefnx {C Function} void scm_unget_byte (int c, SCM port)
+@deftypefnx {C Function} void scm_ungetc (scm_t_wchar c, SCM port)
+Like @code{unget-bytevector}, @code{unget-byte}, and @code{unget-char},
+respectively. @xref{Textual I/O}.
+@end deftypefn
+
+@deftypefn {C Function} void scm_c_put_latin1_chars (SCM port, const scm_t_uint8 *buf, size_t len)
+@deftypefnx {C Function} void scm_c_put_utf32_chars (SCM port, const scm_t_uint32 *buf, size_t len);
+Write a string to @var{port}. In the first case, the
+@code{scm_t_uint8*} buffer is a string in the latin-1 encoding. In the
+second, the @code{scm_t_uint32*} buffer is a string in the UTF-32
+encoding. These routines will update the port's line and column.
+@end deftypefn
@node I/O Extensions
-@subsection Using and Extending Ports in C
+@subsection Implementing New Port Types in C
-@menu
-* C Port Interface:: Using ports from C.
-* Port Implementation:: How to implement a new port type in C.
-@end menu
+This section describes how to implement a new port type in C. Although
+ports support many operations, as a data structure they present an
+opaque interface to the user. To the port implementor, you have two
+pieces of information to work with: the port type, and the port's
+``stream''. The port type is an opaque pointer allocated when defining
+your port type. It is your key into the port API, and it helps you
+identify which ports are actually yours. The ``stream'' is a pointer
+you control, and which you set when you create a port. Get a stream
+from a port using the @code{SCM_STREAM} macro. Note that your port
+methods are only ever called with ports of your type.
+A port type is created by calling @code{scm_make_port_type}. Once you
+have your port type, you can create ports with @code{scm_c_make_port},
+or @code{scm_c_make_port_with_encoding}.
-@node C Port Interface
-@subsubsection C Port Interface
-@cindex C port interface
-@cindex Port, C interface
-
-This section describes how to use Scheme ports from C.
-
-@subsubheading Port basics
-
-@cindex ptob
-@tindex scm_ptob_descriptor
-@tindex scm_port
-@findex SCM_PTAB_ENTRY
-@findex SCM_PTOBNUM
-@vindex scm_ptobs
-There are two main data structures. A port type object (ptob) is of
-type @code{scm_ptob_descriptor}. A port instance is of type
-@code{scm_port}. Given an @code{SCM} variable which points to a port,
-the corresponding C port object can be obtained using the
-@code{SCM_PTAB_ENTRY} macro. The ptob can be obtained by using
-@code{SCM_PTOBNUM} to give an index into the @code{scm_ptobs}
-global array.
-
-@subsubheading Port buffers
-
-An input port always has a read buffer and an output port always has a
-write buffer. However the size of these buffers is not guaranteed to be
-more than one byte (e.g., the @code{shortbuf} field in @code{scm_port}
-which is used when no other buffer is allocated). The way in which the
-buffers are allocated depends on the implementation of the ptob. For
-example in the case of an fport, buffers may be allocated with malloc
-when the port is created, but in the case of an strport the underlying
-string is used as the buffer.
-
-@subsubheading The @code{rw_random} flag
-
-Special treatment is required for ports which can be seeked at random.
-Before various operations, such as seeking the port or changing from
-input to output on a bidirectional port or vice versa, the port
-implementation must be given a chance to update its state. The write
-buffer is updated by calling the @code{flush} ptob procedure and the
-input buffer is updated by calling the @code{end_input} ptob procedure.
-In the case of an fport, @code{flush} causes buffered output to be
-written to the file descriptor, while @code{end_input} causes the
-descriptor position to be adjusted to account for buffered input which
-was never read.
-
-The special treatment must be performed if the @code{rw_random} flag in
-the port is non-zero.
-
-@subsubheading The @code{rw_active} variable
-
-The @code{rw_active} variable in the port is only used if
-@code{rw_random} is set. It's defined as an enum with the following
-values:
-
-@table @code
-@item SCM_PORT_READ
-the read buffer may have unread data.
-
-@item SCM_PORT_WRITE
-the write buffer may have unwritten data.
-
-@item SCM_PORT_NEITHER
-neither the write nor the read buffer has data.
-@end table
-
-@subsubheading Reading from a port.
-
-To read from a port, it's possible to either call existing libguile
-procedures such as @code{scm_getc} and @code{scm_read_line} or to read
-data from the read buffer directly. Reading from the buffer involves
-the following steps:
-
-@enumerate
-@item
-Flush output on the port, if @code{rw_active} is @code{SCM_PORT_WRITE}.
-
-@item
-Fill the read buffer, if it's empty, using @code{scm_fill_input}.
-
-@item Read the data from the buffer and update the read position in
-the buffer. Steps 2) and 3) may be repeated as many times as required.
-
-@item Set rw_active to @code{SCM_PORT_READ} if @code{rw_random} is set.
-
-@item update the port's line and column counts.
-@end enumerate
-
-@subsubheading Writing to a port.
-
-To write data to a port, calling @code{scm_lfwrite} should be sufficient for
-most purposes. This takes care of the following steps:
-
-@enumerate
-@item
-End input on the port, if @code{rw_active} is @code{SCM_PORT_READ}.
-
-@item
-Pass the data to the ptob implementation using the @code{write} ptob
-procedure. The advantage of using the ptob @code{write} instead of
-manipulating the write buffer directly is that it allows the data to be
-written in one operation even if the port is using the single-byte
-@code{shortbuf}.
-
-@item
-Set @code{rw_active} to @code{SCM_PORT_WRITE} if @code{rw_random}
-is set.
-@end enumerate
-
-
-@node Port Implementation
-@subsubsection Port Implementation
-@cindex Port implementation
-
-This section describes how to implement a new port type in C.
-
-As described in the previous section, a port type object (ptob) is
-a structure of type @code{scm_ptob_descriptor}. A ptob is created by
-calling @code{scm_make_port_type}.
-
-@deftypefun scm_t_bits scm_make_port_type (char *name, int (*fill_input) (SCM port), void (*write) (SCM port, const void *data, size_t size))
-Return a new port type object. The @var{name}, @var{fill_input} and
-@var{write} parameters are initial values for those port type fields,
-as described below. The other fields are initialized with default
-values and can be changed later.
+@deftypefun scm_t_port_type* scm_make_port_type (char *name, size_t (*read) (SCM port, SCM dst, size_t start, size_t count), size_t (*write) (SCM port, SCM src, size_t start, size_t count))
+Define a new port type. The @var{name}, @var{read} and @var{write}
+parameters are initial values for those port type fields, as described
+below. The other fields are initialized with default values and can be
+changed later.
@end deftypefun
-All of the elements of the ptob, apart from @code{name}, are procedures
-which collectively implement the port behaviour. Creating a new port
-type mostly involves writing these procedures.
+@deftypefun SCM scm_c_make_port_with_encoding (scm_t_port_type *type, unsigned long mode_bits, SCM encoding, SCM conversion_strategy, scm_t_bits stream)
+@deftypefunx SCM scm_c_make_port (scm_t_port_type *type, unsigned long mode_bits, scm_t_bits stream)
+Make a port with the given @var{type}. The @var{stream} indicates the
+private data associated with the port, which your port implementation
+may later retrieve with @code{SCM_STREAM}. The mode bits should include
+one or more of the flags @code{SCM_RDNG} or @code{SCM_WRTNG}, indicating
+that the port is an input and/or an output port, respectively. The mode
+bits may also include @code{SCM_BUF0} or @code{SCM_BUFLINE}, indicating
+that the port should be unbuffered or line-buffered, respectively. The
+default is that the port will be block-buffered. @xref{Buffering}.
+
+As you would imagine, @var{encoding} and @var{conversion_strategy}
+specify the port's initial textual encoding and conversion strategy.
+Both are symbols. @code{scm_c_make_port} is the same as
+@code{scm_c_make_port_with_encoding}, except it uses the default port
+encoding and conversion strategy.
+@end deftypefun
+
+The port type has a number of associate procedures and properties which
+collectively implement the port's behavior. Creating a new port type
+mostly involves writing these procedures.
@table @code
@item name
A pointer to a NUL terminated string: the name of the port type. This
-is the only element of @code{scm_ptob_descriptor} which is not
-a procedure. Set via the first argument to @code{scm_make_port_type}.
+property is initialized via the first argument to
+@code{scm_make_port_type}.
-@item mark
-Called during garbage collection to mark any SCM objects that a port
-object may contain. It doesn't need to be set unless the port has
-@code{SCM} components. Set using
+@item read
+A port's @code{read} implementation fills read buffers. It should copy
+bytes to the supplied bytevector @code{dst}, starting at offset
+@code{start} and continuing for @code{count} bytes, returning the number
+of bytes read.
-@deftypefun void scm_set_port_mark (scm_t_bits tc, SCM (*mark) (SCM port))
-@end deftypefun
+@item write
+A port's @code{write} implementation flushes write buffers to the
+mutable store. A port's @code{read} implementation fills read buffers.
+It should write out bytes from the supplied bytevector @code{src},
+starting at offset @code{start} and continuing for @code{count} bytes,
+and return the number of bytes that were written.
-@item free
-Called when the port is collected during gc. It
-should free any resources used by the port.
+@item read_wait_fd
+@itemx write_wait_fd
+If a port's @code{read} or @code{write} function returns @code{(size_t)
+-1}, that indicates that reading or writing would block. In that case
+to preserve the illusion of a blocking read or write operation, Guile's
+C port run-time will @code{poll} on the file descriptor returned by
+either the port's @code{read_wait_fd} or @code{write_wait_fd} function.
Set using
-@deftypefun void scm_set_port_free (scm_t_bits tc, size_t (*free) (SCM port))
+@deftypefun void scm_set_port_read_wait_fd (scm_t_port_type *type, int (*wait_fd) (SCM port))
+@deftypefunx void scm_set_port_write_wait_fd (scm_t_port_type *type, int (*wait_fd) (SCM port))
@end deftypefun
-@item print
-Called when @code{write} is called on the port object, to print a
-port description. E.g., for an fport it may produce something like:
-@code{#}. Set using
+Only a port type which implements the @code{read_wait_fd} or
+@code{write_wait_fd} port methods can usefully return @code{(size_t) -1}
+from a read or write function. @xref{Non-Blocking I/O}, for more on
+non-blocking I/O in Guile.
-@deftypefun void scm_set_port_print (scm_t_bits tc, int (*print) (SCM port, SCM dest_port, scm_print_state *pstate))
-The first argument @var{port} is the object being printed, the second
+@item print
+Called when @code{write} is called on the port, to print a port
+description. For example, for a file port it may produce something
+like: @code{#}. Set using
+
+@deftypefun void scm_set_port_print (scm_t_port_type *type, int (*print) (SCM port, SCM dest_port, scm_print_state *pstate))
+The first argument @var{port} is the port being printed, the second
argument @var{dest_port} is where its description should go.
@end deftypefun
-@item equalp
-Not used at present. Set using
-
-@deftypefun void scm_set_port_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM))
-@end deftypefun
-
@item close
-Called when the port is closed, unless it was collected during gc. It
-should free any resources used by the port.
-Set using
+Called when the port is closed. It should free any resources used by
+the port. Set using
-@deftypefun void scm_set_port_close (scm_t_bits tc, int (*close) (SCM port))
+@deftypefun void scm_set_port_close (scm_t_port_type *type, void (*close) (SCM port))
@end deftypefun
-@item write
-Accept data which is to be written using the port. The port implementation
-may choose to buffer the data instead of processing it directly.
-Set via the third argument to @code{scm_make_port_type}.
+By default, ports that are garbage collected just go away without
+closing. If your port type needs to release some external resource like
+a file descriptor, or needs to make sure that its internal buffers are
+flushed even if the port is collected while it was open, then mark the
+port type as needing a close on GC.
-@item flush
-Complete the processing of buffered output data. Reset the value of
-@code{rw_active} to @code{SCM_PORT_NEITHER}.
-Set using
-
-@deftypefun void scm_set_port_flush (scm_t_bits tc, void (*flush) (SCM port))
-@end deftypefun
-
-@item end_input
-Perform any synchronization required when switching from input to output
-on the port. Reset the value of @code{rw_active} to @code{SCM_PORT_NEITHER}.
-Set using
-
-@deftypefun void scm_set_port_end_input (scm_t_bits tc, void (*end_input) (SCM port, int offset))
-@end deftypefun
-
-@item fill_input
-Read new data into the read buffer and return the first character. It
-can be assumed that the read buffer is empty when this procedure is called.
-Set via the second argument to @code{scm_make_port_type}.
-
-@item input_waiting
-Return a lower bound on the number of bytes that could be read from the
-port without blocking. It can be assumed that the current state of
-@code{rw_active} is @code{SCM_PORT_NEITHER}.
-Set using
-
-@deftypefun void scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM port))
+@deftypefun void scm_set_port_needs_close_on_gc (scm_t_port_type *type, int needs_close_p)
@end deftypefun
@item seek
-Set the current position of the port. The procedure can not make
-any assumptions about the value of @code{rw_active} when it's
-called. It can reset the buffers first if desired by using something
-like:
+Set the current position of the port. Guile will flush read and/or
+write buffers before seeking, as appropriate.
-@example
-if (pt->rw_active == SCM_PORT_READ)
- scm_end_input (port);
-else if (pt->rw_active == SCM_PORT_WRITE)
- ptob->flush (port);
-@end example
-
-However note that this will have the side effect of discarding any data
-in the unread-char buffer, in addition to any side effects from the
-@code{end_input} and @code{flush} ptob procedures. This is undesirable
-when seek is called to measure the current position of the port, i.e.,
-@code{(seek p 0 SEEK_CUR)}. The libguile fport and string port
-implementations take care to avoid this problem.
-
-The procedure is set using
-
-@deftypefun void scm_set_port_seek (scm_t_bits tc, scm_t_off (*seek) (SCM port, scm_t_off offset, int whence))
+@deftypefun void scm_set_port_seek (scm_t_port_type *type, scm_t_off (*seek) (SCM port, scm_t_off offset, int whence))
@end deftypefun
@item truncate
-Truncate the port data to be specified length. It can be assumed that the
-current state of @code{rw_active} is @code{SCM_PORT_NEITHER}.
-Set using
+Truncate the port data to be specified length. Guile will flush buffers
+before hand, as appropriate. Set using
-@deftypefun void scm_set_port_truncate (scm_t_bits tc, void (*truncate) (SCM port, scm_t_off length))
+@deftypefun void scm_set_port_truncate (scm_t_port_type *type, void (*truncate) (SCM port, scm_t_off length))
@end deftypefun
+@item random_access_p
+Determine whether this port is a random-access port.
+
+@cindex random access
+Seeking on a random-access port with buffered input, or switching to
+writing after reading, will cause the buffered input to be discarded and
+Guile will seek the port back the buffered number of bytes. Likewise
+seeking on a random-access port with buffered output, or switching to
+reading after writing, will flush pending bytes with a call to the
+@code{write} procedure. @xref{Buffering}.
+
+Indicate to Guile that your port needs this behavior by returning a
+nonzero value from your @code{random_access_p} function. The default
+implementation of this function returns nonzero if the port type
+supplies a seek implementation.
+
+@deftypefun void scm_set_port_random_access_p (scm_t_port_type *type, int (*random_access_p) (SCM port));
+@end deftypefun
+
+@item get_natural_buffer_sizes
+Guile will internally attach buffers to ports. An input port always has
+a read buffer and an output port always has a write buffer.
+@xref{Buffering}. A port buffer consists of a bytevector, along with
+some cursors into that bytevector denoting where to get and put data.
+
+Port implementations generally don't have to be concerned with
+buffering: a port type's @code{read} or @code{write} function will
+receive the buffer's bytevector as an argument, along with an offset and
+a length into that bytevector, and should then either fill or empty that
+bytevector. However in some cases, port implementations may be able to
+provide an appropriate default buffer size to Guile.
+
+@deftypefun void scm_set_port_get_natural_buffer_sizes @
+ (scm_t_port_type *type, void (*get_natural_buffer_sizes) (SCM, size_t *read_buf_size, size_t *write_buf_size))
+Fill in @var{read_buf_size} and @var{write_buf_size} with an appropriate buffer size for this port, if one is known.
+@end deftypefun
+
+File ports implement a @code{get_natural_buffer_sizes} to let the
+operating system inform Guile about the appropriate buffer sizes for the
+particular file opened by the port.
@end table
+Note that calls to all of these methods can proceed in parallel and
+concurrently and from any thread up until the point that the port is
+closed. The call to @code{close} will happen when no other method is
+running, and no method will be called after the @code{close} method is
+called. If your port implementation needs mutual exclusion to prevent
+concurrency, it is responsible for locking appropriately.
+
+@node Non-Blocking I/O
+@subsection Non-Blocking I/O
+
+Most ports in Guile are @dfn{blocking}: when you try to read a character
+from a port, Guile will block on the read until a character is ready, or
+end-of-stream is detected. Likewise whenever Guile goes to write
+(possibly buffered) data to an output port, Guile will block until all
+the data is written.
+
+Interacting with ports in blocking mode is very convenient: you can
+write straightforward, sequential algorithms whose code flow reflects
+the flow of data. However, blocking I/O has two main limitations.
+
+The first is that it's easy to get into a situation where code is
+waiting on data. Time spent waiting on data when code could be doing
+something else is wasteful and prevents your program from reaching its
+peak throughput. If you implement a web server that sequentially
+handles requests from clients, it's very easy for the server to end up
+waiting on a client to finish its HTTP request, or waiting on it to
+consume the response. The end result is that you are able to serve
+fewer requests per second than you'd like to serve.
+
+The second limitation is related: a blocking parser over user-controlled
+input is a denial-of-service vulnerability. Indeed the so-called ``slow
+loris'' attack of the early 2010s was just that: an attack on common web
+servers that drip-fed HTTP requests, one character at a time. All it
+took was a handful of slow loris connections to occupy an entire web
+server.
+
+In Guile we would like to preserve the ability to write straightforward
+blocking networking processes of all kinds, but under the hood to allow
+those processes to suspend their requests if they would block.
+
+To do this, the first piece is to allow Guile ports to declare
+themselves as being nonblocking. This is currently supported only for
+file ports, which also includes sockets, terminals, or any other port
+that is backed by a file descriptor. To do that, we use an arcane UNIX
+incantation:
+
+@example
+(let ((flags (fcntl socket F_GETFL)))
+ (fcntl socket F_SETFL (logior O_NONBLOCK flags)))
+@end example
+
+Now the file descriptor is open in non-blocking mode. If Guile tries to
+read or write from this file and the read or write returns a result
+indicating that more data can only be had by doing a blocking read or
+write, Guile will block by polling on the socket's @code{read-wait-fd}
+or @code{write-wait-fd}, to preserve the illusion of a blocking read or
+write. @xref{I/O Extensions} for more on those internal interfaces.
+
+So far we have just reproduced the status quo: the file descriptor is
+non-blocking, but the operations on the port do block. To go farther,
+it would be nice if we could suspend the ``thread'' using delimited
+continuations, and only resume the thread once the file descriptor is
+readable or writable. (@xref{Prompts}).
+
+But here we run into a difficulty. The ports code is implemented in C,
+which means that although we can suspend the computation to some outer
+prompt, we can't resume it because Guile can't resume delimited
+continuations that capture the C stack.
+
+To overcome this difficulty we have created a compatible but entirely
+parallel implementation of port operations. To use this implementation,
+do the following:
+
+@example
+(use-modules (ice-9 suspendable-ports))
+(install-suspendable-ports!)
+@end example
+
+This will replace the core I/O primitives like @code{get-char} and
+@code{put-bytevector} with new versions that are exactly the same as the
+ones in the standard library, but with two differences. One is that
+when a read or a write would block, the suspendable port operations call
+out the value of the @code{current-read-waiter} or
+@code{current-write-waiter} parameter, as appropriate.
+@xref{Parameters}. The default read and write waiters do the same thing
+that the C read and write waiters do, which is to poll. User code can
+parameterize the waiters, though, enabling the computation to suspend
+and allow the program to process other I/O operations. Because the new
+suspendable ports implementation is written in Scheme, that suspended
+computation can resume again later when it is able to make progress.
+Success!
+
+The other main difference is that because the new ports implementation
+is written in Scheme, it is slower than C, currently by a factor of 3 or
+4, though it depends on many factors. For this reason we have to keep
+the C implementations as the default ones. One day when Guile's
+compiler is better, we can close this gap and have only one port
+operation implementation again.
+
+Note that Guile does not currently include an implementation of the
+facility to suspend the current thread and schedule other threads in the
+meantime. Before adding such a thing, we want to make sure that we're
+providing the right primitives that can be used to build schedulers and
+other user-space concurrency patterns, and that the patterns that we
+settle on are the right patterns. In the meantime, have a look at 8sync
+(@url{https://gnu.org/software/8sync}) for a prototype of an
+asynchronous I/O and concurrency facility.
+
+@deffn {Scheme Procedure} install-suspendable-ports!
+Replace the core ports implementation with suspendable ports, as
+described above. This will mutate the values of the bindings like
+@code{get-char}, @code{put-u8}, and so on in place.
+@end deffn
+
+@deffn {Scheme Procedure} uninstall-suspendable-ports!
+Restore the original core ports implementation, un-doing the effect of
+@code{install-suspendable-ports!}.
+@end deffn
+
+@deffn {Scheme Parameter} current-read-waiter
+@deffnx {Scheme Parameter} current-write-waiter
+Parameters whose values are procedures of one argument, called when a
+suspendable port operation would block on a port while reading or
+writing, respectively. The default values of these parameters do a
+blocking @code{poll} on the port's file descriptor. The procedures are
+passed the port in question as their one argument.
+@end deffn
+
+
@node BOM Handling
-@subsection Handling of Unicode byte order marks.
+@subsection Handling of Unicode Byte Order Marks
@cindex BOM
@cindex byte order mark
@@ -2475,7 +1885,7 @@ BOM. Similarly, if the user writes first, then later reads will
@emph{not} consume a BOM.
@item
-For ports that do not support seeking (e.g. pipes, sockets, and
+For ports that are not random access (e.g. pipes, sockets, and
terminals), the input and output streams are considered
@emph{independent} for purposes of BOM handling: the first read will
consume a BOM (if appropriate), and the first write will @emph{also}
diff --git a/doc/ref/api-languages.texi b/doc/ref/api-languages.texi
index fb42987d9..839e6eae2 100644
--- a/doc/ref/api-languages.texi
+++ b/doc/ref/api-languages.texi
@@ -138,7 +138,7 @@ only one bit, and so a test for, for example, @code{#f}-or-@code{nil}
may be made very efficiently. See @code{libguile/boolean.h}, for more
information.
-@subsubsection Equality
+@subsubheading Equality
Since Scheme's @code{equal?} must be transitive, and @code{'()}
is not @code{equal?} to @code{#f}, to Scheme @code{nil} is not
@@ -229,7 +229,7 @@ Here are correct versions of the above examples:
This problem has a mirror-image case in Elisp:
@example
-(deffn my-falsep (x)
+(defun my-falsep (x)
(if (eq x nil)
t
nil))
diff --git a/doc/ref/api-macros.texi b/doc/ref/api-macros.texi
index 9964e6b06..7fa62e3d6 100644
--- a/doc/ref/api-macros.texi
+++ b/doc/ref/api-macros.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010, 2011,
-@c 2012, 2013, 2014 Free Software Foundation, Inc.
+@c Copyright (C) 1996, 1997, 2000-2004, 2009-2015
+@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Macros
@@ -618,9 +618,9 @@ won't have access to the binding of @code{it}.
But they can, if we explicitly introduce a binding via @code{datum->syntax}.
-@deffn {Scheme Procedure} datum->syntax for-syntax datum
+@deffn {Scheme Procedure} datum->syntax template-id datum
Create a syntax object that wraps @var{datum}, within the lexical context
-corresponding to the syntax object @var{for-syntax}.
+corresponding to the identifier @var{template-id}.
@end deffn
For completeness, we should mention that it is possible to strip the metadata
@@ -791,6 +791,44 @@ Return the source properties that correspond to the syntax object
@var{x}. @xref{Source Properties}, for more information.
@end deffn
+And now, a bit of confession time. Guile's syntax expander originates
+in code from Chez Scheme: a version of the expander in Chez Scheme that
+was made portable to other Scheme systems. Way back in the mid-1990s,
+some Scheme systems didn't even have the ability to define new abstract
+data types. For this reason, the portable expander from Chez Scheme
+that Guile inherited used tagged vectors as syntax objects: vectors
+whose first element was the symbol, @code{syntax-object}.
+
+At the time of this writing it is 2017 and Guile still has support for
+this strategy. It worked for this long because no one ever puts a
+literal vector in the operator position:
+
+@example
+(#(syntax-object ...) 1 2 3)
+@end example
+
+But this state of affairs was an error. Because syntax objects are just
+vectors, this makes it possible for any Scheme code to forge a syntax
+object which might cause it to violate abstraction boundaries. You
+can't build a sandboxing facility that limits the set of bindings in
+scope when one can always escape that limit just by evaluating a special
+vector. To fix this problem, Guile 2.2.1 finally migrated to represent
+syntax objects as a distinct type with a distinct constructor that is
+unavailable to user code.
+
+However, Guile still has to support ``legacy'' syntax objects, because
+it could be that a file compiled with Guile 2.2.0 embeds syntax objects
+of the vector kind. Whether the expander treats the special tagged
+vectors as syntax objects is now controllable by the
+@code{allow-legacy-syntax-objects?} parameter:
+
+@deffn {Scheme Procedure} allow-legacy-syntax-objects?
+A parameter that indicates whether the expander should support legacy
+syntax objects, as described above. For ABI stability reasons, the
+default is @code{#t}. Use @code{parameterize} to bind it to @code{#f}.
+@xref{Parameters}.
+@end deffn
+
Guile also offers some more experimental interfaces in a separate
module. As was the case with the Large Hadron Collider, it is unclear
to our senior macrologists whether adding these interfaces will result
diff --git a/doc/ref/api-memory.texi b/doc/ref/api-memory.texi
index 0e37d16fc..ce0187b14 100644
--- a/doc/ref/api-memory.texi
+++ b/doc/ref/api-memory.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010, 2012, 2013, 2014
+@c Copyright (C) 1996, 1997, 2000-2004, 2009, 2010, 2012-2016
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -27,24 +27,26 @@ collection relates to using Guile from C.
@deffn {Scheme Procedure} gc
@deffnx {C Function} scm_gc ()
-Scans all of SCM objects and reclaims for further use those that are
-no longer accessible. You normally don't need to call this function
-explicitly. It is called automatically when appropriate.
+Finds all of the ``live'' @code{SCM} objects and reclaims for further
+use those that are no longer accessible. You normally don't need to
+call this function explicitly. Its functionality is invoked
+automatically as needed.
@end deffn
@deftypefn {C Function} SCM scm_gc_protect_object (SCM @var{obj})
Protects @var{obj} from being freed by the garbage collector, when it
otherwise might be. When you are done with the object, call
@code{scm_gc_unprotect_object} on the object. Calls to
-@code{scm_gc_protect}/@code{scm_gc_unprotect_object} can be nested, and
+@code{scm_gc_protect_object}/@code{scm_gc_unprotect_object} can be nested, and
the object remains protected until it has been unprotected as many times
as it was protected. It is an error to unprotect an object more times
than it has been protected. Returns the SCM object it was passed.
Note that storing @var{obj} in a C global variable has the same
effect@footnote{In Guile up to version 1.8, C global variables were not
-scanned by the garbage collector; hence, @code{scm_gc_protect_object}
-was the only way in C to prevent a Scheme object from being freed.}.
+visited by the garbage collector in the mark phase; hence,
+@code{scm_gc_protect_object} was the only way in C to prevent a Scheme
+object from being freed.}.
@end deftypefn
@deftypefn {C Function} SCM scm_gc_unprotect_object (SCM @var{obj})
@@ -123,16 +125,18 @@ live reference to it@footnote{In Guile up to version 1.8, memory
allocated with @code{scm_gc_malloc} @emph{had} to be freed with
@code{scm_gc_free}.}.
-Memory allocated with @code{scm_gc_malloc} is scanned for live pointers.
-This means that if @code{scm_gc_malloc}-allocated memory contains a
-pointer to some other part of the memory, the garbage collector notices
-it and prevents it from being reclaimed@footnote{In Guile up to 1.8,
-memory allocated with @code{scm_gc_malloc} was @emph{not} scanned.
-Consequently, the GC had to be told explicitly about pointers to live
-objects contained in the memory block, e.g., @i{via} SMOB mark functions
-(@pxref{Smobs, @code{scm_set_smob_mark}})}. Conversely, memory
-allocated with @code{scm_gc_malloc_pointerless} is assumed to be
-``pointer-less'' and is not scanned.
+When garbage collection occurs, Guile will visit the words in memory
+allocated with @code{scm_gc_malloc}, looking for live pointers. This
+means that if @code{scm_gc_malloc}-allocated memory contains a pointer
+to some other part of the memory, the garbage collector notices it and
+prevents it from being reclaimed@footnote{In Guile up to 1.8, memory
+allocated with @code{scm_gc_malloc} was @emph{not} visited by the
+collector in the mark phase. Consequently, the GC had to be told
+explicitly about pointers to live objects contained in the memory block,
+e.g., @i{via} SMOB mark functions (@pxref{Smobs,
+@code{scm_set_smob_mark}})}. Conversely, memory allocated with
+@code{scm_gc_malloc_pointerless} is assumed to be ``pointer-less'' and
+is not scanned for pointers.
For memory that is not associated with a Scheme object, you can use
@code{scm_malloc} instead of @code{malloc}. Like
@@ -193,9 +197,11 @@ Allocate @var{size} bytes of automatically-managed memory. The memory
is automatically freed when no longer referenced from any live memory
block.
-Memory allocated with @code{scm_gc_malloc} or @code{scm_gc_calloc} is
-scanned for pointers. Memory allocated by
-@code{scm_gc_malloc_pointerless} is not scanned.
+When garbage collection occurs, Guile will visit the words in memory
+allocated with @code{scm_gc_malloc} or @code{scm_gc_calloc}, looking for
+pointers to other memory allocations that are managed by the GC. In
+contrast, memory allocated by @code{scm_gc_malloc_pointerless} is not
+scanned for pointers.
The @code{scm_gc_realloc} call preserves the ``pointerlessness'' of the
memory area pointed to by @var{mem}. Note that you need to pass the old
@@ -309,10 +315,18 @@ Return a weak hash table with @var{size} buckets. As with any
hash table, choosing a good size for the table requires some
caution.
-You can modify weak hash tables in exactly the same way you
-would modify regular hash tables. (@pxref{Hash Tables})
+You can modify weak hash tables in exactly the same way you would modify
+regular hash tables, with the exception of the routines that act on
+handles. Weak tables have a different implementation behind the scenes
+that doesn't have handles. @pxref{Hash Tables}, for more on
+@code{hashq-ref} et al.
@end deffn
+Note that in a weak-key hash table, the reference to the value is
+strong. This means that if the value references the key, even
+indirectly, the key will never be collected, which can lead to a memory
+leak. The reverse is true for weak value tables.
+
@deffn {Scheme Procedure} weak-key-hash-table? obj
@deffnx {Scheme Procedure} weak-value-hash-table? obj
@deffnx {Scheme Procedure} doubly-weak-hash-table? obj
diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi
index 4c46f2984..8f18b1e62 100644
--- a/doc/ref/api-modules.texi
+++ b/doc/ref/api-modules.texi
@@ -171,8 +171,8 @@ of @code{@@} and should only be used as a last resort or for
debugging, for example.
Note that just as with a @code{use-modules} statement, any module that
-has not yet been loaded yet will be loaded when referenced by a
-@code{@@} or @code{@@@@} form.
+has not yet been loaded will be loaded when referenced by a @code{@@} or
+@code{@@@@} form.
You can also use the @code{@@} and @code{@@@@} syntaxes as the target
of a @code{set!} when the binding refers to a variable.
diff --git a/doc/ref/api-options.texi b/doc/ref/api-options.texi
index b09ae8952..0259b4b21 100644
--- a/doc/ref/api-options.texi
+++ b/doc/ref/api-options.texi
@@ -241,7 +241,7 @@ procedures (@pxref{Arrays}).
@item char-ready?
Indicates that the @code{char-ready?} function is available
-(@pxref{Reading}).
+(@pxref{Venerable Port Interfaces}).
@item complex
Indicates support for complex numbers.
@@ -284,8 +284,11 @@ Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
@item fork
Indicates support for the POSIX @code{fork} function (@pxref{Processes,
-@code{primitive-fork}}). This is a prerequisite for the @code{(ice-9
-popen)} module (@pxref{Pipes}).
+@code{primitive-fork}}).
+
+@item popen
+Indicates support for @code{open-pipe} in the @code{(ice-9 popen)}
+module (@pxref{Pipes}).
@item random
Indicates availability of random number generation functions:
diff --git a/doc/ref/api-procedures.texi b/doc/ref/api-procedures.texi
index 02bf6822a..df24178f9 100644
--- a/doc/ref/api-procedures.texi
+++ b/doc/ref/api-procedures.texi
@@ -836,7 +836,7 @@ Let us call this new procedure @code{foo}.
(define foo (make-procedure-with-setter foo-ref foo-set!))
@end lisp
-@code{foo} can from now an be used to either read from the data
+@code{foo} can from now on be used to either read from the data
structure stored in @code{f}, or to write into the structure.
@lisp
diff --git a/doc/ref/api-regex.texi b/doc/ref/api-regex.texi
index 082fb874d..b14c2b39c 100644
--- a/doc/ref/api-regex.texi
+++ b/doc/ref/api-regex.texi
@@ -14,10 +14,7 @@
A @dfn{regular expression} (or @dfn{regexp}) is a pattern that
describes a whole class of strings. A full description of regular
-expressions and their syntax is beyond the scope of this manual;
-an introduction can be found in the Emacs manual (@pxref{Regexps,
-, Syntax of Regular Expressions, emacs, The GNU Emacs Manual}), or
-in many general Unix reference books.
+expressions and their syntax is beyond the scope of this manual.
If your system does not include a POSIX regular expression library,
and you have not linked Guile with a third-party regexp library such
@@ -41,10 +38,11 @@ regex))}.
@node Regexp Functions
@subsection Regexp Functions
-By default, Guile supports POSIX extended regular expressions.
-That means that the characters @samp{(}, @samp{)}, @samp{+} and
-@samp{?} are special, and must be escaped if you wish to match the
-literal characters.
+By default, Guile supports POSIX extended regular expressions. That
+means that the characters @samp{(}, @samp{)}, @samp{+} and @samp{?} are
+special, and must be escaped if you wish to match the literal characters
+and there is no support for ``non-greedy'' variants of @samp{*},
+@samp{+} or @samp{?}.
This regular expression interface was modeled after that
implemented by SCSH, the Scheme Shell. It is intended to be
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index 0d036be9e..7b39a03d6 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -8,189 +8,17 @@
@section Threads, Mutexes, Asyncs and Dynamic Roots
@menu
-* Arbiters:: Synchronization primitives.
-* Asyncs:: Asynchronous procedure invocation.
* Threads:: Multiple threads of execution.
+* Thread Local Variables:: Some fluids are thread-local.
+* Asyncs:: Asynchronous interrupts.
+* Atomics:: Atomic references.
* Mutexes and Condition Variables:: Synchronization primitives.
* Blocking:: How to block properly in guile mode.
-* Critical Sections:: Avoiding concurrency and reentries.
-* Fluids and Dynamic States:: Thread-local variables, etc.
-* Parameters:: Dynamic scoping in Scheme.
* Futures:: Fine-grain parallelism.
* Parallel Forms:: Parallel execution of forms.
@end menu
-@node Arbiters
-@subsection Arbiters
-@cindex arbiters
-
-Arbiters are synchronization objects, they can be used by threads to
-control access to a shared resource. An arbiter can be locked to
-indicate a resource is in use, and unlocked when done.
-
-An arbiter is like a light-weight mutex (@pxref{Mutexes and Condition
-Variables}). It uses less memory and may be faster, but there's no
-way for a thread to block waiting on an arbiter, it can only test and
-get the status returned.
-
-@deffn {Scheme Procedure} make-arbiter name
-@deffnx {C Function} scm_make_arbiter (name)
-Return an object of type arbiter and name @var{name}. Its
-state is initially unlocked. Arbiters are a way to achieve
-process synchronization.
-@end deffn
-
-@deffn {Scheme Procedure} try-arbiter arb
-@deffnx {C Function} scm_try_arbiter (arb)
-If @var{arb} is unlocked, then lock it and return @code{#t}.
-If @var{arb} is already locked, then do nothing and return
-@code{#f}.
-@end deffn
-
-@deffn {Scheme Procedure} release-arbiter arb
-@deffnx {C Function} scm_release_arbiter (arb)
-If @var{arb} is locked, then unlock it and return @code{#t}. If
-@var{arb} is already unlocked, then do nothing and return @code{#f}.
-
-Typical usage is for the thread which locked an arbiter to later
-release it, but that's not required, any thread can release it.
-@end deffn
-
-
-@node Asyncs
-@subsection Asyncs
-
-@cindex asyncs
-@cindex user asyncs
-@cindex system asyncs
-
-Asyncs are a means of deferring the execution of Scheme code until it is
-safe to do so.
-
-Guile provides two kinds of asyncs that share the basic concept but are
-otherwise quite different: system asyncs and user asyncs. System asyncs
-are integrated into the core of Guile and are executed automatically
-when the system is in a state to allow the execution of Scheme code.
-For example, it is not possible to execute Scheme code in a POSIX signal
-handler, but such a signal handler can queue a system async to be
-executed in the near future, when it is safe to do so.
-
-System asyncs can also be queued for threads other than the current one.
-This way, you can cause threads to asynchronously execute arbitrary
-code.
-
-User asyncs offer a convenient means of queuing procedures for future
-execution and triggering this execution. They will not be executed
-automatically.
-
-@menu
-* System asyncs::
-* User asyncs::
-@end menu
-
-@node System asyncs
-@subsubsection System asyncs
-
-To cause the future asynchronous execution of a procedure in a given
-thread, use @code{system-async-mark}.
-
-Automatic invocation of system asyncs can be temporarily disabled by
-calling @code{call-with-blocked-asyncs}. This function works by
-temporarily increasing the @emph{async blocking level} of the current
-thread while a given procedure is running. The blocking level starts
-out at zero, and whenever a safe point is reached, a blocking level
-greater than zero will prevent the execution of queued asyncs.
-
-Analogously, the procedure @code{call-with-unblocked-asyncs} will
-temporarily decrease the blocking level of the current thread. You
-can use it when you want to disable asyncs by default and only allow
-them temporarily.
-
-In addition to the C versions of @code{call-with-blocked-asyncs} and
-@code{call-with-unblocked-asyncs}, C code can use
-@code{scm_dynwind_block_asyncs} and @code{scm_dynwind_unblock_asyncs}
-inside a @dfn{dynamic context} (@pxref{Dynamic Wind}) to block or
-unblock system asyncs temporarily.
-
-@deffn {Scheme Procedure} system-async-mark proc [thread]
-@deffnx {C Function} scm_system_async_mark (proc)
-@deffnx {C Function} scm_system_async_mark_for_thread (proc, thread)
-Mark @var{proc} (a procedure with zero arguments) for future execution
-in @var{thread}. When @var{proc} has already been marked for
-@var{thread} but has not been executed yet, this call has no effect.
-When @var{thread} is omitted, the thread that called
-@code{system-async-mark} is used.
-
-This procedure is not safe to be called from signal handlers. Use
-@code{scm_sigaction} or @code{scm_sigaction_for_thread} to install
-signal handlers.
-@end deffn
-
-@deffn {Scheme Procedure} call-with-blocked-asyncs proc
-@deffnx {C Function} scm_call_with_blocked_asyncs (proc)
-Call @var{proc} and block the execution of system asyncs by one level
-for the current thread while it is running. Return the value returned
-by @var{proc}. For the first two variants, call @var{proc} with no
-arguments; for the third, call it with @var{data}.
-@end deffn
-
-@deftypefn {C Function} {void *} scm_c_call_with_blocked_asyncs (void * (*proc) (void *data), void *data)
-The same but with a C function @var{proc} instead of a Scheme thunk.
-@end deftypefn
-
-@deffn {Scheme Procedure} call-with-unblocked-asyncs proc
-@deffnx {C Function} scm_call_with_unblocked_asyncs (proc)
-Call @var{proc} and unblock the execution of system asyncs by one
-level for the current thread while it is running. Return the value
-returned by @var{proc}. For the first two variants, call @var{proc}
-with no arguments; for the third, call it with @var{data}.
-@end deffn
-
-@deftypefn {C Function} {void *} scm_c_call_with_unblocked_asyncs (void *(*proc) (void *data), void *data)
-The same but with a C function @var{proc} instead of a Scheme thunk.
-@end deftypefn
-
-@deftypefn {C Function} void scm_dynwind_block_asyncs ()
-During the current dynwind context, increase the blocking of asyncs by
-one level. This function must be used inside a pair of calls to
-@code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic
-Wind}).
-@end deftypefn
-
-@deftypefn {C Function} void scm_dynwind_unblock_asyncs ()
-During the current dynwind context, decrease the blocking of asyncs by
-one level. This function must be used inside a pair of calls to
-@code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic
-Wind}).
-@end deftypefn
-
-@node User asyncs
-@subsubsection User asyncs
-
-A user async is a pair of a thunk (a parameterless procedure) and a
-mark. Setting the mark on a user async will cause the thunk to be
-executed when the user async is passed to @code{run-asyncs}. Setting
-the mark more than once is satisfied by one execution of the thunk.
-
-User asyncs are created with @code{async}. They are marked with
-@code{async-mark}.
-
-@deffn {Scheme Procedure} async thunk
-@deffnx {C Function} scm_async (thunk)
-Create a new user async for the procedure @var{thunk}.
-@end deffn
-
-@deffn {Scheme Procedure} async-mark a
-@deffnx {C Function} scm_async_mark (a)
-Mark the user async @var{a} for future execution.
-@end deffn
-
-@deffn {Scheme Procedure} run-asyncs list_of_a
-@deffnx {C Function} scm_run_asyncs (list_of_a)
-Execute all thunks from the marked asyncs of the list @var{list_of_a}.
-@end deffn
-
@node Threads
@subsection Threads
@cindex threads
@@ -207,6 +35,12 @@ the system's POSIX threads. For application-level parallelism, using
higher-level constructs, such as futures, is recommended
(@pxref{Futures}).
+To use these facilities, load the @code{(ice-9 threads)} module.
+
+@example
+(use-modules (ice-9 threads))
+@end example
+
@deffn {Scheme Procedure} all-threads
@deffnx {C Function} scm_all_threads ()
Return a list of all threads.
@@ -217,7 +51,6 @@ Return a list of all threads.
Return the thread that called this function.
@end deffn
-@c begin (texi-doc-string "guile" "call-with-new-thread")
@deffn {Scheme Procedure} call-with-new-thread thunk [handler]
Call @code{thunk} in a new thread and with a new dynamic state,
returning the new thread. The procedure @var{thunk} is called via
@@ -251,17 +84,18 @@ Return @code{#t} ff @var{obj} is a thread; otherwise, return
@code{#f}.
@end deffn
-@c begin (texi-doc-string "guile" "join-thread")
@deffn {Scheme Procedure} join-thread thread [timeout [timeoutval]]
@deffnx {C Function} scm_join_thread (thread)
@deffnx {C Function} scm_join_thread_timed (thread, timeout, timeoutval)
-Wait for @var{thread} to terminate and return its exit value. Threads
-that have not been created with @code{call-with-new-thread} or
-@code{scm_spawn_thread} have an exit value of @code{#f}. When
-@var{timeout} is given, it specifies a point in time where the waiting
-should be aborted. It can be either an integer as returned by
-@code{current-time} or a pair as returned by @code{gettimeofday}.
-When the waiting is aborted, @var{timeoutval} is returned (if it is
+Wait for @var{thread} to terminate and return its exit value. Only
+threads that were created with @code{call-with-new-thread} or
+@code{scm_spawn_thread} can be joinable; attempting to join a foreign
+thread will raise an error.
+
+When @var{timeout} is given, it specifies a point in time where the
+waiting should be aborted. It can be either an integer as returned by
+@code{current-time} or a pair as returned by @code{gettimeofday}. When
+the waiting is aborted, @var{timeoutval} is returned (if it is
specified; @code{#f} is returned otherwise).
@end deffn
@@ -270,52 +104,25 @@ specified; @code{#f} is returned otherwise).
Return @code{#t} if @var{thread} has exited, or @code{#f} otherwise.
@end deffn
-@c begin (texi-doc-string "guile" "yield")
@deffn {Scheme Procedure} yield
+@deffnx {C Function} scm_yield (thread)
If one or more threads are waiting to execute, calling yield forces an
immediate context switch to one of them. Otherwise, yield has no effect.
@end deffn
-@deffn {Scheme Procedure} cancel-thread thread
+@deffn {Scheme Procedure} cancel-thread thread . values
@deffnx {C Function} scm_cancel_thread (thread)
-Asynchronously notify @var{thread} to exit. Immediately after
-receiving this notification, @var{thread} will call its cleanup handler
-(if one has been set) and then terminate, aborting any evaluation that
-is in progress.
+Asynchronously interrupt @var{thread} and ask it to terminate.
+@code{dynamic-wind} post thunks will run, but throw handlers will not.
+If @var{thread} has already terminated or been signaled to terminate,
+this function is a no-op. Calling @code{join-thread} on the thread will
+return the given @var{values}, if the cancel succeeded.
-Because Guile threads are isomorphic with POSIX threads, @var{thread}
-will not receive its cancellation signal until it reaches a cancellation
-point. See your operating system's POSIX threading documentation for
-more information on cancellation points; note that in Guile, unlike
-native POSIX threads, a thread can receive a cancellation notification
-while attempting to lock a mutex.
+Under the hood, thread cancellation uses @code{system-async-mark} and
+@code{abort-to-prompt}. @xref{Asyncs} for more on asynchronous
+interrupts.
@end deffn
-@deffn {Scheme Procedure} set-thread-cleanup! thread proc
-@deffnx {C Function} scm_set_thread_cleanup_x (thread, proc)
-Set @var{proc} as the cleanup handler for the thread @var{thread}.
-@var{proc}, which must be a thunk, will be called when @var{thread}
-exits, either normally or by being canceled. Thread cleanup handlers
-can be used to perform useful tasks like releasing resources, such as
-locked mutexes, when thread exit cannot be predicted.
-
-The return value of @var{proc} will be set as the @emph{exit value} of
-@var{thread}.
-
-To remove a cleanup handler, pass @code{#f} for @var{proc}.
-@end deffn
-
-@deffn {Scheme Procedure} thread-cleanup thread
-@deffnx {C Function} scm_thread_cleanup (thread)
-Return the cleanup handler currently installed for the thread
-@var{thread}. If no cleanup handler is currently installed,
-thread-cleanup returns @code{#f}.
-@end deffn
-
-Higher level thread procedures are available by loading the
-@code{(ice-9 threads)} module. These provide standardized
-thread creation.
-
@deffn macro make-thread proc arg @dots{}
Apply @var{proc} to @var{arg} @dots{} in a new thread formed by
@code{call-with-new-thread} using a default error handler that display
@@ -329,49 +136,418 @@ Evaluate forms @var{expr1} @var{expr2} @dots{} in a new thread formed by
the error to the current error port.
@end deffn
+One often wants to limit the number of threads running to be
+proportional to the number of available processors. These interfaces
+are therefore exported by (ice-9 threads) as well.
+
+@deffn {Scheme Procedure} total-processor-count
+@deffnx {C Function} scm_total_processor_count ()
+Return the total number of processors of the machine, which
+is guaranteed to be at least 1. A ``processor'' here is a
+thread execution unit, which can be either:
+
+@itemize
+@item an execution core in a (possibly multi-core) chip, in a
+ (possibly multi- chip) module, in a single computer, or
+@item a thread execution unit inside a core in the case of
+ @dfn{hyper-threaded} CPUs.
+@end itemize
+
+Which of the two definitions is used, is unspecified.
+@end deffn
+
+@deffn {Scheme Procedure} current-processor-count
+@deffnx {C Function} scm_current_processor_count ()
+Like @code{total-processor-count}, but return the number of
+processors available to the current process. See
+@code{setaffinity} and @code{getaffinity} for more
+information.
+@end deffn
+
+
+@node Thread Local Variables
+@subsection Thread-Local Variables
+
+Sometimes you want to establish a variable binding that is only valid
+for a given thread: a ``thread-local variable''.
+
+You would think that fluids or parameters would be Guile's answer for
+thread-local variables, since establishing a new fluid binding doesn't
+affect bindings in other threads. @xref{Fluids and Dynamic States}, or
+@xref{Parameters}. However, new threads inherit the fluid bindings that
+were in place in their creator threads. In this way, a binding
+established using a fluid (or a parameter) in a thread can escape to
+other threads, which might not be what you want. Or, it might escape
+via explicit reification via @code{current-dynamic-state}.
+
+Of course, this dynamic scoping might be exactly what you want; that's
+why fluids and parameters work this way, and is what you want for for
+many common parameters such as the current input and output ports, the
+current locale conversion parameters, and the like. Perhaps this is the
+case for most parameters, even. If your use case for thread-local
+bindings comes from a desire to isolate a binding from its setting in
+unrelated threads, then fluids and parameters apply nicely.
+
+On the other hand, if your use case is to prevent concurrent access to a
+value from multiple threads, then using vanilla fluids or parameters is
+not appropriate. For this purpose, Guile has @dfn{thread-local fluids}.
+A fluid created with @code{make-thread-local-fluid} won't be captured by
+@code{current-dynamic-state} and won't be propagated to new threads.
+
+@deffn {Scheme Procedure} make-thread-local-fluid [dflt]
+@deffnx {C Function} scm_make_thread_local_fluid (dflt)
+Return a newly created fluid, whose initial value is @var{dflt}, or
+@code{#f} if @var{dflt} is not given. Unlike fluids made with
+@code{make-fluid}, thread local fluids are not captured by
+@code{make-dynamic-state}. Similarly, a newly spawned child thread does
+not inherit thread-local fluid values from the parent thread.
+@end deffn
+
+@deffn {Scheme Procedure} fluid-thread-local? fluid
+@deffnx {C Function} scm_fluid_thread_local_p (fluid)
+Return @code{#t} if the fluid @var{fluid} is is thread-local, or
+@code{#f} otherwise.
+@end deffn
+
+For example:
+
+@example
+(define %thread-local (make-thread-local-fluid))
+
+(with-fluids ((%thread-local (compute-data)))
+ ... (fluid-ref %thread-local) ...)
+@end example
+
+You can also make a thread-local parameter out of a thread-local fluid
+using the normal @code{fluid->parameter}:
+
+@example
+(define param (fluid->parameter (make-thread-local-fluid)))
+
+(parameterize ((param (compute-data)))
+ ... (param) ...)
+@end example
+
+
+@node Asyncs
+@subsection Asynchronous Interrupts
+
+@cindex asyncs
+@cindex asynchronous interrupts
+@cindex interrupts
+
+Every Guile thread can be interrupted. Threads running Guile code will
+periodically check if there are pending interrupts and run them if
+necessary. To interrupt a thread, call @code{system-async-mark} on that
+thread.
+
+@deffn {Scheme Procedure} system-async-mark proc [thread]
+@deffnx {C Function} scm_system_async_mark (proc)
+@deffnx {C Function} scm_system_async_mark_for_thread (proc, thread)
+Enqueue @var{proc} (a procedure with zero arguments) for future
+execution in @var{thread}. When @var{proc} has already been enqueued
+for @var{thread} but has not been executed yet, this call has no effect.
+When @var{thread} is omitted, the thread that called
+@code{system-async-mark} is used.
+@end deffn
+
+Note that @code{scm_system_async_mark_for_thread} is not
+``async-signal-safe'' and so cannot be called from a C signal handler.
+(Indeed in general, @code{libguile} functions are not safe to call from
+C signal handlers.)
+
+Though an interrupt procedure can have any side effect permitted to
+Guile code, asynchronous interrupts are generally used either for
+profiling or for prematurely cancelling a computation. The former case
+is mostly transparent to the program being run, by design, but the
+latter case can introduce bugs. Like finalizers (@pxref{Foreign Object
+Memory Management}), asynchronous interrupts introduce concurrency in a
+program. An asyncronous interrupt can run in the middle of some
+mutex-protected operation, for example, and potentially corrupt the
+program's state.
+
+If some bit of Guile code needs to temporarily inhibit interrupts, it
+can use @code{call-with-blocked-asyncs}. This function works by
+temporarily increasing the @emph{async blocking level} of the current
+thread while a given procedure is running. The blocking level starts
+out at zero, and whenever a safe point is reached, a blocking level
+greater than zero will prevent the execution of queued asyncs.
+
+Analogously, the procedure @code{call-with-unblocked-asyncs} will
+temporarily decrease the blocking level of the current thread. You
+can use it when you want to disable asyncs by default and only allow
+them temporarily.
+
+In addition to the C versions of @code{call-with-blocked-asyncs} and
+@code{call-with-unblocked-asyncs}, C code can use
+@code{scm_dynwind_block_asyncs} and @code{scm_dynwind_unblock_asyncs}
+inside a @dfn{dynamic context} (@pxref{Dynamic Wind}) to block or
+unblock asyncs temporarily.
+
+@deffn {Scheme Procedure} call-with-blocked-asyncs proc
+@deffnx {C Function} scm_call_with_blocked_asyncs (proc)
+Call @var{proc} and block the execution of asyncs by one level for the
+current thread while it is running. Return the value returned by
+@var{proc}. For the first two variants, call @var{proc} with no
+arguments; for the third, call it with @var{data}.
+@end deffn
+
+@deftypefn {C Function} {void *} scm_c_call_with_blocked_asyncs (void * (*proc) (void *data), void *data)
+The same but with a C function @var{proc} instead of a Scheme thunk.
+@end deftypefn
+
+@deffn {Scheme Procedure} call-with-unblocked-asyncs proc
+@deffnx {C Function} scm_call_with_unblocked_asyncs (proc)
+Call @var{proc} and unblock the execution of asyncs by one level for the
+current thread while it is running. Return the value returned by
+@var{proc}. For the first two variants, call @var{proc} with no
+arguments; for the third, call it with @var{data}.
+@end deffn
+
+@deftypefn {C Function} {void *} scm_c_call_with_unblocked_asyncs (void *(*proc) (void *data), void *data)
+The same but with a C function @var{proc} instead of a Scheme thunk.
+@end deftypefn
+
+@deftypefn {C Function} void scm_dynwind_block_asyncs ()
+During the current dynwind context, increase the blocking of asyncs by
+one level. This function must be used inside a pair of calls to
+@code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic
+Wind}).
+@end deftypefn
+
+@deftypefn {C Function} void scm_dynwind_unblock_asyncs ()
+During the current dynwind context, decrease the blocking of asyncs by
+one level. This function must be used inside a pair of calls to
+@code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic
+Wind}).
+@end deftypefn
+
+Sometimes you want to interrupt a thread that might be waiting for
+something to happen, for example on a file descriptor or a condition
+variable. In that case you can inform Guile of how to interrupt that
+wait using the following procedures:
+
+@deftypefn {C Function} int scm_c_prepare_to_wait_on_fd (int fd)
+Inform Guile that the current thread is about to sleep, and that if an
+asynchronous interrupt is signalled on this thread, Guile should wake up
+the thread by writing a zero byte to @var{fd}. Returns zero if the
+prepare succeeded, or nonzero if the thread already has a pending async
+and that it should avoid waiting.
+@end deftypefn
+
+@deftypefn {C Function} int scm_c_prepare_to_wait_on_cond (scm_i_pthread_mutex_t *mutex, scm_i_pthread_cond_t *cond)
+Inform Guile that the current thread is about to sleep, and that if an
+asynchronous interrupt is signalled on this thread, Guile should wake up
+the thread by acquiring @var{mutex} and signalling @var{cond}. The
+caller must already hold @var{mutex} and only drop it as part of the
+@code{pthread_cond_wait} call. Returns zero if the prepare succeeded,
+or nonzero if the thread already has a pending async and that it should
+avoid waiting.
+@end deftypefn
+
+@deftypefn {C Function} void scm_c_wait_finished (void)
+Inform Guile that the current thread has finished waiting, and that
+asynchronous interrupts no longer need any special wakeup action; the
+current thread will periodically poll its internal queue instead.
+@end deftypefn
+
+Guile's own interface to @code{sleep}, @code{wait-condition-variable},
+@code{select}, and so on all call the above routines as appropriate.
+
+Finally, note that threads can also be interrupted via POSIX signals.
+@xref{Signals}. As an implementation detail, signal handlers will
+effectively call @code{system-async-mark} in a signal-safe way,
+eventually running the signal handler using the same async mechanism.
+In this way you can temporarily inhibit signal handlers from running
+using the above interfaces.
+
+
+@node Atomics
+@subsection Atomics
+
+When accessing data in parallel from multiple threads, updates made by
+one thread are not generally guaranteed to be visible by another thread.
+It could be that your hardware requires special instructions to be
+emitted to propagate a change from one CPU core to another. Or, it
+could be that your hardware updates values with a sequence of
+instructions, and a parallel thread could see a value that is in the
+process of being updated but not fully updated.
+
+Atomic references solve this problem. Atomics are a standard, primitive
+facility to allow for concurrent access and update of mutable variables
+from multiple threads with guaranteed forward-progress and well-defined
+intermediate states.
+
+Atomic references serve not only as a hardware memory barrier but also
+as a compiler barrier. Normally a compiler might choose to reorder or
+elide certain memory accesses due to optimizations like common
+subexpression elimination. Atomic accesses however will not be
+reordered relative to each other, and normal memory accesses will not be
+reordered across atomic accesses.
+
+As an implementation detail, currently all atomic accesses and updates
+use the sequential consistency memory model from C11. We may relax this
+in the future to the acquire/release semantics, which still issues a
+memory barrier so that non-atomic updates are not reordered across
+atomic accesses or updates.
+
+To use Guile's atomic operations, load the @code{(ice-9 atomic)} module:
+
+@example
+(use-modules (ice-9 atomic))
+@end example
+
+@deffn {Scheme Procedure} make-atomic-box init
+Return an atomic box initialized to value @var{init}.
+@end deffn
+
+@deffn {Scheme Procedure} atomic-box? obj
+Return @code{#t} if @var{obj} is an atomic-box object, else
+return @code{#f}.
+@end deffn
+
+@deffn {Scheme Procedure} atomic-box-ref box
+Fetch the value stored in the atomic box @var{box} and return it.
+@end deffn
+
+@deffn {Scheme Procedure} atomic-box-set! box val
+Store @var{val} into the atomic box @var{box}.
+@end deffn
+
+@deffn {Scheme Procedure} atomic-box-swap! box val
+Store @var{val} into the atomic box @var{box}, and return the value that
+was previously stored in the box.
+@end deffn
+
+@deffn {Scheme Procedure} atomic-box-compare-and-swap! box expected desired
+If the value of the atomic box @var{box} is the same as, @var{expected}
+(in the sense of @code{eq?}), replace the contents of the box with
+@var{desired}. Otherwise does not update the box. Returns the previous
+value of the box in either case, so you can know if the swap worked by
+checking if the return value is @code{eq?} to @var{expected}.
+@end deffn
+
+
@node Mutexes and Condition Variables
@subsection Mutexes and Condition Variables
@cindex mutex
@cindex condition variable
-A mutex is a thread synchronization object, it can be used by threads
-to control access to a shared resource. A mutex can be locked to
-indicate a resource is in use, and other threads can then block on the
-mutex to wait for the resource (or can just test and do something else
-if not available). ``Mutex'' is short for ``mutual exclusion''.
+Mutexes are low-level primitives used to coordinate concurrent access to
+mutable data. Short for ``mutual exclusion'', the name ``mutex''
+indicates that only one thread at a time can acquire access to data that
+is protected by a mutex -- threads are excluded from accessing data at
+the same time. If one thread has locked a mutex, then another thread
+attempting to lock that same mutex will wait until the first thread is
+done.
-There are two types of mutexes in Guile, ``standard'' and
-``recursive''. They're created by @code{make-mutex} and
-@code{make-recursive-mutex} respectively, the operation functions are
-then common to both.
+Mutexes can be used to build robust multi-threaded programs that take
+advantage of multiple cores. However, they provide very low-level
+functionality and are somewhat dangerous; usually you end up wanting to
+acquire multiple mutexes at the same time to perform a multi-object
+access, but this can easily lead to deadlocks if the program is not
+carefully written. For example, if objects A and B are protected by
+associated mutexes M and N, respectively, then to access both of them
+then you need to acquire both mutexes. But what if one thread acquires
+M first and then N, at the same time that another thread acquires N them
+M? You can easily end up in a situation where one is waiting for the
+other.
-Note that for both types of mutex there's no protection against a
-``deadly embrace''. For instance if one thread has locked mutex A and
-is waiting on mutex B, but another thread owns B and is waiting on A,
-then an endless wait will occur (in the current implementation).
-Acquiring requisite mutexes in a fixed order (like always A before B)
-in all threads is one way to avoid such problems.
+There's no easy way around this problem on the language level. A
+function A that uses mutexes does not necessarily compose nicely with a
+function B that uses mutexes. For this reason we suggest using atomic
+variables when you can (@pxref{Atomics}), as they do not have this problem.
+
+Still, if you as a programmer are responsible for a whole system, then
+you can use mutexes as a primitive to provide safe concurrent
+abstractions to your users. (For example, given all locks in a system,
+if you establish an order such that M is consistently acquired before N,
+you can avoid the ``deadly-embrace'' deadlock described above. The
+problem is enumerating all mutexes and establishing this order from a
+system perspective.) Guile gives you the low-level facilities to build
+such systems.
+
+In Guile there are additional considerations beyond the usual ones in
+other programming languages: non-local control flow and asynchronous
+interrupts. What happens if you hold a mutex, but somehow you cause an
+exception to be thrown? There is no one right answer. You might want
+to keep the mutex locked to prevent any other code from ever entering
+that critical section again. Or, your critical section might be fine if
+you unlock the mutex ``on the way out'', via a catch handler or
+@code{dynamic-wind}. @xref{Catch}, and @xref{Dynamic Wind}.
+
+But if you arrange to unlock the mutex when leaving a dynamic extent via
+@code{dynamic-wind}, what to do if control re-enters that dynamic extent
+via a continuation invocation? Surely re-entering the dynamic extent
+without the lock is a bad idea, so there are two options on the table:
+either prevent re-entry via @code{with-continuation-barrier} or similar,
+or reacquire the lock in the entry thunk of a @code{dynamic-wind}.
+
+You might think that because you don't use continuations, that you don't
+have to think about this, and you might be right. If you control the
+whole system, you can reason about continuation use globally. Or, if
+you know all code that can be called in a dynamic extent, and none of
+that code can call continuations, then you don't have to worry about
+re-entry, and you might not have to worry about early exit either.
+
+However, do consider the possibility of asynchronous interrupts
+(@pxref{Asyncs}). If the user interrupts your code interactively, that
+can cause an exception; or your thread might be cancelled, which does
+the same; or the user could be running your code under some pre-emptive
+system that periodically causes lightweight task switching. (Guile does
+not currently include such a system, but it's possible to implement as a
+library.) Probably you also want to defer asynchronous interrupt
+processing while you hold the mutex, and probably that also means that
+you should not hold the mutex for very long.
+
+All of these additional Guile-specific considerations mean that from a
+system perspective, you would do well to avoid these hazards if you can
+by not requiring mutexes. Instead, work with immutable data that can be
+shared between threads without hazards, or use persistent data
+structures with atomic updates based on the atomic variable library
+(@pxref{Atomics}).
+
+There are three types of mutexes in Guile: ``standard'', ``recursive'',
+and ``unowned''.
+
+Calling @code{make-mutex} with no arguments makes a standard mutex. A
+standard mutex can only be locked once. If you try to lock it again
+from the thread that locked it to begin with (the "owner" thread), it
+throws an error. It can only be unlocked from the thread that locked it
+in the first place.
+
+Calling @code{make-mutex} with the symbol @code{recursive} as the
+argument, or calling @code{make-recursive-mutex}, will give you a
+recursive mutex. A recursive mutex can be locked multiple times by its
+owner. It then has to be unlocked the corresponding number of times,
+and like standard mutexes can only be unlocked by the owner thread.
+
+Finally, calling @code{make-mutex} with the symbol
+@code{allow-external-unlock} creates an unowned mutex. An unowned mutex
+is like a standard mutex, except that it can be unlocked by any thread.
+A corollary of this behavior is that a thread's attempt to lock a mutex
+that it already owns will block instead of signalling an error, as it
+could be that some other thread unlocks the mutex, allowing the owner
+thread to proceed. This kind of mutex is a bit strange and is here for
+use by SRFI-18.
+
+The mutex procedures in Guile can operate on all three kinds of mutexes.
+
+To use these facilities, load the @code{(ice-9 threads)} module.
+
+@example
+(use-modules (ice-9 threads))
+@end example
@sp 1
-@deffn {Scheme Procedure} make-mutex flag @dots{}
+@deffn {Scheme Procedure} make-mutex [kind]
@deffnx {C Function} scm_make_mutex ()
-@deffnx {C Function} scm_make_mutex_with_flags (SCM flags)
-Return a new mutex. It is initially unlocked. If @var{flag} @dots{} is
-specified, it must be a list of symbols specifying configuration flags
-for the newly-created mutex. The supported flags are:
-@table @code
-@item unchecked-unlock
-Unless this flag is present, a call to `unlock-mutex' on the returned
-mutex when it is already unlocked will cause an error to be signalled.
-
-@item allow-external-unlock
-Allow the returned mutex to be unlocked by the calling thread even if
-it was originally locked by a different thread.
-
-@item recursive
-The returned mutex will be recursive.
-
-@end table
+@deffnx {C Function} scm_make_mutex_with_kind (SCM kind)
+Return a new mutex. It will be a standard non-recursive mutex, unless
+the @code{recursive} symbol is passed as the optional @var{kind}
+argument, in which case it will be recursive. It's also possible to
+pass @code{unowned} for semantics tailored to SRFI-18's use case; see
+above for details.
@end deffn
@deffn {Scheme Procedure} mutex? obj
@@ -383,40 +559,32 @@ Return @code{#t} if @var{obj} is a mutex; otherwise, return
@deffn {Scheme Procedure} make-recursive-mutex
@deffnx {C Function} scm_make_recursive_mutex ()
Create a new recursive mutex. It is initially unlocked. Calling this
-function is equivalent to calling `make-mutex' and specifying the
-@code{recursive} flag.
+function is equivalent to calling @code{make-mutex} with the
+@code{recursive} kind.
@end deffn
-@deffn {Scheme Procedure} lock-mutex mutex [timeout [owner]]
+@deffn {Scheme Procedure} lock-mutex mutex [timeout]
@deffnx {C Function} scm_lock_mutex (mutex)
-@deffnx {C Function} scm_lock_mutex_timed (mutex, timeout, owner)
-Lock @var{mutex}. If the mutex is already locked, then block and
-return only when @var{mutex} has been acquired.
+@deffnx {C Function} scm_timed_lock_mutex (mutex, timeout)
+Lock @var{mutex} and return @code{#t}. If the mutex is already locked,
+then block and return only when @var{mutex} has been acquired.
When @var{timeout} is given, it specifies a point in time where the
waiting should be aborted. It can be either an integer as returned
by @code{current-time} or a pair as returned by @code{gettimeofday}.
When the waiting is aborted, @code{#f} is returned.
-When @var{owner} is given, it specifies an owner for @var{mutex} other
-than the calling thread. @var{owner} may also be @code{#f},
-indicating that the mutex should be locked but left unowned.
-
-For standard mutexes (@code{make-mutex}), and error is signalled if
-the thread has itself already locked @var{mutex}.
+For standard mutexes (@code{make-mutex}), an error is signalled if the
+thread has itself already locked @var{mutex}.
For a recursive mutex (@code{make-recursive-mutex}), if the thread has
itself already locked @var{mutex}, then a further @code{lock-mutex}
call increments the lock count. An additional @code{unlock-mutex}
will be required to finally release.
-If @var{mutex} was locked by a thread that exited before unlocking it,
-the next attempt to lock @var{mutex} will succeed, but
-@code{abandoned-mutex-error} will be signalled.
-
-When a system async (@pxref{System asyncs}) is activated for a thread
-blocked in @code{lock-mutex}, the wait is interrupted and the async is
-executed. When the async returns, the wait resumes.
+When an asynchronous interrupt (@pxref{Asyncs}) is scheduled for a
+thread blocked in @code{lock-mutex}, Guile will interrupt the wait, run
+the interrupts, and then resume the wait.
@end deffn
@deftypefn {C Function} void scm_dynwind_lock_mutex (SCM mutex)
@@ -426,31 +594,18 @@ context is entered and to be unlocked when it is exited.
@deffn {Scheme Procedure} try-mutex mx
@deffnx {C Function} scm_try_mutex (mx)
-Try to lock @var{mutex} as per @code{lock-mutex}. If @var{mutex} can
-be acquired immediately then this is done and the return is @code{#t}.
-If @var{mutex} is locked by some other thread then nothing is done and
-the return is @code{#f}.
+Try to lock @var{mutex} and return @code{#t} if successful, or @code{#f}
+otherwise. This is like calling @code{lock-mutex} with an expired
+timeout.
@end deffn
-@deffn {Scheme Procedure} unlock-mutex mutex [condvar [timeout]]
+@deffn {Scheme Procedure} unlock-mutex mutex
@deffnx {C Function} scm_unlock_mutex (mutex)
-@deffnx {C Function} scm_unlock_mutex_timed (mutex, condvar, timeout)
-Unlock @var{mutex}. An error is signalled if @var{mutex} is not locked
-and was not created with the @code{unchecked-unlock} flag set, or if
-@var{mutex} is locked by a thread other than the calling thread and was
-not created with the @code{allow-external-unlock} flag set.
+Unlock @var{mutex}. An error is signalled if @var{mutex} is not locked.
-If @var{condvar} is given, it specifies a condition variable upon
-which the calling thread will wait to be signalled before returning.
-(This behavior is very similar to that of
-@code{wait-condition-variable}, except that the mutex is left in an
-unlocked state when the function returns.)
-
-When @var{timeout} is also given and not false, it specifies a point in
-time where the waiting should be aborted. It can be either an integer
-as returned by @code{current-time} or a pair as returned by
-@code{gettimeofday}. When the waiting is aborted, @code{#f} is
-returned. Otherwise the function returns @code{#t}.
+``Standard'' and ``recursive'' mutexes can only be unlocked by the
+thread that locked them; Guile detects this situation and signals an
+error. ``Unowned'' mutexes can be unlocked by any thread.
@end deffn
@deffn {Scheme Procedure} mutex-owner mutex
@@ -497,12 +652,11 @@ as returned by @code{gettimeofday}. When the waiting is aborted,
signalled, @code{#t} is returned. The mutex is re-locked in any case
before @code{wait-condition-variable} returns.
-When a system async is activated for a thread that is blocked in a
-call to @code{wait-condition-variable}, the waiting is interrupted,
-the mutex is locked, and the async is executed. When the async
-returns, the mutex is unlocked again and the waiting is resumed. When
-the thread block while re-acquiring the mutex, execution of asyncs is
-blocked.
+When an async is activated for a thread that is blocked in a call to
+@code{wait-condition-variable}, the waiting is interrupted, the mutex is
+locked, and the async is executed. When the async returns, the mutex is
+unlocked again and the waiting is resumed. When the thread block while
+re-acquiring the mutex, execution of asyncs is blocked.
@end deffn
@deffn {Scheme Procedure} signal-condition-variable condvar
@@ -515,13 +669,8 @@ Wake up one thread that is waiting for @var{condvar}.
Wake up all threads that are waiting for @var{condvar}.
@end deffn
-@sp 1
-The following are higher level operations on mutexes. These are
-available from
-
-@example
-(use-modules (ice-9 threads))
-@end example
+Guile also includes some higher-level abstractions for working with
+mutexes.
@deffn macro with-mutex mutex body1 body2 @dots{}
Lock @var{mutex}, evaluate the body @var{body1} @var{body2} @dots{},
@@ -596,361 +745,21 @@ leaves guile mode while waiting for the condition variable.
@deftypefn {C Function} int scm_std_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Like @code{select} but leaves guile mode while waiting. Also, the
-delivery of a system async causes this function to be interrupted with
-error code @code{EINTR}.
+delivery of an async causes this function to be interrupted with error
+code @code{EINTR}.
@end deftypefn
@deftypefn {C Function} {unsigned int} scm_std_sleep ({unsigned int} seconds)
Like @code{sleep}, but leaves guile mode while sleeping. Also, the
-delivery of a system async causes this function to be interrupted.
+delivery of an async causes this function to be interrupted.
@end deftypefn
@deftypefn {C Function} {unsigned long} scm_std_usleep ({unsigned long} usecs)
Like @code{usleep}, but leaves guile mode while sleeping. Also, the
-delivery of a system async causes this function to be interrupted.
+delivery of an async causes this function to be interrupted.
@end deftypefn
-@node Critical Sections
-@subsection Critical Sections
-
-@deffn {C Macro} SCM_CRITICAL_SECTION_START
-@deffnx {C Macro} SCM_CRITICAL_SECTION_END
-These two macros can be used to delimit a critical section.
-Syntactically, they are both statements and need to be followed
-immediately by a semicolon.
-
-Executing @code{SCM_CRITICAL_SECTION_START} will lock a recursive
-mutex and block the executing of system asyncs. Executing
-@code{SCM_CRITICAL_SECTION_END} will unblock the execution of system
-asyncs and unlock the mutex. Thus, the code that executes between
-these two macros can only be executed in one thread at any one time
-and no system asyncs will run. However, because the mutex is a
-recursive one, the code might still be reentered by the same thread.
-You must either allow for this or avoid it, both by careful coding.
-
-On the other hand, critical sections delimited with these macros can
-be nested since the mutex is recursive.
-
-You must make sure that for each @code{SCM_CRITICAL_SECTION_START},
-the corresponding @code{SCM_CRITICAL_SECTION_END} is always executed.
-This means that no non-local exit (such as a signalled error) might
-happen, for example.
-@end deffn
-
-@deftypefn {C Function} void scm_dynwind_critical_section (SCM mutex)
-Call @code{scm_dynwind_lock_mutex} on @var{mutex} and call
-@code{scm_dynwind_block_asyncs}. When @var{mutex} is false, a recursive
-mutex provided by Guile is used instead.
-
-The effect of a call to @code{scm_dynwind_critical_section} is that
-the current dynwind context (@pxref{Dynamic Wind}) turns into a
-critical section. Because of the locked mutex, no second thread can
-enter it concurrently and because of the blocked asyncs, no system
-async can reenter it from the current thread.
-
-When the current thread reenters the critical section anyway, the kind
-of @var{mutex} determines what happens: When @var{mutex} is recursive,
-the reentry is allowed. When it is a normal mutex, an error is
-signalled.
-@end deftypefn
-
-
-@node Fluids and Dynamic States
-@subsection Fluids and Dynamic States
-
-@cindex fluids
-
-A @emph{fluid} is an object that can store one value per @emph{dynamic
-state}. Each thread has a current dynamic state, and when accessing a
-fluid, this current dynamic state is used to provide the actual value.
-In this way, fluids can be used for thread local storage, but they are
-in fact more flexible: dynamic states are objects of their own and can
-be made current for more than one thread at the same time, or only be
-made current temporarily, for example.
-
-Fluids can also be used to simulate the desirable effects of
-dynamically scoped variables. Dynamically scoped variables are useful
-when you want to set a variable to a value during some dynamic extent
-in the execution of your program and have them revert to their
-original value when the control flow is outside of this dynamic
-extent. See the description of @code{with-fluids} below for details.
-
-New fluids are created with @code{make-fluid} and @code{fluid?} is
-used for testing whether an object is actually a fluid. The values
-stored in a fluid can be accessed with @code{fluid-ref} and
-@code{fluid-set!}.
-
-@deffn {Scheme Procedure} make-fluid [dflt]
-@deffnx {C Function} scm_make_fluid ()
-@deffnx {C Function} scm_make_fluid_with_default (dflt)
-Return a newly created fluid, whose initial value is @var{dflt}, or
-@code{#f} if @var{dflt} is not given.
-Fluids are objects that can hold one
-value per dynamic state. That is, modifications to this value are
-only visible to code that executes with the same dynamic state as
-the modifying code. When a new dynamic state is constructed, it
-inherits the values from its parent. Because each thread normally executes
-with its own dynamic state, you can use fluids for thread local storage.
-@end deffn
-
-@deffn {Scheme Procedure} make-unbound-fluid
-@deffnx {C Function} scm_make_unbound_fluid ()
-Return a new fluid that is initially unbound (instead of being
-implicitly bound to some definite value).
-@end deffn
-
-@deffn {Scheme Procedure} fluid? obj
-@deffnx {C Function} scm_fluid_p (obj)
-Return @code{#t} if @var{obj} is a fluid; otherwise, return
-@code{#f}.
-@end deffn
-
-@deffn {Scheme Procedure} fluid-ref fluid
-@deffnx {C Function} scm_fluid_ref (fluid)
-Return the value associated with @var{fluid} in the current
-dynamic root. If @var{fluid} has not been set, then return
-its default value. Calling @code{fluid-ref} on an unbound fluid produces
-a runtime error.
-@end deffn
-
-@deffn {Scheme Procedure} fluid-set! fluid value
-@deffnx {C Function} scm_fluid_set_x (fluid, value)
-Set the value associated with @var{fluid} in the current dynamic root.
-@end deffn
-
-@deffn {Scheme Procedure} fluid-unset! fluid
-@deffnx {C Function} scm_fluid_unset_x (fluid)
-Disassociate the given fluid from any value, making it unbound.
-@end deffn
-
-@deffn {Scheme Procedure} fluid-bound? fluid
-@deffnx {C Function} scm_fluid_bound_p (fluid)
-Returns @code{#t} if the given fluid is bound to a value, otherwise
-@code{#f}.
-@end deffn
-
-@code{with-fluids*} temporarily changes the values of one or more fluids,
-so that the given procedure and each procedure called by it access the
-given values. After the procedure returns, the old values are restored.
-
-@deffn {Scheme Procedure} with-fluid* fluid value thunk
-@deffnx {C Function} scm_with_fluid (fluid, value, thunk)
-Set @var{fluid} to @var{value} temporarily, and call @var{thunk}.
-@var{thunk} must be a procedure with no argument.
-@end deffn
-
-@deffn {Scheme Procedure} with-fluids* fluids values thunk
-@deffnx {C Function} scm_with_fluids (fluids, values, thunk)
-Set @var{fluids} to @var{values} temporary, and call @var{thunk}.
-@var{fluids} must be a list of fluids and @var{values} must be the
-same number of their values to be applied. Each substitution is done
-in the order given. @var{thunk} must be a procedure with no argument.
-It is called inside a @code{dynamic-wind} and the fluids are
-set/restored when control enter or leaves the established dynamic
-extent.
-@end deffn
-
-@deffn {Scheme Macro} with-fluids ((fluid value) @dots{}) body1 body2 @dots{}
-Execute body @var{body1} @var{body2} @dots{} while each @var{fluid} is
-set to the corresponding @var{value}. Both @var{fluid} and @var{value}
-are evaluated and @var{fluid} must yield a fluid. The body is executed
-inside a @code{dynamic-wind} and the fluids are set/restored when
-control enter or leaves the established dynamic extent.
-@end deffn
-
-@deftypefn {C Function} SCM scm_c_with_fluids (SCM fluids, SCM vals, SCM (*cproc)(void *), void *data)
-@deftypefnx {C Function} SCM scm_c_with_fluid (SCM fluid, SCM val, SCM (*cproc)(void *), void *data)
-The function @code{scm_c_with_fluids} is like @code{scm_with_fluids}
-except that it takes a C function to call instead of a Scheme thunk.
-
-The function @code{scm_c_with_fluid} is similar but only allows one
-fluid to be set instead of a list.
-@end deftypefn
-
-@deftypefn {C Function} void scm_dynwind_fluid (SCM fluid, SCM val)
-This function must be used inside a pair of calls to
-@code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic
-Wind}). During the dynwind context, the fluid @var{fluid} is set to
-@var{val}.
-
-More precisely, the value of the fluid is swapped with a `backup'
-value whenever the dynwind context is entered or left. The backup
-value is initialized with the @var{val} argument.
-@end deftypefn
-
-@deffn {Scheme Procedure} make-dynamic-state [parent]
-@deffnx {C Function} scm_make_dynamic_state (parent)
-Return a copy of the dynamic state object @var{parent}
-or of the current dynamic state when @var{parent} is omitted.
-@end deffn
-
-@deffn {Scheme Procedure} dynamic-state? obj
-@deffnx {C Function} scm_dynamic_state_p (obj)
-Return @code{#t} if @var{obj} is a dynamic state object;
-return @code{#f} otherwise.
-@end deffn
-
-@deftypefn {C Procedure} int scm_is_dynamic_state (SCM obj)
-Return non-zero if @var{obj} is a dynamic state object;
-return zero otherwise.
-@end deftypefn
-
-@deffn {Scheme Procedure} current-dynamic-state
-@deffnx {C Function} scm_current_dynamic_state ()
-Return the current dynamic state object.
-@end deffn
-
-@deffn {Scheme Procedure} set-current-dynamic-state state
-@deffnx {C Function} scm_set_current_dynamic_state (state)
-Set the current dynamic state object to @var{state}
-and return the previous current dynamic state object.
-@end deffn
-
-@deffn {Scheme Procedure} with-dynamic-state state proc
-@deffnx {C Function} scm_with_dynamic_state (state, proc)
-Call @var{proc} while @var{state} is the current dynamic
-state object.
-@end deffn
-
-@deftypefn {C Procedure} void scm_dynwind_current_dynamic_state (SCM state)
-Set the current dynamic state to @var{state} for the current dynwind
-context.
-@end deftypefn
-
-@deftypefn {C Procedure} {void *} scm_c_with_dynamic_state (SCM state, void *(*func)(void *), void *data)
-Like @code{scm_with_dynamic_state}, but call @var{func} with
-@var{data}.
-@end deftypefn
-
-@node Parameters
-@subsection Parameters
-
-@cindex SRFI-39
-@cindex parameter object
-@tindex Parameter
-
-A parameter object is a procedure. Calling it with no arguments returns
-its value. Calling it with one argument sets the value.
-
-@example
-(define my-param (make-parameter 123))
-(my-param) @result{} 123
-(my-param 456)
-(my-param) @result{} 456
-@end example
-
-The @code{parameterize} special form establishes new locations for
-parameters, those new locations having effect within the dynamic scope
-of the @code{parameterize} body. Leaving restores the previous
-locations. Re-entering (through a saved continuation) will again use
-the new locations.
-
-@example
-(parameterize ((my-param 789))
- (my-param)) @result{} 789
-(my-param) @result{} 456
-@end example
-
-Parameters are like dynamically bound variables in other Lisp dialects.
-They allow an application to establish parameter settings (as the name
-suggests) just for the execution of a particular bit of code, restoring
-when done. Examples of such parameters might be case-sensitivity for a
-search, or a prompt for user input.
-
-Global variables are not as good as parameter objects for this sort of
-thing. Changes to them are visible to all threads, but in Guile
-parameter object locations are per-thread, thereby truly limiting the
-effect of @code{parameterize} to just its dynamic execution.
-
-Passing arguments to functions is thread-safe, but that soon becomes
-tedious when there's more than a few or when they need to pass down
-through several layers of calls before reaching the point they should
-affect. And introducing a new setting to existing code is often easier
-with a parameter object than adding arguments.
-
-@deffn {Scheme Procedure} make-parameter init [converter]
-Return a new parameter object, with initial value @var{init}.
-
-If a @var{converter} is given, then a call @code{(@var{converter}
-val)} is made for each value set, its return is the value stored.
-Such a call is made for the @var{init} initial value too.
-
-A @var{converter} allows values to be validated, or put into a
-canonical form. For example,
-
-@example
-(define my-param (make-parameter 123
- (lambda (val)
- (if (not (number? val))
- (error "must be a number"))
- (inexact->exact val))))
-(my-param 0.75)
-(my-param) @result{} 3/4
-@end example
-@end deffn
-
-@deffn {library syntax} parameterize ((param value) @dots{}) body1 body2 @dots{}
-Establish a new dynamic scope with the given @var{param}s bound to new
-locations and set to the given @var{value}s. @var{body1} @var{body2}
-@dots{} is evaluated in that environment. The value returned is that of
-last body form.
-
-Each @var{param} is an expression which is evaluated to get the
-parameter object. Often this will just be the name of a variable
-holding the object, but it can be anything that evaluates to a
-parameter.
-
-The @var{param} expressions and @var{value} expressions are all
-evaluated before establishing the new dynamic bindings, and they're
-evaluated in an unspecified order.
-
-For example,
-
-@example
-(define prompt (make-parameter "Type something: "))
-(define (get-input)
- (display (prompt))
- ...)
-
-(parameterize ((prompt "Type a number: "))
- (get-input)
- ...)
-@end example
-@end deffn
-
-Parameter objects are implemented using fluids (@pxref{Fluids and
-Dynamic States}), so each dynamic state has its own parameter
-locations. That includes the separate locations when outside any
-@code{parameterize} form. When a parameter is created it gets a
-separate initial location in each dynamic state, all initialized to the
-given @var{init} value.
-
-New code should probably just use parameters instead of fluids, because
-the interface is better. But for migrating old code or otherwise
-providing interoperability, Guile provides the @code{fluid->parameter}
-procedure:
-
-@deffn {Scheme Procedure} fluid->parameter fluid [conv]
-Make a parameter that wraps a fluid.
-
-The value of the parameter will be the same as the value of the fluid.
-If the parameter is rebound in some dynamic extent, perhaps via
-@code{parameterize}, the new value will be run through the optional
-@var{conv} procedure, as with any parameter. Note that unlike
-@code{make-parameter}, @var{conv} is not applied to the initial value.
-@end deffn
-
-As alluded to above, because each thread usually has a separate dynamic
-state, each thread has its own locations behind parameter objects, and
-changes in one thread are not visible to any other. When a new dynamic
-state or thread is created, the values of parameters in the originating
-context are copied, into new locations.
-
-@cindex SRFI-39
-Guile's parameters conform to SRFI-39 (@pxref{SRFI-39}).
-
-
@node Futures
@subsection Futures
@cindex futures
@@ -1037,13 +846,6 @@ future has completed. This suspend/resume is achieved by capturing the
calling future's continuation, and later reinstating it (@pxref{Prompts,
delimited continuations}).
-Note that @code{par-map} above is not tail-recursive. This could lead
-to stack overflows when @var{lst} is large compared to
-@code{(current-processor-count)}. To address that, @code{touch} uses
-the suspend mechanism described above to limit the number of nested
-futures executing on the same stack. Thus, the above code should never
-run into stack overflows.
-
@deffn {Scheme Syntax} future exp
Return a future for expression @var{exp}. This is equivalent to:
diff --git a/doc/ref/api-utility.texi b/doc/ref/api-utility.texi
index e2b60e2f9..d82d31a48 100644
--- a/doc/ref/api-utility.texi
+++ b/doc/ref/api-utility.texi
@@ -612,20 +612,6 @@ Return 1 if @var{x} is a Scheme-level hook, 0 otherwise.
@end deftypefn
-@subsubsection Handling Scheme-level hooks from C code
-
-Here is an example of how to handle Scheme-level hooks from C code using
-the above functions.
-
-@example
-if (scm_is_true (scm_hook_p (obj)))
- /* handle Scheme-level hook using C functions */
- scm_reset_hook_x (obj);
-else
- /* do something else (obj is not a hook) */
-@end example
-
-
@node C Hooks
@subsubsection Hooks For C Code.
diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi
index 9743c5357..057ebe817 100644
--- a/doc/ref/compiler.texi
+++ b/doc/ref/compiler.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
+@c Copyright (C) 2008-2016
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -363,7 +363,7 @@ Sets a variable in the current procedure's module.
@end deftp
@deftp {Scheme Variable} src name exp
-@deftpx {External Representation} (define (toplevel @var{name}) @var{exp})
+@deftpx {External Representation} (define @var{name} @var{exp})
Defines a new top-level variable in the current procedure's module.
@end deftp
@@ -513,12 +513,8 @@ Optimization passes performed on Tree-IL currently include:
and calls to primitives to primcalls)
@item Partial evaluation (comprising inlining, copy propagation, and
constant folding)
-@item Common subexpression elimination (CSE)
@end itemize
-In the future, we will move the CSE pass to operate over the lower-level
-CPS language.
-
@node Continuation-Passing Style
@subsection Continuation-Passing Style
@@ -534,6 +530,7 @@ compiler.
* An Introduction to CPS::
* CPS in Guile::
* Building CPS::
+* CPS Soup::
* Compiling CPS::
@end menu
@@ -624,12 +621,57 @@ details manifest, and gives them names.
@node CPS in Guile
@subsubsection CPS in Guile
-Guile's CPS language is composed of @dfn{terms}, @dfn{expressions},
-and @dfn{continuations}.
+@cindex continuation, CPS
+Guile's CPS language is composed of @dfn{continuations}. A continuation
+is a labelled program point. If you are used to traditional compilers,
+think of a continuation as a trivial basic block. A program is a
+``soup'' of continuations, represented as a map from labels to
+continuations.
-A term can either evaluate an expression and pass the resulting values
-to some continuation, or it can declare local continuations and contain
-a sub-term in the scope of those continuations.
+@cindex term, CPS
+@cindex expression, CPS
+Like basic blocks, each continuation belongs to only one function. Some
+continuations are special, like the continuation corresponding to a
+function's entry point, or the continuation that represents the tail of
+a function. Others contain a @dfn{term}. A term contains an
+@dfn{expression}, which evaluates to zero or more values. The term also
+records the continuation to which it will pass its values. Some terms,
+like conditional branches, may continue to one of a number of
+continuations.
+
+Continuation labels are small integers. This makes it easy to sort them
+and to group them into sets. Whenever a term refers to a continuation,
+it does so by name, simply recording the label of the continuation.
+Continuation labels are unique among the set of labels in a program.
+
+Variables are also named by small integers. Variable names are unique
+among the set of variables in a program.
+
+For example, a simple continuation that receives two values and adds
+them together can be matched like this, using the @code{match} form from
+@code{(ice-9 match)}:
+
+@smallexample
+(match cont
+ (($ $kargs (x-name y-name) (x-var y-var)
+ ($ $continue k src ($ $primcall '+ (x-var y-var))))
+ (format #t "Add ~a and ~a and pass the result to label ~a"
+ x-var y-var k)))
+@end smallexample
+
+Here we see the most common kind of continuation, @code{$kargs}, which
+binds some number of values to variables and then evaluates a term.
+
+@deftp {CPS Continuation} $kargs names vars term
+Bind the incoming values to the variables @var{vars}, with original
+names @var{names}, and then evaluate @var{term}.
+@end deftp
+
+The @var{names} of a @code{$kargs} are just for debugging, and will end
+up residualized in the object file for use by the debugger.
+
+The @var{term} in a @code{$kargs} is always a @code{$continue}, which
+evaluates an expression and continues to a continuation.
@deftp {CPS Term} $continue k src exp
Evaluate the expression @var{exp} and pass the resulting values (if any)
@@ -639,44 +681,33 @@ as in @code{source-properties} or is @code{#f} if there is no associated
source.
@end deftp
-@deftp {CPS Term} $letk conts body
-Bind @var{conts}, a list of continuations (@code{$cont} instances), in
-the scope of the sub-term @var{body}. The continuations are mutually
-recursive.
+There are a number of expression kinds. Above you see an example of
+@code{$primcall}.
+
+@deftp {CPS Expression} $primcall name args
+Perform the primitive operation identified by @code{name}, a well-known
+symbol, passing it the arguments @var{args}, and pass all resulting
+values to the continuation. The set of available primitives includes
+all primitives known to Tree-IL and then some more; see the source code
+for details.
@end deftp
-Additionally, the early stages of CPS allow for a set of mutually
-recursive functions to be declared as a term. This @code{$letrec} type
-is like Tree-IL's @code{}. The contification pass will attempt to
-transform the functions declared in a @code{$letrec} into local
-continuations. Any remaining functions are later lowered to @code{$fun}
-expressions.
-
-@deftp {CPS Term} $letrec names syms funs body
-Declare the mutually recursive set of functions denoted by @var{names},
-@var{syms}, and @var{funs} within the sub-term @var{body}. @var{names}
-and @var{syms} are lists of symbols, and @var{funs} is a list of
-@code{$fun} values. @var{syms} are globally unique.
-@end deftp
-
-A higher-order CPS program is a @code{$cont} containing a @code{$kfun}
-(see below), and the @code{$kfun} which contains clauses and those
-clauses contain terms. A first-order CPS program, on the other hand, is
-the result of closure conversion and does not contain nested functions.
-Closure conversion lifts code for all functions up to the top, collects
-their entry continuations as a list of @code{$cont} @code{$kfun}
-instances and binds them in a @code{$program}.
-
-@deftp {CPS Term} $program funs
-A first-order CPS term declaring a recursive scope for first-order
-functions in a compilation unit. @var{funs} is a list of @code{$cont}
-@code{$kfun} instances. The first entry in the list is the entry
-function for the program.
-@end deftp
+@cindex dominate, CPS
+The variables that are used by @code{$primcall}, or indeed by any
+expression, must be defined before the expression is evaluated. An
+equivalent way of saying this is that predecessor @code{$kargs}
+continuation(s) that bind the variables(s) used by the expression must
+@dfn{dominate} the continuation that uses the expression: definitions
+dominate uses. This condition is trivially satisfied in our example
+above, but in general to determine the set of variables that are in
+``scope'' for a given term, you need to do a flow analysis to see what
+continuations dominate a term. The variables that are in scope are
+those variables defined by the continuations that dominate a term.
Here is an inventory of the kinds of expressions in Guile's CPS
-language. Recall that all expressions are wrapped in a @code{$continue}
-term which specifies their continuation.
+language, besides @code{$primcall} which has already been described.
+Recall that all expressions are wrapped in a @code{$continue} term which
+specifies their continuation.
@deftp {CPS Expression} $const val
Continue with the constant value @var{val}.
@@ -687,47 +718,11 @@ Continue with the procedure that implements the primitive operation
named by @var{name}.
@end deftp
-@deftp {CPS Expression} $fun free body
-Continue with a procedure. @var{free} is a list of free variables
-accessed by the procedure. Early CPS uses an empty list for @var{free};
-only after closure conversion is it correctly populated. Finally,
-@var{body} is the @code{$kfun} @code{$cont} of the procedure entry.
-@end deftp
-
-@code{$fun} is part of higher-level CPS. After closure conversion,
-@code{$fun} instances are given a concrete representation. By default,
-a closure is represented as an object built by a @code{$closure}
-expression
-
-@deftp {CPS Expression} $closure label nfree
-Build a closure that joins the code at the continuation named
-@var{label} with space for @var{nfree} free variables. The variables
-will be initialized later via @code{free-variable-set!} primcalls.
-@end deftp
-
-If the closure can be proven to never escape its scope then other
-lighter-weight representations can be chosen.
-
@deftp {CPS Expression} $call proc args
-@deftpx {CPS Expression} $callk label proc args
Call @var{proc} with the arguments @var{args}, and pass all values to
the continuation. @var{proc} and the elements of the @var{args} list
should all be variable names. The continuation identified by the term's
@var{k} should be a @code{$kreceive} or a @code{$ktail} instance.
-
-@code{$callk} is for the case where the call target is known to be in
-the same compilation unit. @var{label} should be some continuation
-label, though it need not be in scope. In this case the @var{proc} is
-simply an additional argument, since it is not used to determine the
-call target at run-time.
-@end deftp
-
-@deftp {CPS Expression} $primcall name args
-Perform the primitive operation identified by @code{name}, a well-known
-symbol, passing it the arguments @var{args}, and pass all resulting
-values to the continuation. The set of available primitives includes
-all primitives known to Tree-IL and then some more; see the source code
-for details.
@end deftp
@deftp {CPS Expression} $values args
@@ -736,7 +731,8 @@ Pass the values named by the list @var{args} to the continuation.
@deftp {CPS Expression} $branch kt exp
Evaluate the branching expression @var{exp}, and continue to @var{kt}
-with zero values if the test evaluates to true. Otherwise, in the false
+with zero values if the test evaluates to true. Otherwise continue to
+the continuation named in the outer @code{$continue} term.
Only certain expressions are valid in a @var{$branch}. Compiling a
@code{$branch} avoids allocating space for the test variable, so the
@@ -744,9 +740,9 @@ expression should be evaluatable without temporary values. In practice
this condition is true for @code{$primcall}s to @code{null?}, @code{=},
and similar primitives that have corresponding @code{br-if-@var{foo}} VM
operations; see the source code for full details. When in doubt, bind
-the test expression to a variable, and reference the variable in the
-@code{$branch} expression. The optimizer should inline the reference if
-possible.
+the test expression to a variable, and branch on a @code{$values}
+expression that references that variable. The optimizer should inline
+the reference if possible.
@end deftp
@deftp {CPS Expression} $prompt escape? tag handler
@@ -758,30 +754,73 @@ the continuation labelled @var{handler}, which should be a
@code{pop-prompt} primcalls.
@end deftp
-The remaining element of the CPS language in Guile is the continuation.
-In CPS, all continuations have unique labels. Since this aspect is
-common to all continuation types, all continuations are contained in a
-@code{$cont} instance:
+@cindex higher-order CPS
+@cindex CPS, higher-order
+@cindex first-order CPS
+@cindex CPS, first-order
+There are two sub-languages of CPS, @dfn{higher-order CPS} and
+@dfn{first-order CPS}. The difference is that in higher-order CPS,
+there are @code{$fun} and @code{$rec} expressions that bind functions or
+mutually-recursive functions in the implicit scope of their use sites.
+Guile transforms higher-order CPS into first-order CPS by @dfn{closure
+conversion}, which chooses representations for all closures and which
+arranges to access free variables through the implicit closure parameter
+that is passed to every function call.
-@deftp {CPS Continuation Wrapper} $cont k cont
-Declare a continuation labelled @var{k}. All references to the
-continuation will use this label.
+@deftp {CPS Expression} $fun body
+Continue with a procedure. @var{body} names the entry point of the
+function, which should be a @code{$kfun}. This expression kind is only
+valid in higher-order CPS, which is the CPS language before closure
+conversion.
@end deftp
-The most common kind of continuation binds some number of values, and
-then evaluates a sub-term. @code{$kargs} is this kind of simple
-@code{lambda}.
-
-@deftp {CPS Continuation} $kargs names syms body
-Bind the incoming values to the variables @var{syms}, with original
-names @var{names}, and then evaluate the sub-term @var{body}.
+@deftp {CPS Expression} $rec names vars funs
+Continue with a set of mutually recursive procedures denoted by
+@var{names}, @var{vars}, and @var{funs}. @var{names} is a list of
+symbols, @var{vars} is a list of variable names (unique integers), and
+@var{funs} is a list of @code{$fun} values. Note that the @code{$kargs}
+continuation should also define @var{names}/@var{vars} bindings.
@end deftp
-Variable names (the names in the @var{syms} of a @code{$kargs}) should
-be unique among all other variable names. To bind a value to a variable
-and then evaluate some term, you would continue with the value to a
-@code{$kargs} that declares one variable. The bound value would then be
-available for use within the body of the @code{$kargs}.
+The contification pass will attempt to transform the functions declared
+in a @code{$rec} into local continuations. Any remaining @code{$fun}
+instances are later removed by the closure conversion pass. By default,
+a closure is represented as an object built by a @code{$closure}
+expression.
+
+@deftp {CPS Expression} $closure label nfree
+Build a closure that joins the code at the continuation named
+@var{label} with space for @var{nfree} free variables. The variables
+will be initialized later via @code{free-set!} primcalls. This
+expression kind is part of first-order CPS.
+@end deftp
+
+If the closure can be proven to never escape its scope then other
+lighter-weight representations can be chosen. Additionally, if all call
+sites are known, closure conversion will hard-wire the calls by lowering
+@code{$call} to @code{$callk}.
+
+@deftp {CPS Expression} $callk label proc args
+Like @code{$call}, but for the case where the call target is known to be
+in the same compilation unit. @var{label} should denote some
+@code{$kfun} continuation in the program. In this case the @var{proc}
+is simply an additional argument, since it is not used to determine the
+call target at run-time.
+@end deftp
+
+At this point we have described terms, expressions, and the most common
+kind of continuation, @code{$kargs}. @code{$kargs} is used when the
+predecessors of the continuation can be instructed to pass the values
+where the continuation wants them. For example, if a @code{$kargs}
+continuation @var{k} binds a variable @var{v}, and the compiler decides
+to allocate @var{v} to slot 6, all predecessors of @var{k} should put
+the value for @var{v} in slot 6 before jumping to @var{k}. One
+situation in which this isn't possible is receiving values from function
+calls. Guile has a calling convention for functions which currently
+places return values on the stack. A continuation of a call must check
+that the number of values returned from a function matches the expected
+number of values, and then must shuffle or collect those values to named
+variables. @code{$kreceive} denotes this kind of continuation.
@deftp {CPS Continuation} $kreceive arity k
Receive values on the stack. Parse them according to @var{arity}, and
@@ -806,18 +845,18 @@ Note that all of these names with the exception of the @var{var}s in the
@var{kw} list are source names, not unique variable names.
@end deftp
-Additionally, there are three specific kinds of continuations that can
-only be declared at function entries.
+Additionally, there are three specific kinds of continuations that are
+only used in function entries.
@deftp {CPS Continuation} $kfun src meta self tail clauses
Declare a function entry. @var{src} is the source information for the
procedure declaration, and @var{meta} is the metadata alist as described
above in Tree-IL's @code{}. @var{self} is a variable bound to
the procedure being called, and which may be used for self-references.
-@var{tail} declares the @code{$cont} wrapping the @code{$ktail} for this
-function, corresponding to the function's tail continuation.
-@var{clause} is the first @code{$kclause} @code{$cont} instance for the
-first @code{case-lambda} clause in the function, or otherwise @code{#f}.
+@var{tail} is the label of the @code{$ktail} for this function,
+corresponding to the function's tail continuation. @var{clause} is the
+label of the first @code{$kclause} for the first @code{case-lambda}
+clause in the function, or otherwise @code{#f}.
@end deftp
@deftp {CPS Continuation} $ktail
@@ -826,10 +865,10 @@ A tail continuation.
@deftp {CPS Continuation} $kclause arity cont alternate
A clause of a function with a given arity. Applications of a function
-with a compatible set of actual arguments will continue to @var{cont}, a
-@code{$kargs} @code{$cont} instance representing the clause body. If
-the arguments are incompatible, control proceeds to @var{alternate},
-which is a @code{$kclause} @code{$cont} for the next clause, or
+with a compatible set of actual arguments will continue to the
+continuation labelled @var{cont}, a @code{$kargs} instance representing
+the clause body. If the arguments are incompatible, control proceeds to
+@var{alternate}, which is a @code{$kclause} for the next clause, or
@code{#f} if there is no next clause.
@end deftp
@@ -842,41 +881,41 @@ constructors or accessors, or instead of S-expression matching.
Deconstruction and matching is handled adequately by the @code{match}
form from @code{(ice-9 match)}. @xref{Pattern Matching}. Construction
-is handled by a set of mutually recursive builder macros:
-@code{build-cps-term}, @code{build-cps-cont}, and @code{build-cps-exp}.
+is handled by a set of mutually builder macros:
+@code{build-term}, @code{build-cont}, and @code{build-exp}.
-In the following interface definitions, consider variables containing
-@code{cont} to be recursively build by @code{build-cps-cont}, and
-likewise for @code{term} and @code{exp}. Consider any other name to be
-evaluated as a Scheme expression. Many of these forms recognize
-@code{unquote} in some contexts, to splice in a previously-built value;
-see the specifications below for full details.
+In the following interface definitions, consider @code{term} and
+@code{exp} to be built by @code{build-term} or @code{build-exp},
+respectively. Consider any other name to be evaluated as a Scheme
+expression. Many of these forms recognize @code{unquote} in some
+contexts, to splice in a previously-built value; see the specifications
+below for full details.
-@deffn {Scheme Syntax} build-cps-term ,val
-@deffnx {Scheme Syntax} build-cps-term ($letk (cont ...) term)
-@deffnx {Scheme Syntax} build-cps-term ($letrec names syms funs term)
-@deffnx {Scheme Syntax} build-cps-term ($continue k src exp)
-@deffnx {Scheme Syntax} build-cps-term ($program conts)
-@deffnx {Scheme Syntax} build-cps-exp ,val
-@deffnx {Scheme Syntax} build-cps-exp ($const val)
-@deffnx {Scheme Syntax} build-cps-exp ($prim name)
-@deffnx {Scheme Syntax} build-cps-exp ($fun src meta free body)
-@deffnx {Scheme Syntax} build-cps-exp ($call proc (arg ...))
-@deffnx {Scheme Syntax} build-cps-exp ($call proc args)
-@deffnx {Scheme Syntax} build-cps-exp ($primcall name (arg ...))
-@deffnx {Scheme Syntax} build-cps-exp ($primcall name args)
-@deffnx {Scheme Syntax} build-cps-exp ($values (arg ...))
-@deffnx {Scheme Syntax} build-cps-exp ($values args)
-@deffnx {Scheme Syntax} build-cps-exp ($prompt escape? tag handler)
-@deffnx {Scheme Syntax} build-cps-cont ,val
-@deffnx {Scheme Syntax} build-cps-cont (k ($kargs (name ...) (sym ...) term))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kargs names syms term))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kif kt kf))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kreceive req rest kargs))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kentry self tail-cont ,clauses))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kentry self tail-cont (cont ...)))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kclause ,arity cont))
-@deffnx {Scheme Syntax} build-cps-cont (k ($kclause (req opt rest kw aok?) cont))
+@deffn {Scheme Syntax} build-term ,val
+@deffnx {Scheme Syntax} build-term ($continue k src exp)
+@deffnx {Scheme Syntax} build-exp ,val
+@deffnx {Scheme Syntax} build-exp ($const val)
+@deffnx {Scheme Syntax} build-exp ($prim name)
+@deffnx {Scheme Syntax} build-exp ($branch kt exp)
+@deffnx {Scheme Syntax} build-exp ($fun kentry)
+@deffnx {Scheme Syntax} build-exp ($rec names syms funs)
+@deffnx {Scheme Syntax} build-exp ($closure k nfree)
+@deffnx {Scheme Syntax} build-exp ($call proc (arg ...))
+@deffnx {Scheme Syntax} build-exp ($call proc args)
+@deffnx {Scheme Syntax} build-exp ($callk k proc (arg ...))
+@deffnx {Scheme Syntax} build-exp ($callk k proc args)
+@deffnx {Scheme Syntax} build-exp ($primcall name (arg ...))
+@deffnx {Scheme Syntax} build-exp ($primcall name args)
+@deffnx {Scheme Syntax} build-exp ($values (arg ...))
+@deffnx {Scheme Syntax} build-exp ($values args)
+@deffnx {Scheme Syntax} build-exp ($prompt escape? tag handler)
+@deffnx {Scheme Syntax} build-cont ,val
+@deffnx {Scheme Syntax} build-cont ($kargs (name ...) (sym ...) term)
+@deffnx {Scheme Syntax} build-cont ($kargs names syms term)
+@deffnx {Scheme Syntax} build-cont ($kreceive req rest kargs)
+@deffnx {Scheme Syntax} build-cont ($kfun src meta self ktail kclause)
+@deffnx {Scheme Syntax} build-cont ($kclause ,arity kbody kalt)
+@deffnx {Scheme Syntax} build-cont ($kclause (req opt rest kw aok?) kbody)
Construct a CPS term, expression, or continuation.
@end deffn
@@ -886,19 +925,187 @@ There are a few more miscellaneous interfaces as well.
A procedural constructor for @code{$arity} objects.
@end deffn
-@deffn {Scheme Syntax} let-gensyms (sym ...) body ...
-Bind @var{sym...} to fresh names, and evaluate @var{body...}.
-@end deffn
-
-@deffn {Scheme Syntax} rewrite-cps-term val (pat term) ...
-@deffnx {Scheme Syntax} rewrite-cps-exp val (pat exp) ...
-@deffnx {Scheme Syntax} rewrite-cps-cont val (pat cont) ...
+@deffn {Scheme Syntax} rewrite-term val (pat term) ...
+@deffnx {Scheme Syntax} rewrite-exp val (pat exp) ...
+@deffnx {Scheme Syntax} rewrite-cont val (pat cont) ...
Match @var{val} against the series of patterns @var{pat...}, using
@code{match}. The body of the matching clause should be a template in
-the syntax of @code{build-cps-term}, @code{build-cps-exp}, or
-@code{build-cps-cont}, respectively.
+the syntax of @code{build-term}, @code{build-exp}, or @code{build-cont},
+respectively.
@end deffn
+@node CPS Soup
+@subsubsection CPS Soup
+
+We describe programs in Guile's CPS language as being a kind of ``soup''
+because all continuations in the program are mixed into the same
+``pot'', so to speak, without explicit markers as to what function or
+scope a continuation is in. A program in CPS is a map from continuation
+labels to continuation values. As discussed in the introduction, a
+continuation label is an integer. No label may be negative.
+
+As a matter of convention, label 0 should map to the @code{$kfun}
+continuation of the entry to the program, which should be a function of
+no arguments. The body of a function consists of the labelled
+continuations that are reachable from the function entry. A program can
+refer to other functions, either via @code{$fun} and @code{$rec} in
+higher-order CPS, or via @code{$closure} and @code{$callk} in
+first-order CPS. The program logically contains all continuations of
+all functions reachable from the entry function. A compiler pass may
+leave unreachable continuations in a program; subsequent compiler passes
+should ensure that their transformations and analyses only take
+reachable continuations into account. It's OK though if transformation
+runs over all continuations if including the unreachable continuations
+has no effect on the transformations on the live continuations.
+
+@cindex intmap
+The ``soup'' itself is implemented as an @dfn{intmap}, a functional
+array-mapped trie specialized for integer keys. Intmaps associate
+integers with values of any kind. Currently intmaps are a private data
+structure only used by the CPS phase of the compiler. To work with
+intmaps, load the @code{(language cps intmap)} module:
+
+@example
+(use-modules (language cps intmap))
+@end example
+
+Intmaps are functional data structures, so there is no constructor as
+such: one can simply start with the empty intmap and add entries to it.
+
+@example
+(intmap? empty-intmap) @result{} #t
+(define x (intmap-add empty-intmap 42 "hi"))
+(intmap? x) @result{} #t
+(intmap-ref x 42) @result{} "hi"
+(intmap-ref x 43) @result{} @i{error: 43 not present}
+(intmap-ref x 43 (lambda (k) "yo!")) @result{} "yo"
+(intmap-add x 42 "hej") @result{} @i{error: 42 already present}
+@end example
+
+@code{intmap-ref} and @code{intmap-add} are the core of the intmap
+interface. There is also @code{intmap-replace}, which replaces the
+value associated with a given key, requiring that the key was present
+already, and @code{intmap-remove}, which removes a key from an intmap.
+
+Intmaps have a tree-like structure that is well-suited to set operations
+such as union and intersection, so there is are also the binary
+@code{intmap-union} and @code{intmap-intersect} procedures. If the
+result is equivalent to either argument, that argument is returned
+as-is; in that way, one can detect whether the set operation produced a
+new result simply by checking with @code{eq?}. This makes intmaps
+useful when computing fixed points.
+
+If a key is present in both intmaps and the associated values are not
+the same in the sense of @code{eq?}, the resulting value is determined
+by a ``meet'' procedure, which is the optional last argument to
+@code{intmap-union}, @code{intmap-intersect}, and also to
+@code{intmap-add}, @code{intmap-replace}, and similar functions. The
+meet procedure will be called with the two values and should return the
+intersected or unioned value in some domain-specific way. If no meet
+procedure is given, the default meet procedure will raise an error.
+
+To traverse over the set of values in an intmap, there are the
+@code{intmap-next} and @code{intmap-prev} procedures. For example, if
+intmap @var{x} has one entry mapping 42 to some value, we would have:
+
+@example
+(intmap-next x) @result{} 42
+(intmap-next x 0) @result{} 42
+(intmap-next x 42) @result{} 42
+(intmap-next x 43) @result{} #f
+(intmap-prev x) @result{} 42
+(intmap-prev x 42) @result{} 42
+(intmap-prev x 41) @result{} #f
+@end example
+
+There is also the @code{intmap-fold} procedure, which folds over keys
+and values in the intmap from lowest to highest value, and
+@code{intmap-fold-right} which does so in the opposite direction. These
+procedures may take up to 3 seed values. The number of values that the
+fold procedure returns is the number of seed values.
+
+@example
+(define q (intmap-add (intmap-add empty-intmap 1 2) 3 4))
+(intmap-fold acons q '()) @result{} ((3 . 4) (1 . 2))
+(intmap-fold-right acons q '()) @result{} ((1 . 2) (3 . 4))
+@end example
+
+When an entry in an intmap is updated (removed, added, or changed), a
+new intmap is created that shares structure with the original intmap.
+This operation ensures that the result of existing computations is not
+affected by future computations: no mutation is ever visible to user
+code. This is a great property in a compiler data structure, as it lets
+us hold a copy of a program before a transformation and use it while we
+build a post-transformation program. Updating an intmap is O(log
+@var{n}) in the size of the intmap.
+
+However, the O(log @var{n}) allocation costs are sometimes too much,
+especially in cases when we know that we can just update the intmap in
+place. As an example, say we have an intmap mapping the integers 1 to
+100 to the integers 42 to 141. Let's say that we want to transform this
+map by adding 1 to each value. There is already an efficient
+@code{intmap-map} procedure in the @code{(language cps utils}) module,
+but if we didn't know about that we might do:
+
+@example
+(define (intmap-increment map)
+ (let lp ((k 0) (map map))
+ (let ((k (intmap-next map k)))
+ (if k
+ (let ((v (intmap-ref map k)))
+ (lp (1+ k) (intmap-replace map k (1+ v))))
+ map))))
+@end example
+
+@cindex intmap, transient
+@cindex transient intmaps
+Observe that the intermediate values created by @code{intmap-replace}
+are completely invisible to the program -- only the last result of
+@code{intmap-replace} value is needed. The rest might as well share
+state with the last one, and we could update in place. Guile allows
+this kind of interface via @dfn{transient intmaps}, inspired by
+Clojure's transient interface (@uref{http://clojure.org/transients}).
+
+The in-place @code{intmap-add!} and @code{intmap-replace!} procedures
+return transient intmaps. If one of these in-place procedures is called
+on a normal persistent intmap, a new transient intmap is created. This
+is an O(1) operation. In all other respects the interface is like their
+persistent counterparts, @code{intmap-add} and @code{intmap-replace}.
+If an in-place procedure is called on a transient intmap, the intmap is
+mutated in-place and the same value is returned.
+
+If a persistent operation like @code{intmap-add} is called on a
+transient intmap, the transient's mutable substructure is then marked as
+persistent, and @code{intmap-add} then runs on a new persistent intmap
+sharing structure but not state with the original transient. Mutating a
+transient will cause enough copying to ensure that it can make its
+change, but if part of its substructure is already ``owned'' by it, no
+more copying is needed.
+
+We can use transients to make @code{intmap-increment} more efficient.
+The two changed elements have been marked @strong{like this}.
+
+@example
+(define (intmap-increment map)
+ (let lp ((k 0) (map map))
+ (let ((k (intmap-next map k)))
+ (if k
+ (let ((v (intmap-ref map k)))
+ (lp (1+ k) (@strong{intmap-replace!} map k (1+ v))))
+ (@strong{persistent-intmap} map)))))
+@end example
+
+Be sure to tag the result as persistent using the
+@code{persistent-intmap} procedure to prevent the mutability from
+leaking to other parts of the program. For added paranoia, you could
+call @code{persistent-intmap} on the incoming map, to ensure that if it
+were already transient, that the mutations in the body of
+@code{intmap-increment} wouldn't affect the incoming value.
+
+In summary, programs in CPS are intmaps whose values are continuations.
+See the source code of @code{(language cps utils)} for a number of
+useful facilities for working with CPS values.
+
@node Compiling CPS
@subsubsection Compiling CPS
@@ -915,16 +1122,18 @@ variables (in Tree-IL, locals that are @code{}) are
converted to being boxed values on the heap. @xref{Variables and the
VM}.
-After CPS conversion, Guile runs some optimization passes. The major
-optimization performed on CPS is contification, in which functions that
-are always called with the same continuation are incorporated directly
-into a function's body. This opens up space for more optimizations, and
-turns procedure calls into @code{goto}. It can also make loops out of
-recursive function nests.
+After CPS conversion, Guile runs some optimization passes over the CPS.
+Most optimization in Guile is done on the CPS language. The one major
+exception is partial evaluation, which for historic reasons is done on
+Tree-IL.
-At the time of this writing (2014), most high-level optimization in
-Guile is done on Tree-IL. We would like to rewrite many of these passes
-to operate on CPS instead, as it is easier to reason about CPS.
+The major optimization performed on CPS is contification, in which
+functions that are always called with the same continuation are
+incorporated directly into a function's body. This opens up space for
+more optimizations, and turns procedure calls into @code{goto}. It can
+also make loops out of recursive function nests. Guile also does dead
+code elimination, common subexpression elimination, loop peeling and
+invariant code motion, and range and type inference.
The rest of the optimization passes are really cleanups and
canonicalizations. CPS spans the gap between high-level languages and
diff --git a/doc/ref/data-rep.texi b/doc/ref/data-rep.texi
index d0a76e9be..bb7f74afe 100644
--- a/doc/ref/data-rep.texi
+++ b/doc/ref/data-rep.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2010
+@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2010, 2015
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -339,7 +339,7 @@ actually garbage, and should be freed. In practice, this is not a
problem. The alternative, an explicitly maintained list of local
variable addresses, is effectively much less reliable, due to programmer
error. Interested readers should see the BDW-GC web page at
-@uref{http://www.hpl.hp.com/personal/Hans_Boehm/gc}, for more
+@uref{http://www.hboehm.info/gc/}, for more
information.
diff --git a/doc/ref/guile-invoke.texi b/doc/ref/guile-invoke.texi
index bc33ce080..a18984f31 100644
--- a/doc/ref/guile-invoke.texi
+++ b/doc/ref/guile-invoke.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2010, 2011, 2013, 2014
-@c Free Software Foundation, Inc.
+@c Copyright (C) 1996, 1997, 2000-2005, 2010, 2011, 2013, 2014,
+@c 2016 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Invoking Guile
@@ -102,14 +102,10 @@ that is defined in the script. It can also be of the form @code{(@@
@var{module-name} @var{symbol})}, and in that case, the symbol is
looked up in the module named @var{module-name}.
-For compatibility with some versions of Guile 1.4, you can also use the
-form @code{(symbol ...)} (that is, a list of only symbols that doesn't
-start with @code{@@}), which is equivalent to @code{(@@ (symbol ...)
-main)}, or @code{(symbol ...) symbol} (that is, a list of only symbols
-followed by a symbol), which is equivalent to @code{(@@ (symbol ...)
-symbol)}. We recommend to use the equivalent forms directly since they
-correspond to the @code{(@@ ...)} read syntax that can be used in
-normal code. See @ref{Using Guile Modules} and @ref{Scripting
+As a shorthand you can use the form @code{(symbol ...)}, that is, a list
+of only symbols that doesn't start with @code{@@}. It is equivalent to
+@code{(@@ @var{module-name} main)}, where @var{module-name} is
+@code{(symbol ...)} form. @xref{Using Guile Modules} and @ref{Scripting
Examples}.
@item -ds
@@ -176,7 +172,7 @@ the @file{.guile} file. @xref{Init File}.
While this program runs, listen on a local port or a path for REPL
clients. If @var{p} starts with a number, it is assumed to be a local
port on which to listen. If it starts with a forward slash, it is
-assumed to be a path to a UNIX domain socket on which to listen.
+assumed to be the file name of a UNIX domain socket on which to listen.
If @var{p} is not given, the default is local port 37146. If you look
at it upside down, it almost spells ``Guile''. If you have netcat
@@ -184,12 +180,22 @@ installed, you should be able to @kbd{nc localhost 37146} and get a
Guile prompt. Alternately you can fire up Emacs and connect to the
process; see @ref{Using Guile in Emacs} for more details.
-Note that opening a port allows anyone who can connect to that port---in
-the TCP case, any local user---to do anything Guile can do, as the user
+@quotation Note
+Opening a port allows anyone who can connect to that port to do anything
+Guile can do, as the user
that the Guile process is running as. Do not use @option{--listen} on
multi-user machines. Of course, if you do not pass @option{--listen} to
Guile, no port will be opened.
+Guile protects against the
+@uref{https://en.wikipedia.org/wiki/Inter-protocol_exploitation,
+@dfn{HTTP inter-protocol exploitation attack}}, a scenario whereby an
+attacker can, @i{via} an HTML page, cause a web browser to send data to
+TCP servers listening on a loopback interface or private network.
+Nevertheless, you are advised to use UNIX domain sockets, as in
+@code{--listen=/some/local/file}, whenever possible.
+@end quotation
+
That said, @option{--listen} is great for interactive debugging and
development.
diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi
index 5f21188fa..4bc3b74d8 100644
--- a/doc/ref/guile.texi
+++ b/doc/ref/guile.texi
@@ -14,7 +14,7 @@
This manual documents Guile version @value{VERSION}.
Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2009,
-2010, 2011, 2012, 2013, 2014 Free Software Foundation.
+2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -297,8 +297,7 @@ available through both Scheme and C interfaces.
* The SCM Type:: The fundamental data type for C code.
* Initialization:: Initializing Guile.
* Snarfing Macros:: Macros for snarfing initialization actions.
-* Simple Data Types:: Numbers, strings, booleans and so on.
-* Compound Data Types:: Data types for holding other data.
+* Data Types:: Representing values in Guile.
* Foreign Objects:: Defining new data types in C.
* Smobs:: Use foreign objects instead.
* Procedures:: Procedures.
@@ -328,7 +327,6 @@ available through both Scheme and C interfaces.
@include api-init.texi
@include api-snarf.texi
@include api-data.texi
-@include api-compound.texi
@include api-foreign-objects.texi
@include api-smobs.texi
@include api-procedures.texi
diff --git a/doc/ref/libguile-concepts.texi b/doc/ref/libguile-concepts.texi
index 9e2eb7503..34010eebf 100644
--- a/doc/ref/libguile-concepts.texi
+++ b/doc/ref/libguile-concepts.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2010,
-@c 2011, 2013, 2014 Free Software Foundation, Inc.
+@c Copyright (C) 1996-1997, 2000-2005, 2010-2011, 2013-2016
+@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node General Libguile Concepts
@@ -197,28 +197,44 @@ sections, function arguments or local variables on the C and Scheme
stacks, and values in machine registers. Other references to @code{SCM}
objects, such as those in other random data structures in the C heap
that contain fields of type @code{SCM}, can be made visible to the
-garbage collector by calling the functions @code{scm_gc_protect} or
+garbage collector by calling the functions @code{scm_gc_protect_object} or
@code{scm_permanent_object}. Collectively, these values form the ``root
set'' of garbage collection; any value on the heap that is referenced
directly or indirectly by a member of the root set is preserved, and all
other objects are eligible for reclamation.
-The Scheme stack and heap are scanned precisely; that is to say, Guile
-knows about all inter-object pointers on the Scheme stack and heap.
-This is not the case, unfortunately, for pointers on the C stack and
-static data segment. For this reason we have to scan the C stack and
-static data segment @dfn{conservatively}; any value that looks like a
-pointer to a GC-managed object is treated as such, whether it actually
-is a reference or not. Thus, scanning the C stack and static data
-segment is guaranteed to find all actual references, but it might also
-find words that only accidentally look like references. These ``false
-positives'' might keep @code{SCM} objects alive that would otherwise be
-considered dead. While this might waste memory, keeping an object
-around longer than it strictly needs to is harmless. This is why this
-technique is called ``conservative garbage collection''. In practice,
-the wasted memory seems to be no problem, as the static C root set is
-almost always finite and small, given that the Scheme stack is separate
-from the C stack.
+In Guile, garbage collection has two logical phases: the @dfn{mark
+phase}, in which the collector discovers the set of all live objects,
+and the @dfn{sweep phase}, in which the collector reclaims the resources
+associated with dead objects. The mark phase pauses the program and
+traces all @code{SCM} object references, starting with the root set.
+The sweep phase actually runs concurrently with the main program,
+incrementally reclaiming memory as needed by allocation.
+
+In the mark phase, the garbage collector traces the Scheme stack and
+heap @dfn{precisely}. Because the Scheme stack and heap are managed by
+Guile, Guile can know precisely where in those data structures it might
+find references to other heap objects. This is not the case,
+unfortunately, for pointers on the C stack and static data segment.
+Instead of requiring the user to inform Guile about all variables in C
+that might point to heap objects, Guile traces the C stack and static
+data segment @dfn{conservatively}. That is to say, Guile just treats
+every word on the C stack and every C global variable as a potential
+reference in to the Scheme heap@footnote{Note that Guile does not scan
+the C heap for references, so a reference to a @code{SCM} object from a
+memory segment allocated with @code{malloc} will have to use some other
+means to keep the @code{SCM} object alive. @xref{Garbage Collection
+Functions}.}. Any value that looks like a pointer to a GC-managed
+object is treated as such, whether it actually is a reference or not.
+Thus, scanning the C stack and static data segment is guaranteed to find
+all actual references, but it might also find words that only
+accidentally look like references. These ``false positives'' might keep
+@code{SCM} objects alive that would otherwise be considered dead. While
+this might waste memory, keeping an object around longer than it
+strictly needs to is harmless. This is why this technique is called
+``conservative garbage collection''. In practice, the wasted memory
+seems to be no problem, as the static C root set is almost always finite
+and small, given that the Scheme stack is separate from the C stack.
The stack of every thread is scanned in this way and the registers of
the CPU and all other memory locations where local variables or function
@@ -402,7 +418,7 @@ do such a thing on its own.
If you do not want to allow the running of asynchronous signal handlers,
you can block them temporarily with @code{scm_dynwind_block_asyncs}, for
-example. See @xref{System asyncs}.
+example. @xref{Asyncs}.
Since signal handling in Guile relies on safe points, you need to make
sure that your functions do offer enough of them. Normally, calling
diff --git a/doc/ref/libguile-foreign-objects.texi b/doc/ref/libguile-foreign-objects.texi
index 11941d566..29e1f8619 100644
--- a/doc/ref/libguile-foreign-objects.texi
+++ b/doc/ref/libguile-foreign-objects.texi
@@ -279,10 +279,10 @@ Note that the finalizer may be invoked in ways and at times you might
not expect. In particular, if the user's Guile is built with support
for threads, the finalizer may be called from any thread that is running
Guile. In Guile 2.0, finalizers are invoked via ``asyncs'', which
-interleaves them with running Scheme code; @pxref{System asyncs}. In
-Guile 2.2 there will be a dedicated finalization thread, to ensure that
-the finalization doesn't run within the critical section of any other
-thread known to Guile.
+interleaves them with running Scheme code; @pxref{Asyncs}. In Guile 2.2
+there will be a dedicated finalization thread, to ensure that the
+finalization doesn't run within the critical section of any other thread
+known to Guile.
In either case, finalizers run concurrently with the main program, and
so they need to be async-safe and thread-safe. If for some reason this
diff --git a/doc/ref/misc-modules.texi b/doc/ref/misc-modules.texi
index c1e65d7e3..6c899a905 100644
--- a/doc/ref/misc-modules.texi
+++ b/doc/ref/misc-modules.texi
@@ -47,7 +47,7 @@ follows,
@table @asis
@item @nicode{#:display?} @var{flag}
If @var{flag} is true then print using @code{display}. The default is
-@code{#f} which means use @code{write} style. (@pxref{Writing})
+@code{#f} which means use @code{write} style. @xref{Scheme Write}.
@item @nicode{#:per-line-prefix} @var{string}
Print the given @var{string} as a prefix on each line. The default is
@@ -55,6 +55,9 @@ no prefix.
@item @nicode{#:width} @var{columns}
Print within the given @var{columns}. The default is 79.
+
+@item @nicode{#:max-expr-width} @var{columns}
+The maximum width of an expression. The default is 50.
@end table
@end deffn
@@ -106,7 +109,7 @@ follows,
@table @asis
@item @nicode{#:display?} @var{flag}
If @var{flag} is true then print using @code{display}. The default is
-@code{#f} which means use @code{write} style. (@pxref{Writing})
+@code{#f} which means use @code{write} style. @pxref{Scheme Write}.
@item @nicode{#:width} @var{columns}
Print within the given @var{columns}. The default is 79.
@@ -204,7 +207,7 @@ Object output. Parameters: @var{minwidth}, @var{padinc},
@var{minpad}, @var{padchar}.
@nicode{~a} outputs an argument like @code{display}, @nicode{~s}
-outputs an argument like @code{write} (@pxref{Writing}).
+outputs an argument like @code{write} (@pxref{Scheme Write}).
@example
(format #t "~a" "foo") @print{} foo
@@ -242,9 +245,9 @@ no minimum or multiple).
Character. Parameter: @var{charnum}.
Output a character. The default is to simply output, as per
-@code{write-char} (@pxref{Writing}). @nicode{~@@c} prints in
-@code{write} style. @nicode{~:c} prints control characters (ASCII 0
-to 31) in @nicode{^X} form.
+@code{write-char} (@pxref{Venerable Port Interfaces}). @nicode{~@@c}
+prints in @code{write} style. @nicode{~:c} prints control characters
+(ASCII 0 to 31) in @nicode{^X} form.
@example
(format #t "~c" #\z) @print{} z
@@ -760,8 +763,9 @@ already so.
(format #f "a~3,5'*@@tx") @result{} "a****x"
@end example
-@nicode{~t} is implemented using @code{port-column} (@pxref{Reading}),
-so it works even there has been other output before @code{format}.
+@nicode{~t} is implemented using @code{port-column} (@pxref{Textual
+I/O}), so it works even there has been other output before
+@code{format}.
@item @nicode{~~}
Tilde character. Parameter: @var{n}.
@@ -815,7 +819,7 @@ Output a formfeed character, or @var{n} many if a parameter is given.
Force output. No parameters.
At the end of output, call @code{force-output} to flush any buffers on
-the destination (@pxref{Writing}). @nicode{~!} can occur anywhere in
+the destination (@pxref{Buffering}). @nicode{~!} can occur anywhere in
the format string, but the force is done at the end of output.
When output is to a string (destination @code{#f}), @nicode{~!} does
@@ -1112,10 +1116,10 @@ originating format, or similar.
@sp 1
Guile contains a @code{format} procedure even when the module
@code{(ice-9 format)} is not loaded. The default @code{format} is
-@code{simple-format} (@pxref{Writing}), it doesn't support all escape
-sequences documented in this section, and will signal an error if you
-try to use one of them. The reason for two versions is that the full
-@code{format} is fairly large and requires some time to load.
+@code{simple-format} (@pxref{Simple Output}), it doesn't support all
+escape sequences documented in this section, and will signal an error if
+you try to use one of them. The reason for two versions is that the
+full @code{format} is fairly large and requires some time to load.
@code{simple-format} is often adequate too.
@@ -1661,10 +1665,10 @@ returned.
@end deffn
@deffn {Scheme Procedure} port->stream port readproc
-Return a stream which is the values obtained by reading from
-@var{port} using @var{readproc}. Each read call is
-@code{(@var{readproc} @var{port})}, and it should return an EOF object
-(@pxref{Reading}) at the end of input.
+Return a stream which is the values obtained by reading from @var{port}
+using @var{readproc}. Each read call is @code{(@var{readproc}
+@var{port})}, and it should return an EOF object (@pxref{Binary I/O}) at
+the end of input.
For example a stream of characters from a file,
diff --git a/doc/ref/mod-getopt-long.texi b/doc/ref/mod-getopt-long.texi
index 07fab813b..cf043418f 100644
--- a/doc/ref/mod-getopt-long.texi
+++ b/doc/ref/mod-getopt-long.texi
@@ -7,6 +7,12 @@
@node getopt-long
@section The (ice-9 getopt-long) Module
+The @code{(ice-9 getopt-long)} facility is designed to help parse
+arguments that are passed to Guile programs on the command line, and is
+modelled after the C library's facility of the same name
+(@pxref{Getopt,,,libc,The GNU C Library Reference Manual}). For a more
+low-level interface to command-line argument parsing, @xref{SRFI-37}.
+
The @code{(ice-9 getopt-long)} module exports two procedures:
@code{getopt-long} and @code{option-ref}.
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 356941f2d..5cb68a292 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007,
-@c 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+@c 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2017 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node POSIX
@@ -133,18 +133,6 @@ then the return is @code{#f}. For example,
Conventions generally follow those of scsh, @ref{The Scheme shell (scsh)}.
-File ports are implemented using low-level operating system I/O
-facilities, with optional buffering to improve efficiency; see
-@ref{File Ports}.
-
-Note that some procedures (e.g., @code{recv!}) will accept ports as
-arguments, but will actually operate directly on the file descriptor
-underlying the port. Any port buffering is ignored, including the
-buffer which implements @code{peek-char} and @code{unread-char}.
-
-The @code{force-output} and @code{drain-input} procedures can be used
-to clear the buffers.
-
Each open file port has an associated operating system file descriptor.
File descriptors are generally not useful in Scheme programs; however
they may be needed when interfacing with foreign code and the Unix
@@ -181,6 +169,22 @@ initially set to one, so that dropping references to one of these
ports will not result in its garbage collection: it could be retrieved
with @code{fdopen} or @code{fdes->ports}.
+Guile's ports can be buffered. This means that writing a byte to a file
+port goes to the internal buffer first, and only when the buffer is full
+(or the user invokes @code{force-output} on the port) is the data
+actually written to the file descriptor. Likewise on input, bytes are
+read in from the file descriptor in blocks and placed in a buffer.
+Reading a character via @code{read-char} first goes to the buffer,
+filling it as needed. Usually read buffering is more or less
+transparent, but write buffering can sometimes cause writes to be
+delayed unexpectedly, if you forget to call @code{force-output}.
+@xref{Buffering}, for more on how to control port buffers.
+
+Note however that some procedures (e.g., @code{recv!}) will accept ports
+as arguments, but will actually operate directly on the file descriptor
+underlying the port. Any port buffering is ignored, including the
+buffer which implements @code{peek-char} and @code{unread-char}.
+
@deffn {Scheme Procedure} port-revealed port
@deffnx {C Function} scm_port_revealed (port)
Return the revealed count for @var{port}.
@@ -299,7 +303,7 @@ a port.
@deffn {Scheme Procedure} close fd_or_port
@deffnx {C Function} scm_close (fd_or_port)
-Similar to @code{close-port} (@pxref{Closing, close-port}),
+Similar to @code{close-port} (@pxref{Ports, close-port}),
but also works on file descriptors. A side
effect of closing a file descriptor is that any ports using that file
descriptor are moved to a different file descriptor and have
@@ -314,32 +318,16 @@ the file descriptor will be closed even if a port is using it. The
return value is unspecified.
@end deffn
-@deffn {Scheme Procedure} unread-char char [port]
-@deffnx {C Function} scm_unread_char (char, port)
-Place @var{char} in @var{port} so that it will be read by the next
-read operation on that port. If called multiple times, the unread
-characters will be read again in ``last-in, first-out'' order (i.e.@:
-a stack). If @var{port} is not supplied, the current input port is
-used.
-@end deffn
-
-@deffn {Scheme Procedure} unread-string str port
-Place the string @var{str} in @var{port} so that its characters will be
-read in subsequent read operations. If called multiple times, the
-unread characters will be read again in last-in first-out order. If
-@var{port} is not supplied, the current-input-port is used.
-@end deffn
-
@deffn {Scheme Procedure} pipe
@deffnx {C Function} scm_pipe ()
@cindex pipe
-Return a newly created pipe: a pair of ports which are linked
-together on the local machine. The @acronym{CAR} is the input
-port and the @acronym{CDR} is the output port. Data written (and
-flushed) to the output port can be read from the input port.
-Pipes are commonly used for communication with a newly forked
-child process. The need to flush the output port can be
-avoided by making it unbuffered using @code{setvbuf}.
+Return a newly created pipe: a pair of ports which are linked together
+on the local machine. The @acronym{CAR} is the input port and the
+@acronym{CDR} is the output port. Data written (and flushed) to the
+output port can be read from the input port. Pipes are commonly used
+for communication with a newly forked child process. The need to flush
+the output port can be avoided by making it unbuffered using
+@code{setvbuf} (@pxref{Buffering}).
@defvar PIPE_BUF
A write of up to @code{PIPE_BUF} many bytes to a pipe is atomic,
@@ -431,13 +419,6 @@ is made to move away ports which are using @var{newfd}.
The return value is unspecified.
@end deffn
-@deffn {Scheme Procedure} port-mode port
-Return the port modes associated with the open port @var{port}.
-These will not necessarily be identical to the modes used when
-the port was opened, since modes such as ``append'' which are
-used only during port creation are not retained.
-@end deffn
-
@deffn {Scheme Procedure} port-for-each proc
@deffnx {C Function} scm_port_for_each (SCM proc)
@deffnx {C Function} scm_c_port_for_each (void (*proc)(void *, SCM), void *data)
@@ -455,26 +436,6 @@ a pointer to a C function and passes along a arbitrary @var{data}
cookie.
@end deffn
-@deffn {Scheme Procedure} setvbuf port mode [size]
-@deffnx {C Function} scm_setvbuf (port, mode, size)
-@cindex port buffering
-Set the buffering mode for @var{port}. @var{mode} can be:
-
-@defvar _IONBF
-non-buffered
-@end defvar
-@defvar _IOLBF
-line buffered
-@end defvar
-@defvar _IOFBF
-block buffered, using a newly allocated buffer of @var{size} bytes.
-If @var{size} is omitted, a default size will be used.
-@end defvar
-
-Only certain types of ports are supported, most importantly
-file ports.
-@end deffn
-
@deffn {Scheme Procedure} fcntl port/fd cmd [value]
@deffnx {C Function} scm_fcntl (object, cmd, value)
Apply @var{cmd} on @var{port/fd}, either a port or file descriptor.
@@ -568,10 +529,10 @@ to provide input, accept output, or the existence of
exceptional conditions on a collection of ports or file
descriptors, or waiting for a timeout to occur.
-When an error occurs, of if it is interrupted by a signal, this
-procedure throws a @code{system-error} exception
-(@pxref{Conventions, @code{system-error}}). In case of an
-interruption, the associated error number is @var{EINTR}.
+When an error occurs, this procedure throws a @code{system-error}
+exception (@pxref{Conventions, @code{system-error}}). Note that
+@code{select} may return early for other reasons, for example due to
+pending interrupts. @xref{Asyncs}, for more on interrupts.
@var{reads}, @var{writes} and @var{excepts} can be lists or
vectors, with each member a port or a file descriptor.
@@ -598,6 +559,51 @@ Duplicates in the input vectors appear only once in output.
An additional @code{select!} interface is provided.
@end deffn
+While it is sometimes necessary to operate at the level of file
+descriptors, this is an operation whose correctness can only be
+considered as part of a whole program. So for example while the effects
+of @code{(string-set! x 34 #\y)} are limited to the bits of code that
+can access @var{x}, @code{(close-fdes 34)} mutates the state of the
+entire process. In particular if another thread is using file
+descriptor 34 then their state might be corrupted; and another thread
+which opens a file might cause file descriptor 34 to be re-used, so that
+corruption could manifest itself in a strange way.
+
+@cindex fdes finalizers
+@cindex file descriptor finalizers
+@cindex finalizers, file descriptor
+However when working with file descriptors, it's common to want to
+associate information with the file descriptor, perhaps in a side table.
+To support this use case and to allow user code to remove an association
+when a file descriptor is closed, Guile offers @dfn{fdes finalizers}.
+
+As the name indicates, fdes finalizers are finalizers -- they can run in
+response to garbage collection, and they can also run in response to
+explicit calls to @code{close-port}, @code{close-fdes}, or the like. As
+such they inherit many of the pitfalls of finalizers: they may be
+invoked from concurrent threads, or not at all. @xref{Foreign Object
+Memory Management}, for more on finalizers.
+
+To use fdes finalizers, import their module;
+
+@example
+(use-modules (ice-9 fdes-finalizers))
+@end example
+
+@deffn {Scheme Procedure} add-fdes-finalizer! fdes finalizer
+@deffnx {Scheme Procedure} remove-fdes-finalizer! fdes finalizer
+Add or remove a finalizer for @var{fdes}. A finalizer is a procedure
+that is called by Guile when a file descriptor is closed. The file
+descriptor being closed is passed as the one argument to the finalizer.
+If a finalizer has been added multiple times to a file descriptor, to
+remove it would require that number of calls to
+@code{remove-fdes-finalizer!}.
+
+The finalizers added to a file descriptor are called by Guile in an
+unspecified order, and their return values are ignored.
+@end deffn
+
+
@node File System
@subsection File System
@cindex file system
@@ -864,9 +870,10 @@ Create a symbolic link named @var{newpath} with the value (i.e., pointing to)
@deffn {Scheme Procedure} mkdir path [mode]
@deffnx {C Function} scm_mkdir (path, mode)
Create a new directory named by @var{path}. If @var{mode} is omitted
-then the permissions of the directory file are set using the current
-umask (@pxref{Processes}). Otherwise they are set to the decimal
-value specified with @var{mode}. The return value is unspecified.
+then the permissions of the directory are set to @code{#o777}
+masked with the current umask (@pxref{Processes, @code{umask}}).
+Otherwise they are set to the value specified with @var{mode}.
+The return value is unspecified.
@end deffn
@deffn {Scheme Procedure} rmdir path
@@ -966,7 +973,7 @@ another name if the file exists (error @code{EEXIST}).
@code{mkstemp!} below does that.
@end deffn
-@deffn {Scheme Procedure} mkstemp! tmpl
+@deffn {Scheme Procedure} mkstemp! tmpl [mode]
@deffnx {C Function} scm_mkstemp (tmpl)
@cindex temporary file
Create a new unique file in the file system and return a new buffered
@@ -987,6 +994,10 @@ which is usual for ordinary file creation,
(chmod port (logand #o666 (lognot (umask))))
...)
@end example
+
+The optional @var{mode} argument specifies a mode with which to open the
+new file, as a string in the same format that @code{open-file} takes.
+It defaults to @code{"w+"}.
@end deffn
@deffn {Scheme Procedure} tmpfile
@@ -1966,29 +1977,8 @@ Currently this procedure is only defined on GNU variants
GNU C Library Reference Manual}).
@end deffn
-@deffn {Scheme Procedure} total-processor-count
-@deffnx {C Function} scm_total_processor_count ()
-Return the total number of processors of the machine, which
-is guaranteed to be at least 1. A ``processor'' here is a
-thread execution unit, which can be either:
-
-@itemize
-@item an execution core in a (possibly multi-core) chip, in a
- (possibly multi- chip) module, in a single computer, or
-@item a thread execution unit inside a core in the case of
- @dfn{hyper-threaded} CPUs.
-@end itemize
-
-Which of the two definitions is used, is unspecified.
-@end deffn
-
-@deffn {Scheme Procedure} current-processor-count
-@deffnx {C Function} scm_current_processor_count ()
-Like @code{total-processor-count}, but return the number of
-processors available to the current process. See
-@code{setaffinity} and @code{getaffinity} for more
-information.
-@end deffn
+@xref{Threads}, for information on how get the number of processors
+available on a system.
@node Signals
@@ -1997,11 +1987,11 @@ information.
The following procedures raise, handle and wait for signals.
-Scheme code signal handlers are run via a system async (@pxref{System
-asyncs}), so they're called in the handler's thread at the next safe
-opportunity. Generally this is after any currently executing
-primitive procedure finishes (which could be a long time for
-primitives that wait for an external event).
+Scheme code signal handlers are run via an async (@pxref{Asyncs}), so
+they're called in the handler's thread at the next safe opportunity.
+Generally this is after any currently executing primitive procedure
+finishes (which could be a long time for primitives that wait for an
+external event).
@deffn {Scheme Procedure} kill pid sig
@deffnx {C Function} scm_kill (pid, sig)
@@ -2087,6 +2077,22 @@ restart the system call (as opposed to returning an @code{EINTR} error
from that call).
@end defvar
+Guile handles signals asynchronously. When it receives a signal, the
+synchronous signal handler just records the fact that a signal was
+received and sets a flag to tell the relevant Guile thread that it has a
+pending signal. When the Guile thread checks the pending-interrupt
+flag, it will arrange to run the asynchronous part of the signal
+handler, which is the handler attached by @code{sigaction}.
+
+This strategy has some perhaps-unexpected interactions with the
+@code{SA_RESTART} flag, though: because the synchronous handler doesn't
+do very much, and notably it doesn't run the Guile handler, it's
+impossible to interrupt a thread stuck in a long-running system call via
+a signal handler that is installed with @code{SA_RESTART}: the
+synchronous handler just records the pending interrupt, but then the
+system call resumes and Guile doesn't have a chance to actually check
+the flag and run the asynchronous handler. That's just how it is.
+
The return value is a pair with information about the old handler as
described above.
@@ -2156,12 +2162,12 @@ expiry will be signalled.
A real-time timer, counting down elapsed real time. At zero it raises
@code{SIGALRM}. This is like @code{alarm} above, but with a higher
resolution period.
-@end defvar
+@end defvar
@defvar ITIMER_VIRTUAL
A virtual-time timer, counting down while the current process is
actually using CPU. At zero it raises @code{SIGVTALRM}.
-@end defvar
+@end defvar
@defvar ITIMER_PROF
A profiling timer, counting down while the process is running (like
@@ -2170,7 +2176,7 @@ process's behalf. At zero it raises a @code{SIGPROF}.
This timer is intended for profiling where a program is spending its
time (by looking where it is when the timer goes off).
-@end defvar
+@end defvar
@code{getitimer} returns the restart timer value and its current value,
as a list containing two pairs. Each pair is a time in seconds and
@@ -2190,6 +2196,13 @@ previous setting, in the same form as @code{getitimer} returns.
Although the timers are programmed in microseconds, the actual
accuracy might not be that high.
+
+Note that @code{ITIMER_PROF} and @code{ITIMER_VIRTUAL} are not
+functional on all platforms and may always error when called.
+@code{(provided? 'ITIMER_PROF)} and @code{(provided? 'ITIMER_VIRTUAL)}
+can be used to test if the those itimers are supported on the given
+host. @code{ITIMER_REAL} is supported on all platforms that support
+@code{setitimer}.
@end deffn
@@ -2249,7 +2262,7 @@ controlling terminal. The return value is unspecified.
The following procedures are similar to the @code{popen} and
@code{pclose} system routines. The code is in a separate ``popen''
module@footnote{This module is only available on systems where the
-@code{fork} feature is provided (@pxref{Common Feature Symbols}).}:
+@code{popen} feature is provided (@pxref{Common Feature Symbols}).}:
@lisp
(use-modules (ice-9 popen))
@@ -2278,7 +2291,7 @@ For an input pipe, the child's standard output is the pipe and
standard input is inherited from @code{current-input-port}. For an
output pipe, the child's standard input is the pipe and standard
output is inherited from @code{current-output-port}. In all cases
-cases the child's standard error is inherited from
+the child's standard error is inherited from
@code{current-error-port} (@pxref{Default Ports}).
If those @code{current-X-ports} are not files of some kind, and hence
@@ -2286,11 +2299,10 @@ don't have file descriptors for the child, then @file{/dev/null} is
used instead.
Care should be taken with @code{OPEN_BOTH}, a deadlock will occur if
-both parent and child are writing, and waiting until the write
-completes before doing any reading. Each direction has
-@code{PIPE_BUF} bytes of buffering (@pxref{Ports and File
-Descriptors}), which will be enough for small writes, but not for say
-putting a big file through a filter.
+both parent and child are writing, and waiting until the write completes
+before doing any reading. Each direction has @code{PIPE_BUF} bytes of
+buffering (@pxref{Buffering}), which will be enough for small writes,
+but not for say putting a big file through a filter.
@end deffn
@deffn {Scheme Procedure} open-input-pipe command
@@ -2333,8 +2345,8 @@ terminate, and return the wait status code. The status is as per
it can reap a pipe's child process, causing an error from a subsequent
@code{close-pipe}.
-@code{close-port} (@pxref{Closing}) can close a pipe, but it doesn't
-reap the child process.
+@code{close-port} (@pxref{Ports}) can close a pipe, but it doesn't reap
+the child process.
The garbage collector will close a pipe no longer in use, and reap the
child process with @code{waitpid}. If the child hasn't yet terminated
@@ -3057,7 +3069,7 @@ release the returned structure when no longer required.
Socket ports can be created using @code{socket} and @code{socketpair}.
The ports are initially unbuffered, to make reading and writing to the
same port more reliable. A buffer can be added to the port using
-@code{setvbuf}; see @ref{Ports and File Descriptors}.
+@code{setvbuf} (@pxref{Buffering}).
Most systems have limits on how many files and sockets can be open, so
it's strongly recommended that socket ports be closed explicitly when
@@ -3191,6 +3203,15 @@ supporting that.
@end defvar
@end deffn
+For @code{IPPROTO_TCP} level the following @var{optname}s are defined
+(when provided by the system). For their meaning see @command{man 7
+tcp}.
+
+@defvar TCP_NODELAY
+@defvarx TCP_CORK
+The @var{value} taken or returned is an integer.
+@end defvar
+
@deffn {Scheme Procedure} shutdown sock how
@deffnx {C Function} scm_shutdown (sock, how)
Sockets can be closed simply by using @code{close-port}. The
@@ -3217,10 +3238,12 @@ The return value is unspecified.
@deffnx {Scheme Procedure} connect sock AF_INET6 ipv6addr port [flowinfo [scopeid]]
@deffnx {Scheme Procedure} connect sock AF_UNIX path
@deffnx {C Function} scm_connect (sock, fam, address, args)
-Initiate a connection on socket port @var{sock} to a given address.
-The destination is either a socket address object, or arguments the
-same as @code{make-socket-address} would take to make such an object
-(@pxref{Network Socket Address}). The return value is unspecified.
+Initiate a connection on socket port @var{sock} to a given address. The
+destination is either a socket address object, or arguments the same as
+@code{make-socket-address} would take to make such an object
+(@pxref{Network Socket Address}). Return true unless the socket was
+configured as non-blocking and the connection could not be made
+immediately.
@example
(connect sock AF_INET INADDR_LOOPBACK 23)
@@ -3261,18 +3284,33 @@ the queue.
The return value is unspecified.
@end deffn
-@deffn {Scheme Procedure} accept sock
+@deffn {Scheme Procedure} accept sock [flags]
@deffnx {C Function} scm_accept (sock)
Accept a connection from socket port @var{sock} which has been enabled
-for listening with @code{listen} above. If there are no incoming
-connections in the queue, wait until one is available (unless
-@code{O_NONBLOCK} has been set on the socket, @pxref{Ports and File
-Descriptors,@code{fcntl}}).
+for listening with @code{listen} above.
+
+If there are no incoming connections in the queue, there are two
+possible behaviors, depending on whether @var{sock} has been configured
+for non-blocking operation or not:
+
+@itemize
+@item
+If there is no connection waiting and the socket was set to non-blocking
+mode with the @code{O_NONBLOCK} port option (@pxref{Ports and File
+Descriptors,@code{fcntl}}), return @code{#f} directly.
+
+@item
+Otherwise wait until a connection is available.
+@end itemize
The return value is a pair. The @code{car} is a new socket port,
-connected and ready to communicate. The @code{cdr} is a socket
-address object (@pxref{Network Socket Address}) which is where the
-remote connection is from (like @code{getpeername} below).
+connected and ready to communicate. The @code{cdr} is a socket address
+object (@pxref{Network Socket Address}) which is where the remote
+connection is from (like @code{getpeername} below).
+
+@var{flags}, if given, may include @code{SOCK_CLOEXEC} or
+@code{SOCK_NONBLOCK}, which like @code{O_CLOEXEC} and @code{O_NONBLOCK}
+apply to the newly accepted socket.
All communication takes place using the new socket returned. The
given @var{sock} remains bound and listening, and @code{accept} may be
diff --git a/doc/ref/r6rs.texi b/doc/ref/r6rs.texi
index e5ffb78e4..fa8d7d213 100644
--- a/doc/ref/r6rs.texi
+++ b/doc/ref/r6rs.texi
@@ -97,9 +97,9 @@ The @code{(rnrs io ports)} module is incomplete. Work is
ongoing to fix this.
@item
-Guile does not prevent use of textual I/O procedures on binary ports.
-More generally, it does not make a sharp distinction between binary and
-textual ports (@pxref{R6RS Port Manipulation, binary-port?}).
+Guile does not prevent use of textual I/O procedures on binary ports, or
+vice versa. All ports in Guile support both binary and textual I/O.
+@xref{Encoding}, for full details.
@item
Guile's implementation of @code{equal?} may fail to terminate when
@@ -147,8 +147,10 @@ Language Scheme}).
* rnrs exceptions:: Handling exceptional situations.
* rnrs conditions:: Data structures for exceptions.
-* I/O Conditions:: Predefined I/O error types.
+* R6RS I/O Conditions:: Predefined I/O error types.
+* R6RS Transcoders:: Characters and bytes.
* rnrs io ports:: Support for port-based I/O.
+* R6RS File Ports:: Working with files.
* rnrs io simple:: High-level I/O API.
* rnrs files:: Functions for working with files.
@@ -722,11 +724,15 @@ These procedures are identical to the ones provided by SRFI-1.
@xref{SRFI-1 Filtering and Partitioning}, for @code{partition}.
@end deffn
+@deffn {Scheme Procedure} fold-right combine nil list1 list2 @dots{}
+This procedure is identical the @code{fold-right} procedure provided by
+SRFI-1. @xref{SRFI-1 Fold and Map}, for documentation.
+@end deffn
+
@deffn {Scheme Procedure} fold-left combine nil list1 list2 @dots{}
-@deffnx {Scheme Procedure} fold-right combine nil list1 list2 @dots{}
-These procedures are identical to the @code{fold} and @code{fold-right}
-procedures provided by SRFI-1. @xref{SRFI-1 Fold and Map}, for
-documentation.
+This procedure is like @code{fold} from SRFI-1, but @var{combine} is
+called with the seed as the first argument. @xref{SRFI-1 Fold and Map},
+for documentation.
@end deffn
@deffn {Scheme Procedure} remp proc list
@@ -1343,7 +1349,7 @@ A subtype of @code{&violation} that indicates a reference to an unbound
identifier.
@end deffn
-@node I/O Conditions
+@node R6RS I/O Conditions
@subsubsection I/O Conditions
These condition types are exported by both the
@@ -1420,21 +1426,548 @@ A subtype of @code{&i/o}; represents an error related to an operation on
the port @var{port}.
@end deffn
+@node R6RS Transcoders
+@subsubsection Transcoders
+@cindex codec
+@cindex end-of-line style
+@cindex transcoder
+@cindex binary port
+@cindex textual port
+
+The transcoder facilities are exported by @code{(rnrs io ports)}.
+
+Several different Unicode encoding schemes describe standard ways to
+encode characters and strings as byte sequences and to decode those
+sequences. Within this document, a @dfn{codec} is an immutable Scheme
+object that represents a Unicode or similar encoding scheme.
+
+An @dfn{end-of-line style} is a symbol that, if it is not @code{none},
+describes how a textual port transcodes representations of line endings.
+
+A @dfn{transcoder} is an immutable Scheme object that combines a codec
+with an end-of-line style and a method for handling decoding errors.
+Each transcoder represents some specific bidirectional (but not
+necessarily lossless), possibly stateful translation between byte
+sequences and Unicode characters and strings. Every transcoder can
+operate in the input direction (bytes to characters) or in the output
+direction (characters to bytes). A @var{transcoder} parameter name
+means that the corresponding argument must be a transcoder.
+
+A @dfn{binary port} is a port that supports binary I/O, does not have an
+associated transcoder and does not support textual I/O. A @dfn{textual
+port} is a port that supports textual I/O, and does not support binary
+I/O. A textual port may or may not have an associated transcoder.
+
+@deffn {Scheme Procedure} latin-1-codec
+@deffnx {Scheme Procedure} utf-8-codec
+@deffnx {Scheme Procedure} utf-16-codec
+
+These are predefined codecs for the ISO 8859-1, UTF-8, and UTF-16
+encoding schemes.
+
+A call to any of these procedures returns a value that is equal in the
+sense of @code{eqv?} to the result of any other call to the same
+procedure.
+@end deffn
+
+@deffn {Scheme Syntax} eol-style @var{eol-style-symbol}
+
+@var{eol-style-symbol} should be a symbol whose name is one of
+@code{lf}, @code{cr}, @code{crlf}, @code{nel}, @code{crnel}, @code{ls},
+and @code{none}.
+
+The form evaluates to the corresponding symbol. If the name of
+@var{eol-style-symbol} is not one of these symbols, the effect and
+result are implementation-dependent; in particular, the result may be an
+eol-style symbol acceptable as an @var{eol-style} argument to
+@code{make-transcoder}. Otherwise, an exception is raised.
+
+All eol-style symbols except @code{none} describe a specific
+line-ending encoding:
+
+@table @code
+@item lf
+linefeed
+@item cr
+carriage return
+@item crlf
+carriage return, linefeed
+@item nel
+next line
+@item crnel
+carriage return, next line
+@item ls
+line separator
+@end table
+
+For a textual port with a transcoder, and whose transcoder has an
+eol-style symbol @code{none}, no conversion occurs. For a textual input
+port, any eol-style symbol other than @code{none} means that all of the
+above line-ending encodings are recognized and are translated into a
+single linefeed. For a textual output port, @code{none} and @code{lf}
+are equivalent. Linefeed characters are encoded according to the
+specified eol-style symbol, and all other characters that participate in
+possible line endings are encoded as is.
+
+@quotation Note
+ Only the name of @var{eol-style-symbol} is significant.
+@end quotation
+@end deffn
+
+@deffn {Scheme Procedure} native-eol-style
+Returns the default end-of-line style of the underlying platform, e.g.,
+@code{lf} on Unix and @code{crlf} on Windows.
+@end deffn
+
+@deffn {Condition Type} &i/o-decoding
+@deffnx {Scheme Procedure} make-i/o-decoding-error port
+@deffnx {Scheme Procedure} i/o-decoding-error? obj
+This condition type could be defined by
+
+@lisp
+(define-condition-type &i/o-decoding &i/o-port
+ make-i/o-decoding-error i/o-decoding-error?)
+@end lisp
+
+An exception with this type is raised when one of the operations for
+textual input from a port encounters a sequence of bytes that cannot be
+translated into a character or string by the input direction of the
+port's transcoder.
+
+When such an exception is raised, the port's position is past the
+invalid encoding.
+@end deffn
+
+@deffn {Condition Type} &i/o-encoding
+@deffnx {Scheme Procedure} make-i/o-encoding-error port char
+@deffnx {Scheme Procedure} i/o-encoding-error? obj
+@deffnx {Scheme Procedure} i/o-encoding-error-char condition
+This condition type could be defined by
+
+@lisp
+(define-condition-type &i/o-encoding &i/o-port
+ make-i/o-encoding-error i/o-encoding-error?
+ (char i/o-encoding-error-char))
+@end lisp
+
+An exception with this type is raised when one of the operations for
+textual output to a port encounters a character that cannot be
+translated into bytes by the output direction of the port's transcoder.
+@var{char} is the character that could not be encoded.
+@end deffn
+
+@deffn {Scheme Syntax} error-handling-mode @var{error-handling-mode-symbol}
+@var{error-handling-mode-symbol} should be a symbol whose name is one of
+@code{ignore}, @code{raise}, and @code{replace}. The form evaluates to
+the corresponding symbol. If @var{error-handling-mode-symbol} is not
+one of these identifiers, effect and result are
+implementation-dependent: The result may be an error-handling-mode
+symbol acceptable as a @var{handling-mode} argument to
+@code{make-transcoder}. If it is not acceptable as a
+@var{handling-mode} argument to @code{make-transcoder}, an exception is
+raised.
+
+@quotation Note
+ Only the name of @var{error-handling-mode-symbol} is significant.
+@end quotation
+
+The error-handling mode of a transcoder specifies the behavior
+of textual I/O operations in the presence of encoding or decoding
+errors.
+
+If a textual input operation encounters an invalid or incomplete
+character encoding, and the error-handling mode is @code{ignore}, an
+appropriate number of bytes of the invalid encoding are ignored and
+decoding continues with the following bytes.
+
+If the error-handling mode is @code{replace}, the replacement
+character U+FFFD is injected into the data stream, an appropriate
+number of bytes are ignored, and decoding
+continues with the following bytes.
+
+If the error-handling mode is @code{raise}, an exception with condition
+type @code{&i/o-decoding} is raised.
+
+If a textual output operation encounters a character it cannot encode,
+and the error-handling mode is @code{ignore}, the character is ignored
+and encoding continues with the next character. If the error-handling
+mode is @code{replace}, a codec-specific replacement character is
+emitted by the transcoder, and encoding continues with the next
+character. The replacement character is U+FFFD for transcoders whose
+codec is one of the Unicode encodings, but is the @code{?} character
+for the Latin-1 encoding. If the error-handling mode is @code{raise},
+an exception with condition type @code{&i/o-encoding} is raised.
+@end deffn
+
+@deffn {Scheme Procedure} make-transcoder codec
+@deffnx {Scheme Procedure} make-transcoder codec eol-style
+@deffnx {Scheme Procedure} make-transcoder codec eol-style handling-mode
+@var{codec} must be a codec; @var{eol-style}, if present, an eol-style
+symbol; and @var{handling-mode}, if present, an error-handling-mode
+symbol.
+
+@var{eol-style} may be omitted, in which case it defaults to the native
+end-of-line style of the underlying platform. @var{handling-mode} may
+be omitted, in which case it defaults to @code{replace}. The result is
+a transcoder with the behavior specified by its arguments.
+@end deffn
+
+@deffn {Scheme procedure} native-transcoder
+Returns an implementation-dependent transcoder that represents a
+possibly locale-dependent ``native'' transcoding.
+@end deffn
+
+@deffn {Scheme Procedure} transcoder-codec transcoder
+@deffnx {Scheme Procedure} transcoder-eol-style transcoder
+@deffnx {Scheme Procedure} transcoder-error-handling-mode transcoder
+These are accessors for transcoder objects; when applied to a
+transcoder returned by @code{make-transcoder}, they return the
+@var{codec}, @var{eol-style}, and @var{handling-mode} arguments,
+respectively.
+@end deffn
+
+@deffn {Scheme Procedure} bytevector->string bytevector transcoder
+Returns the string that results from transcoding the
+@var{bytevector} according to the input direction of the transcoder.
+@end deffn
+
+@deffn {Scheme Procedure} string->bytevector string transcoder
+Returns the bytevector that results from transcoding the
+@var{string} according to the output direction of the transcoder.
+@end deffn
+
@node rnrs io ports
@subsubsection rnrs io ports
-The @code{(rnrs io ports (6))} library provides various procedures and
-syntactic forms for use in writing to and reading from ports. This
-functionality is documented in its own section of the manual;
-(@pxref{R6RS I/O Ports}).
+@cindex R6RS
+@cindex R6RS ports
+Guile's binary and textual port interface was heavily inspired by R6RS,
+so many R6RS port interfaces are documented elsewhere. Note that R6RS
+ports are not disjoint from Guile's native ports, so Guile-specific
+procedures will work on ports created using the R6RS API, and vice
+versa. Also note that in Guile, all ports are both textual and binary.
+@xref{Input and Output}, for more on Guile's core port API. The R6RS
+ports module wraps Guile's I/O routines in a helper that will translate
+native Guile exceptions to R6RS conditions; @xref{R6RS I/O Conditions},
+for more. @xref{R6RS File Ports}, for documentation on the R6RS file
+port interface.
+
+@c FIXME: Update description when implemented.
+@emph{Note}: The implementation of this R6RS API is not complete yet.
+
+@deffn {Scheme Procedure} eof-object? obj
+@xref{Binary I/O}, for documentation.
+@end deffn
+
+@deffn {Scheme Procedure} eof-object
+Return the end-of-file (EOF) object.
+
+@lisp
+(eof-object? (eof-object))
+@result{} #t
+@end lisp
+@end deffn
+
+@deffn {Scheme Procedure} port? obj
+@deffnx {Scheme Procedure} input-port? obj
+@deffnx {Scheme Procedure} output-port? obj
+@xref{Ports}, for documentation.
+@end deffn
+
+@deffn {Scheme Procedure} port-transcoder port
+Return a transcoder associated with the encoding of @var{port}.
+@xref{Encoding}, and @xref{R6RS Transcoders}.
+@end deffn
+
+@deffn {Scheme Procedure} binary-port? port
+@deffnx {Scheme Procedure} textual-port? port
+Return @code{#t}, as all ports in Guile are suitable for binary and
+textual I/O. @xref{Encoding}, for more details.
+@end deffn
+
+@deffn {Scheme Procedure} transcoded-port binary-port transcoder
+The @code{transcoded-port} procedure
+returns a new textual port with the specified @var{transcoder}.
+Otherwise the new textual port's state is largely the same as
+that of @var{binary-port}.
+If @var{binary-port} is an input port, the new textual
+port will be an input port and
+will transcode the bytes that have not yet been read from
+@var{binary-port}.
+If @var{binary-port} is an output port, the new textual
+port will be an output port and
+will transcode output characters into bytes that are
+written to the byte sink represented by @var{binary-port}.
+
+As a side effect, however, @code{transcoded-port}
+closes @var{binary-port} in
+a special way that allows the new textual port to continue to
+use the byte source or sink represented by @var{binary-port},
+even though @var{binary-port} itself is closed and cannot
+be used by the input and output operations described in this
+chapter.
+@end deffn
+
+@deffn {Scheme Procedure} port-position port
+Equivalent to @code{(seek @var{port} SEEK_CUR 0)}. @xref{Random
+Access}.
+@end deffn
+
+@deffn {Scheme Procedure} port-has-port-position? port
+Return @code{#t} is @var{port} supports @code{port-position}.
+@end deffn
+
+@deffn {Scheme Procedure} set-port-position! port offset
+Equivalent to @code{(seek @var{port} SEEK_SET @var{offset})}.
+@xref{Random Access}.
+@end deffn
+
+@deffn {Scheme Procedure} port-has-set-port-position!? port
+Return @code{#t} is @var{port} supports @code{set-port-position!}.
+@end deffn
+
+@deffn {Scheme Procedure} call-with-port port proc
+Call @var{proc}, passing it @var{port} and closing @var{port} upon exit
+of @var{proc}. Return the return values of @var{proc}.
+@end deffn
+
+@deffn {Scheme Procedure} port-eof? input-port
+Equivalent to @code{(eof-object? (lookahead-u8 @var{input-port}))}.
+@end deffn
+
+@deffn {Scheme Procedure} standard-input-port
+@deffnx {Scheme Procedure} standard-output-port
+@deffnx {Scheme Procedure} standard-error-port
+Returns a fresh binary input port connected to standard input, or a
+binary output port connected to the standard output or standard error,
+respectively. Whether the port supports the @code{port-position} and
+@code{set-port-position!} operations is implementation-dependent.
+@end deffn
+
+@deffn {Scheme Procedure} current-input-port
+@deffnx {Scheme Procedure} current-output-port
+@deffnx {Scheme Procedure} current-error-port
+@xref{Default Ports}.
+@end deffn
+
+@deffn {Scheme Procedure} open-bytevector-input-port bv [transcoder]
+@deffnx {Scheme Procedure} open-bytevector-output-port [transcoder]
+@xref{Bytevector Ports}.
+@end deffn
+
+@deffn {Scheme Procedure} make-custom-binary-input-port id read! get-position set-position! close
+@deffnx {Scheme Procedure} make-custom-binary-output-port id write! get-position set-position! close
+@deffnx {Scheme Procedure} make-custom-binary-input/output-port id read! write! get-position set-position! close
+@xref{Custom Ports}.
+@end deffn
+
+@deffn {Scheme Procedure} get-u8 port
+@deffnx {Scheme Procedure} lookahead-u8 port
+@deffnx {Scheme Procedure} get-bytevector-n port count
+@deffnx {Scheme Procedure} get-bytevector-n! port bv start count
+@deffnx {Scheme Procedure} get-bytevector-some port
+@deffnx {Scheme Procedure} get-bytevector-all port
+@deffnx {Scheme Procedure} put-u8 port octet
+@deffnx {Scheme Procedure} put-bytevector port bv [start [count]]
+@xref{Binary I/O}.
+@end deffn
+
+@deffn {Scheme Procedure} get-char textual-input-port
+@deffnx {Scheme Procedure} lookahead-char textual-input-port
+@deffnx {Scheme Procedure} get-string-n textual-input-port count
+@deffnx {Scheme Procedure} get-string-n! textual-input-port string start count
+@deffnx {Scheme Procedure} get-string-all textual-input-port
+@deffnx {Scheme Procedure} get-line textual-input-port
+@deffnx {Scheme Procedure} put-char port char
+@deffnx {Scheme Procedure} put-string port string [start [count]]
+@xref{Textual I/O}.
+@end deffn
+
+@deffn {Scheme Procedure} get-datum textual-input-port count
+Reads an external representation from @var{textual-input-port} and returns the
+datum it represents. The @code{get-datum} procedure returns the next
+datum that can be parsed from the given @var{textual-input-port}, updating
+@var{textual-input-port} to point exactly past the end of the external
+representation of the object.
+
+Any @emph{interlexeme space} (comment or whitespace, @pxref{Scheme
+Syntax}) in the input is first skipped. If an end of file occurs after
+the interlexeme space, the end-of-file object is returned.
+
+If a character inconsistent with an external representation is
+encountered in the input, an exception with condition types
+@code{&lexical} and @code{&i/o-read} is raised. Also, if the end of
+file is encountered after the beginning of an external representation,
+but the external representation is incomplete and therefore cannot be
+parsed, an exception with condition types @code{&lexical} and
+@code{&i/o-read} is raised.
+@end deffn
+
+@deffn {Scheme Procedure} put-datum textual-output-port datum
+@var{datum} should be a datum value. The @code{put-datum} procedure
+writes an external representation of @var{datum} to
+@var{textual-output-port}. The specific external representation is
+implementation-dependent. However, whenever possible, an implementation
+should produce a representation for which @code{get-datum}, when reading
+the representation, will return an object equal (in the sense of
+@code{equal?}) to @var{datum}.
+
+@quotation Note
+ Not all datums may allow producing an external representation for which
+ @code{get-datum} will produce an object that is equal to the
+ original. Specifically, NaNs contained in @var{datum} may make
+ this impossible.
+@end quotation
+
+@quotation Note
+ The @code{put-datum} procedure merely writes the external
+ representation, but no trailing delimiter. If @code{put-datum} is
+ used to write several subsequent external representations to an
+ output port, care should be taken to delimit them properly so they can
+ be read back in by subsequent calls to @code{get-datum}.
+@end quotation
+@end deffn
+
+@deffn {Scheme Procedure} flush-output-port port
+@xref{Buffering}, for documentation on @code{force-output}.
+@end deffn
+
+@node R6RS File Ports
+@subsubsection R6RS File Ports
+
+The facilities described in this section are exported by the @code{(rnrs
+io ports)} module.
+
+@deffn {Scheme Syntax} buffer-mode @var{buffer-mode-symbol}
+@var{buffer-mode-symbol} must be a symbol whose name is one of
+@code{none}, @code{line}, and @code{block}. The result is the
+corresponding symbol, and specifies the associated buffer mode.
+@xref{Buffering}, for a discussion of these different buffer modes. To
+control the amount of buffering, use @code{setvbuf} instead. Note that
+only the name of @var{buffer-mode-symbol} is significant.
+
+@xref{Buffering}, for a discussion of port buffering.
+@end deffn
+
+@deffn {Scheme Procedure} buffer-mode? obj
+Returns @code{#t} if the argument is a valid buffer-mode symbol, and
+returns @code{#f} otherwise.
+@end deffn
+
+When opening a file, the various procedures accept a @code{file-options}
+object that encapsulates flags to specify how the file is to be
+opened. A @code{file-options} object is an enum-set (@pxref{rnrs enums})
+over the symbols constituting valid file options.
+
+A @var{file-options} parameter name means that the corresponding
+argument must be a file-options object.
+
+@deffn {Scheme Syntax} file-options @var{file-options-symbol} ...
+
+Each @var{file-options-symbol} must be a symbol.
+
+The @code{file-options} syntax returns a file-options object that
+encapsulates the specified options.
+
+When supplied to an operation that opens a file for output, the
+file-options object returned by @code{(file-options)} specifies that the
+file is created if it does not exist and an exception with condition
+type @code{&i/o-file-already-exists} is raised if it does exist. The
+following standard options can be included to modify the default
+behavior.
+
+@table @code
+@item no-create
+ If the file does not already exist, it is not created;
+ instead, an exception with condition type @code{&i/o-file-does-not-exist}
+ is raised.
+ If the file already exists, the exception with condition type
+ @code{&i/o-file-already-exists} is not raised
+ and the file is truncated to zero length.
+@item no-fail
+ If the file already exists, the exception with condition type
+ @code{&i/o-file-already-exists} is not raised,
+ even if @code{no-create} is not included,
+ and the file is truncated to zero length.
+@item no-truncate
+ If the file already exists and the exception with condition type
+ @code{&i/o-file-already-exists} has been inhibited by inclusion of
+ @code{no-create} or @code{no-fail}, the file is not truncated, but
+ the port's current position is still set to the beginning of the
+ file.
+@end table
+
+These options have no effect when a file is opened only for input.
+Symbols other than those listed above may be used as
+@var{file-options-symbol}s; they have implementation-specific meaning,
+if any.
+
+@quotation Note
+ Only the name of @var{file-options-symbol} is significant.
+@end quotation
+@end deffn
+
+@deffn {Scheme Procedure} open-file-input-port filename
+@deffnx {Scheme Procedure} open-file-input-port filename file-options
+@deffnx {Scheme Procedure} open-file-input-port filename file-options buffer-mode
+@deffnx {Scheme Procedure} open-file-input-port filename file-options buffer-mode maybe-transcoder
+@var{maybe-transcoder} must be either a transcoder or @code{#f}.
+
+The @code{open-file-input-port} procedure returns an
+input port for the named file. The @var{file-options} and
+@var{maybe-transcoder} arguments are optional.
+
+The @var{file-options} argument, which may determine various aspects of
+the returned port, defaults to the value of @code{(file-options)}.
+
+The @var{buffer-mode} argument, if supplied,
+must be one of the symbols that name a buffer mode.
+The @var{buffer-mode} argument defaults to @code{block}.
+
+If @var{maybe-transcoder} is a transcoder, it becomes the transcoder associated
+with the returned port.
+
+If @var{maybe-transcoder} is @code{#f} or absent,
+the port will be a binary port and will support the
+@code{port-position} and @code{set-port-position!} operations.
+Otherwise the port will be a textual port, and whether it supports
+the @code{port-position} and @code{set-port-position!} operations
+is implementation-dependent (and possibly transcoder-dependent).
+@end deffn
+
+@deffn {Scheme Procedure} open-file-output-port filename
+@deffnx {Scheme Procedure} open-file-output-port filename file-options
+@deffnx {Scheme Procedure} open-file-output-port filename file-options buffer-mode
+@deffnx {Scheme Procedure} open-file-output-port filename file-options buffer-mode maybe-transcoder
+@var{maybe-transcoder} must be either a transcoder or @code{#f}.
+
+The @code{open-file-output-port} procedure returns an output port for the named file.
+
+The @var{file-options} argument, which may determine various aspects of
+the returned port, defaults to the value of @code{(file-options)}.
+
+The @var{buffer-mode} argument, if supplied,
+must be one of the symbols that name a buffer mode.
+The @var{buffer-mode} argument defaults to @code{block}.
+
+If @var{maybe-transcoder} is a transcoder, it becomes the transcoder
+associated with the port.
+
+If @var{maybe-transcoder} is @code{#f} or absent,
+the port will be a binary port and will support the
+@code{port-position} and @code{set-port-position!} operations.
+Otherwise the port will be a textual port, and whether it supports
+the @code{port-position} and @code{set-port-position!} operations
+is implementation-dependent (and possibly transcoder-dependent).
+@end deffn
@node rnrs io simple
@subsubsection rnrs io simple
The @code{(rnrs io simple (6))} library provides convenience functions
for performing textual I/O on ports. This library also exports all of
-the condition types and associated procedures described in (@pxref{I/O
-Conditions}). In the context of this section, when stating that a
+the condition types and associated procedures described in (@pxref{R6RS
+I/O Conditions}). In the context of this section, when stating that a
procedure behaves ``identically'' to the corresponding procedure in
Guile's core library, this is modulo the behavior wrt. conditions: such
procedures raise the appropriate R6RS conditions in case of error, but
@@ -1451,9 +1984,8 @@ appropriate R6RS conditions.
@deffn {Scheme Procedure} eof-object
@deffnx {Scheme Procedure} eof-object? obj
-These procedures are identical to the ones provided by the
-@code{(rnrs io ports (6))} library. @xref{R6RS I/O Ports}, for
-documentation.
+These procedures are identical to the ones provided by the @code{(rnrs
+io ports (6))} library. @xref{rnrs io ports}, for documentation.
@end deffn
@deffn {Scheme Procedure} input-port? obj
@@ -1474,8 +2006,8 @@ library. @xref{File Ports}, for documentation.
@deffn {Scheme Procedure} close-input-port input-port
@deffnx {Scheme Procedure} close-output-port output-port
-These procedures are identical to the ones provided by Guile's core
-library. @xref{Closing}, for documentation.
+Closes the given @var{input-port} or @var{output-port}. These are
+legacy interfaces; just use @code{close-port}.
@end deffn
@deffn {Scheme Procedure} peek-char
@@ -1483,7 +2015,7 @@ library. @xref{Closing}, for documentation.
@deffnx {Scheme Procedure} read-char
@deffnx {Scheme Procedure} read-char textual-input-port
These procedures are identical to the ones provided by Guile's core
-library. @xref{Reading}, for documentation.
+library. @xref{Venerable Port Interfaces}, for documentation.
@end deffn
@deffn {Scheme Procedure} read
@@ -1500,8 +2032,9 @@ This procedure is identical to the one provided by Guile's core library.
@deffnx {Scheme Procedure} write obj textual-output-port
@deffnx {Scheme Procedure} write-char char
@deffnx {Scheme Procedure} write-char char textual-output-port
-These procedures are identical to the ones provided by Guile's core
-library. @xref{Writing}, for documentation.
+These procedures are identical to the ones provided by Guile's core
+library. @xref{Venerable Port Interfaces}, and @xref{Scheme Write}, for
+documentation.
@end deffn
@node rnrs files
diff --git a/doc/ref/repl-modules.texi b/doc/ref/repl-modules.texi
index 700867272..e20393ba2 100644
--- a/doc/ref/repl-modules.texi
+++ b/doc/ref/repl-modules.texi
@@ -108,6 +108,8 @@ history-file yes Use history file.
history-length 200 History length.
bounce-parens 500 Time (ms) to show matching opening parenthesis
(0 = off).
+bracketed-paste yes Disable interpretation of control characters
+ in pastes.
@end smalllisp
The readline options interface can only be used @emph{after} loading
diff --git a/doc/ref/scheme-ideas.texi b/doc/ref/scheme-ideas.texi
index 15cf6640d..d18d1012b 100644
--- a/doc/ref/scheme-ideas.texi
+++ b/doc/ref/scheme-ideas.texi
@@ -484,7 +484,7 @@ moved to @ref{Curried Definitions}
(It could be argued that the alternative @code{define} forms are rather
confusing, especially for newcomers to the Scheme language, as they hide
both the role of @code{lambda} and the fact that procedures are values
-that are stored in variables in the some way as any other kind of value.
+that are stored in variables in the same way as any other kind of value.
On the other hand, they are very convenient, and they are also a good
example of another of Scheme's powerful features: the ability to specify
arbitrary syntactic transformations at run time, which can be applied to
diff --git a/doc/ref/scheme-intro.texi b/doc/ref/scheme-intro.texi
index 57aa18f69..b8a502475 100644
--- a/doc/ref/scheme-intro.texi
+++ b/doc/ref/scheme-intro.texi
@@ -10,7 +10,7 @@
Guile's core language is Scheme, which is specified and described in the
series of reports known as @dfn{RnRS}. @dfn{RnRS} is shorthand for the
@iftex
-@dfn{Revised$^n$ Report on the Algorithmic Language Scheme}.
+@dfn{Revised@math{^n} Report on the Algorithmic Language Scheme}.
@end iftex
@ifnottex
@dfn{Revised^n Report on the Algorithmic Language Scheme}.
diff --git a/doc/ref/scheme-scripts.texi b/doc/ref/scheme-scripts.texi
index 7552dba33..221c8ba20 100644
--- a/doc/ref/scheme-scripts.texi
+++ b/doc/ref/scheme-scripts.texi
@@ -293,6 +293,11 @@ and exit.
Load the file @file{/u/jimb/ex4}, and then call the function
@code{main}, passing it the list @code{("/u/jimb/ex4" "foo")}.
+@item guile -e '(ex4)' -s /u/jimb/ex4.scm foo
+Load the file @file{/u/jimb/ex4.scm}, and then call the function
+@code{main} from the module '(ex4)', passing it the list
+@code{("/u/jimb/ex4" "foo")}.
+
@item guile -l first -ds -l last -s script
Load the files @file{first}, @file{script}, and @file{last}, in that
order. The @code{-ds} switch says when to process the @code{-s}
@@ -369,6 +374,7 @@ Suppose that we now want to write a script which computes the
@code{(choose @var{n} @var{m})} is the number of distinct subsets
containing @var{n} objects each. It's easy to write @code{choose} given
@code{fact}, so we might write the script this way:
+
@example
#!/usr/local/bin/guile \
-l fact -e main -s
@@ -402,6 +408,79 @@ $ ./choose 50 100
100891344545564193334812497256
@end example
+To call a specific procedure from a given module, we can use the special
+form @code{(@@ (@var{module}) @var{procedure})}:
+
+@example
+#!/usr/local/bin/guile \
+-l fact -e (@@ (fac) main) -s
+!#
+(define-module (fac)
+ #:export (main))
+
+(define (choose n m)
+ (/ (fact m) (* (fact (- m n)) (fact n))))
+
+(define (main args)
+ (let ((n (string->number (cadr args)))
+ (m (string->number (caddr args))))
+ (display (choose n m))
+ (newline)))
+@end example
+
+We can use @code{@@@@} to invoke non-exported procedures. For exported
+procedures, we can simplify this call with the shorthand
+@code{(@var{module})}:
+
+@example
+#!/usr/local/bin/guile \
+-l fact -e (fac) -s
+!#
+(define-module (fac)
+ #:export (main))
+
+(define (choose n m)
+ (/ (fact m) (* (fact (- m n)) (fact n))))
+
+(define (main args)
+ (let ((n (string->number (cadr args)))
+ (m (string->number (caddr args))))
+ (display (choose n m))
+ (newline)))
+@end example
+
+For maximum portability, we can instead use the shell to execute
+@command{guile} with specified command line arguments. Here we need to
+take care to quote the command arguments correctly:
+
+@example
+#!/usr/bin/env sh
+exec guile -l fact -e '(@@ (fac) main)' -s "$0" "$@@"
+!#
+(define-module (fac)
+ #:export (main))
+
+(define (choose n m)
+ (/ (fact m) (* (fact (- m n)) (fact n))))
+
+(define (main args)
+ (let ((n (string->number (cadr args)))
+ (m (string->number (caddr args))))
+ (display (choose n m))
+ (newline)))
+@end example
+
+Finally, seasoned scripters are probably missing a mention of
+subprocesses. In Bash, for example, most shell scripts run other
+programs like @code{sed} or the like to do the actual work.
+
+In Guile it's often possible get everything done within Guile itself, so
+do give that a try first. But if you just need to run a program and
+wait for it to finish, use @code{system*}. If you need to run a
+sub-program and capture its output, or give it input, use
+@code{open-pipe}. @xref{Processes}, and @xref{Pipes}, for more
+information.
+
@c Local Variables:
@c TeX-master: "guile.texi"
diff --git a/doc/ref/scheme-using.texi b/doc/ref/scheme-using.texi
index 4422c1863..ac265fcca 100644
--- a/doc/ref/scheme-using.texi
+++ b/doc/ref/scheme-using.texi
@@ -294,8 +294,12 @@ Disassemble a file.
Time execution.
@end deffn
-@deffn {REPL Command} profile exp
-Profile execution.
+@deffn {REPL Command} profile exp [#:hz hz=100] @
+ [#:count-calls? count-calls?=#f] [#:display-style display-style=list]
+Profile execution of an expression. This command compiled @var{exp} and
+then runs it within the statprof profiler, passing all keyword options
+to the @code{statprof} procedure. For more on statprof and on the the
+options available to this command, @xref{Statprof}.
@end deffn
@deffn {REPL Command} trace exp [#:width w] [#:max-indent i]
@@ -341,10 +345,6 @@ Show the selected frame. With an argument, select a frame by index,
then show it.
@end deffn
-@deffn {REPL Command} procedure
-Print the procedure for the selected frame.
-@end deffn
-
@deffn {REPL Command} locals
Show local variables.
@@ -793,7 +793,7 @@ packages will be
Note that a @code{.go} file will only be loaded in preference to a
@code{.scm} file if it is newer. For that reason, you should install
-your Scheme files first, and your compiled files second. @code{Load
+your Scheme files first, and your compiled files second. @xref{Load
Paths}, for more on the loading process.
Finally, although this section is only about Scheme, sometimes you need
diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index c890d7dd1..3d4415629 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000-2004, 2006, 2007-2014
+@c Copyright (C) 1996, 1997, 2000-2004, 2006, 2007-2014, 2017
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -150,6 +150,7 @@ The Guile core has the following features,
@example
guile
guile-2 ;; starting from Guile 2.x
+guile-2.2 ;; starting from Guile 2.2
r5rs
srfi-0
srfi-4
@@ -1823,8 +1824,8 @@ procedures easier. It is documented in @xref{Multiple Values}.
This SRFI is a syntax for defining new record types and creating
predicate, constructor, and field getter and setter functions. It is
-documented in the ``Compound Data Types'' section of the manual
-(@pxref{SRFI-9 Records}).
+documented in the ``Data Types'' section of the manual (@pxref{SRFI-9
+Records}).
@node SRFI-10
@@ -1834,9 +1835,9 @@ documented in the ``Compound Data Types'' section of the manual
@cindex hash-comma
@cindex #,()
This SRFI implements a reader extension @code{#,()} called hash-comma.
-It allows the reader to give new kinds of objects, for use both in
-data and as constants or literals in source code. This feature is
-available with
+It allows the reader to give new kinds of objects, for use both in data
+and as constants or literals in source code. This feature is available
+with
@example
(use-modules (srfi srfi-10))
@@ -1894,73 +1895,46 @@ addition,
(display #,(sum 123 456)) @print{} 579
@end example
-A typical use for @nicode{#,()} is to get a read syntax for objects
-which don't otherwise have one. For example, the following allows a
-hash table to be given literally, with tags and values, ready for fast
-lookup.
-
-@example
-(define-reader-ctor 'hash
- (lambda elems
- (let ((table (make-hash-table)))
- (for-each (lambda (elem)
- (apply hash-set! table elem))
- elems)
- table)))
-
-(define (animal->family animal)
- (hash-ref '#,(hash ("tiger" "cat")
- ("lion" "cat")
- ("wolf" "dog"))
- animal))
-
-(animal->family "lion") @result{} "cat"
-@end example
-
-Or for example the following is a syntax for a compiled regular
-expression (@pxref{Regular Expressions}).
-
-@example
-(use-modules (ice-9 regex))
-
-(define-reader-ctor 'regexp make-regexp)
-
-(define (extract-angs str)
- (let ((match (regexp-exec '#,(regexp "<([A-Z0-9]+)>") str)))
- (and match
- (match:substring match 1))))
-
-(extract-angs "foo quux") @result{} "BAR"
-@end example
-
-@sp 1
-@nicode{#,()} is somewhat similar to @code{define-macro}
-(@pxref{Macros}) in that handler code is run to produce a result, but
-@nicode{#,()} operates at the read stage, so it can appear in data for
-@code{read} (@pxref{Scheme Read}), not just in code to be executed.
-
-Because @nicode{#,()} is handled at read-time it has no direct access
-to variables etc. A symbol in the arguments is just a symbol, not a
-variable reference. The arguments are essentially constants, though
-the handler procedure can use them in any complicated way it might
-want.
-
Once @code{(srfi srfi-10)} has loaded, @nicode{#,()} is available
globally, there's no need to use @code{(srfi srfi-10)} in later
modules. Similarly the tags registered are global and can be used
anywhere once registered.
-There's no attempt to record what previous @nicode{#,()} forms have
-been seen, if two identical forms occur then two calls are made to the
-handler procedure. The handler might like to maintain a cache or
-similar to avoid making copies of large objects, depending on expected
-usage.
+We do not recommend @nicode{#,()} reader extensions, however, and for
+three reasons.
-In code the best uses of @nicode{#,()} are generally when there's a
-lot of objects of a particular kind as literals or constants. If
-there's just a few then some local variables and initializers are
-fine, but that becomes tedious and error prone when there's a lot, and
-the anonymous and compact syntax of @nicode{#,()} is much better.
+First of all, this SRFI is not modular: the tag is matched by name, not
+as an identifier within a scope. Defining a reader extension in one
+part of a program can thus affect unrelated parts of a program because
+the tag is not scoped.
+
+Secondly, reader extensions can be hard to manage from a time
+perspective: when does the reader extension take effect? @xref{Eval
+When}, for more discussion.
+
+Finally, reader extensions can easily produce objects that can't be
+reified to an object file by the compiler. For example if you define a
+reader extension that makes a hash table (@pxref{Hash Tables}), then it
+will work fine when run with the interpreter, and you think you have a
+neat hack. But then if you try to compile your program, after wrangling
+with the @code{eval-when} concerns mentioned above, the compiler will
+carp that it doesn't know how to serialize a hash table to disk.
+
+In the specific case of hash tables, it would be possible for Guile to
+know how to pack hash tables into compiled files, but this doesn't work
+in general. What if the object you produce is an instance of a record
+type? Guile would then have to serialize the record type to disk too,
+and then what happens if the program independently loads the code that
+defines the record type? Does it define the same type or a different
+type? Guile's record types are nominal, not structural, so the answer
+is not clear at all.
+
+For all of these reasons we recommend macros over reader extensions.
+Macros fulfill many of the same needs while preserving modular
+composition, and their interaction with @code{eval-when} is well-known.
+If you need brevity, instead use @code{read-hash-extend} and make your
+reader extension expand to a macro invocation. In that way we preserve
+scoping as much as possible. @xref{Reader Extensions}.
@node SRFI-11
@@ -2087,14 +2061,12 @@ library. The functions and variables described here are provided by
(use-modules (srfi srfi-18))
@end example
-As a general rule, the data types and functions in this SRFI-18
-implementation are compatible with the types and functions in Guile's
-core threading code. For example, mutexes created with the SRFI-18
-@code{make-mutex} function can be passed to the built-in Guile
-function @code{lock-mutex} (@pxref{Mutexes and Condition Variables}),
-and mutexes created with the built-in Guile function @code{make-mutex}
-can be passed to the SRFI-18 function @code{mutex-lock!}. Cases in
-which this does not hold true are noted in the following sections.
+SRFI-18 defines facilities for threads, mutexes, condition variables,
+time, and exception handling. Because these facilities are at a higher
+level than Guile's primitives, they are implemented as a layer on top of
+what Guile provides. In particular this means that a Guile mutex is not
+a SRFI-18 mutex, and a Guile thread is not a SRFI-18 thread, and so on.
+Guile provides a set of primitives and SRFI-18 is one of the systems built in terms of those primitives.
@menu
* SRFI-18 Threads:: Executing code
@@ -2112,8 +2084,10 @@ Guile's built-in thread functions. First, a thread created by SRFI-18
@code{make-thread} begins in a blocked state and will not start
execution until @code{thread-start!} is called on it. Second, SRFI-18
threads are constructed with a top-level exception handler that
-captures any exceptions that are thrown on thread exit. In all other
-regards, SRFI-18 threads are identical to normal Guile threads.
+captures any exceptions that are thrown on thread exit.
+
+SRFI-18 threads are disjoint from Guile's primitive threads.
+@xref{Threads}, for more on Guile's primitive facility.
@defun current-thread
Returns the thread that called this function. This is the same
@@ -2206,41 +2180,28 @@ original exception can be retrieved using
@node SRFI-18 Mutexes
@subsubsection SRFI-18 Mutexes
-The behavior of Guile's built-in mutexes is parameterized via a set of
-flags passed to the @code{make-mutex} procedure in the core
-(@pxref{Mutexes and Condition Variables}). To satisfy the requirements
-for mutexes specified by SRFI-18, the @code{make-mutex} procedure
-described below sets the following flags:
-@itemize @bullet
-@item
-@code{recursive}: the mutex can be locked recursively
-@item
-@code{unchecked-unlock}: attempts to unlock a mutex that is already
-unlocked will not raise an exception
-@item
-@code{allow-external-unlock}: the mutex can be unlocked by any thread,
-not just the thread that locked it originally
-@end itemize
+SRFI-18 mutexes are disjoint from Guile's primitive mutexes.
+@xref{Mutexes and Condition Variables}, for more on Guile's primitive
+facility.
@defun make-mutex [name]
-Returns a new mutex, optionally assigning it the object name
-@var{name}, which may be any Scheme object. The returned mutex will be
-created with the configuration described above. Note that the name
-@code{make-mutex} conflicts with Guile core function @code{make-mutex}.
-Applications wanting to use both of these functions will need to refer
-to them by different names.
+Returns a new mutex, optionally assigning it the object name @var{name},
+which may be any Scheme object. The returned mutex will be created with
+the configuration described above.
@end defun
@defun mutex-name mutex
-Returns the name assigned to @var{mutex} at the time of its creation,
-or @code{#f} if it was not given a name.
+Returns the name assigned to @var{mutex} at the time of its creation, or
+@code{#f} if it was not given a name.
@end defun
@defun mutex-specific mutex
-@defunx mutex-specific-set! mutex obj
-Get or set the ``object-specific'' property of @var{mutex}. In Guile's
-implementation of SRFI-18, this value is stored as an object property,
-and will be @code{#f} if not set.
+Return the ``object-specific'' property of @var{mutex}, or @code{#f} if
+none is set.
+@end defun
+
+@defun mutex-specific-set! mutex obj
+Set the ``object-specific'' property of @var{mutex}.
@end defun
@defun mutex-state mutex
@@ -2248,8 +2209,8 @@ Returns information about the state of @var{mutex}. Possible values
are:
@itemize @bullet
@item
-thread @code{T}: the mutex is in the locked/owned state and thread T
-is the owner of the mutex
+thread @var{t}: the mutex is in the locked/owned state and thread
+@var{t} is the owner of the mutex
@item
symbol @code{not-owned}: the mutex is in the locked/not-owned state
@item
@@ -2263,17 +2224,14 @@ unlocked/not-abandoned state
@defun mutex-lock! mutex [timeout [thread]]
Lock @var{mutex}, optionally specifying a time object @var{timeout}
after which to abort the lock attempt and a thread @var{thread} giving
-a new owner for @var{mutex} different than the current thread. This
-procedure has the same behavior as the @code{lock-mutex} procedure in
-the core library.
+a new owner for @var{mutex} different than the current thread.
@end defun
@defun mutex-unlock! mutex [condition-variable [timeout]]
Unlock @var{mutex}, optionally specifying a condition variable
@var{condition-variable} on which to wait, either indefinitely or,
optionally, until the time object @var{timeout} has passed, to be
-signalled. This procedure has the same behavior as the
-@code{unlock-mutex} procedure in the core library.
+signalled.
@end defun
@@ -2282,20 +2240,20 @@ signalled. This procedure has the same behavior as the
SRFI-18 does not specify a ``wait'' function for condition variables.
Waiting on a condition variable can be simulated using the SRFI-18
-@code{mutex-unlock!} function described in the previous section, or
-Guile's built-in @code{wait-condition-variable} procedure can be used.
+@code{mutex-unlock!} function described in the previous section.
+
+SRFI-18 condition variables are disjoint from Guile's primitive
+condition variables. @xref{Mutexes and Condition Variables}, for more
+on Guile's primitive facility.
@defun condition-variable? obj
Returns @code{#t} if @var{obj} is a condition variable, @code{#f}
-otherwise. This is the same procedure as the same-named built-in
-procedure
-(@pxref{Mutexes and Condition Variables, @code{condition-variable?}}).
+otherwise.
@end defun
@defun make-condition-variable [name]
Returns a new condition variable, optionally assigning it the object
-name @var{name}, which may be any Scheme object. This procedure
-replaces a procedure of the same name in the core library.
+name @var{name}, which may be any Scheme object.
@end defun
@defun condition-variable-name condition-variable
@@ -2304,21 +2262,19 @@ creation, or @code{#f} if it was not given a name.
@end defun
@defun condition-variable-specific condition-variable
-@defunx condition-variable-specific-set! condition-variable obj
-Get or set the ``object-specific'' property of
-@var{condition-variable}. In Guile's implementation of SRFI-18, this
-value is stored as an object property, and will be @code{#f} if not
-set.
+Return the ``object-specific'' property of @var{condition-variable}, or
+@code{#f} if none is set.
+@end defun
+
+@defun condition-variable-specific-set! condition-variable obj
+Set the ``object-specific'' property of @var{condition-variable}.
@end defun
@defun condition-variable-signal! condition-variable
@defunx condition-variable-broadcast! condition-variable
Wake up one thread that is waiting for @var{condition-variable}, in
the case of @code{condition-variable-signal!}, or all threads waiting
-for it, in the case of @code{condition-variable-broadcast!}. The
-behavior of these procedures is equivalent to that of the procedures
-@code{signal-condition-variable} and
-@code{broadcast-condition-variable} in the core library.
+for it, in the case of @code{condition-variable-broadcast!}.
@end defun
@@ -2427,17 +2383,6 @@ functions and variables described here are provided by
(use-modules (srfi srfi-19))
@end example
-@strong{Caution}: The current code in this module incorrectly extends
-the Gregorian calendar leap year rule back prior to the introduction
-of those reforms in 1582 (or the appropriate year in various
-countries). The Julian calendar was used prior to 1582, and there
-were 10 days skipped for the reform, but the code doesn't implement
-that.
-
-This will be fixed some time. Until then calculations for 1583
-onwards are correct, but prior to that any day/month/year and day of
-the week calculations are wrong.
-
@menu
* SRFI-19 Introduction::
* SRFI-19 Time::
@@ -2637,6 +2582,16 @@ The fields are year, month, day, hour, minute, second, nanoseconds and
timezone. A date object is immutable, its fields can be read but they
cannot be modified once the object is created.
+Historically, the Gregorian calendar was only used from the latter part
+of the year 1582 onwards, and not until even later in many countries.
+Prior to that most countries used the Julian calendar. SRFI-19 does
+not deal with the Julian calendar at all, and so does not reflect this
+historical calendar reform. Instead it projects the Gregorian calendar
+back proleptically as far as necessary. When dealing with historical
+data, especially prior to the British Empire's adoption of the Gregorian
+calendar in 1752, one should be mindful of which calendar is used in
+each context, and apply non-SRFI-19 facilities to convert where necessary.
+
@defun date? obj
Return @code{#t} if @var{obj} is a date object, or @code{#f} if not.
@end defun
@@ -3302,8 +3257,8 @@ Insert a newline.
Insert a tilde.
@end table
-This procedure is the same as calling @code{simple-format} (@pxref{Writing})
-with @code{#f} as the destination.
+This procedure is the same as calling @code{simple-format}
+(@pxref{Simple Output}) with @code{#f} as the destination.
@end deffn
@node SRFI-30
diff --git a/doc/ref/statprof.texi b/doc/ref/statprof.texi
index 5b99fb6b8..850c5bd2e 100644
--- a/doc/ref/statprof.texi
+++ b/doc/ref/statprof.texi
@@ -1,225 +1,121 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 2013, 2015 Free Software Foundation, Inc.
+@c Copyright (C) 2013, 2015, 2017 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Statprof
@section Statprof
-@code{(statprof)} is a fairly simple statistical profiler for Guile.
+Statprof is a statistical profiler for Guile.
A simple use of statprof would look like this:
-@example
-(statprof-reset 0 50000 #t)
-(statprof-start)
-(do-something)
-(statprof-stop)
-(statprof-display)
+@example
+(use-modules (statprof))
+(statprof (lambda ()
+ (map 1+ (iota 1000000))
+ #f))
@end example
-This would reset statprof, clearing all accumulated statistics, then
-start profiling, run some code, stop profiling, and finally display a
-gprof flat-style table of statistics which will look something like
-this:
+This would run the thunk with statistical profiling, finally displaying
+a flat table of statistics which could look something like this:
-@example
- % cumulative self self total
- time seconds seconds calls ms/call ms/call name
- 35.29 0.23 0.23 2002 0.11 0.11 -
- 23.53 0.15 0.15 2001 0.08 0.08 positive?
- 23.53 0.15 0.15 2000 0.08 0.08 +
- 11.76 0.23 0.08 2000 0.04 0.11 do-nothing
- 5.88 0.64 0.04 2001 0.02 0.32 loop
- 0.00 0.15 0.00 1 0.00 150.59 do-something
- ...
+@example
+% cumulative self
+time seconds seconds procedure
+ 57.14 39769.73 0.07 ice-9/boot-9.scm:249:5:map1
+ 28.57 0.04 0.04 ice-9/boot-9.scm:1165:0:iota
+ 14.29 0.02 0.02 1+
+ 0.00 0.12 0.00 :2:10
+---
+Sample count: 7
+Total time: 0.123490713 seconds (0.201983993 seconds in GC)
@end example
All of the numerical data with the exception of the calls column is
statistically approximate. In the following column descriptions, and in
-all of statprof, "time" refers to execution time (both user and system),
-not wall clock time.
+all of statprof, ``time'' refers to execution time (both user and
+system), not wall clock time.
-@table @asis
-@item % time
-The percent of the time spent inside the procedure itself (not counting
-children).
+The @code{% time} column indicates the percentage of the run-time time
+spent inside the procedure itself (not counting children). It is
+calculated as @code{self seconds}, measuring the amount of time spent in
+the procedure, divided by the total run-time.
-@item cumulative seconds
-The total number of seconds spent in the procedure, including children.
+@code{cumulative seconds} also counts time spent in children of a
+function. For recursive functions, this can exceed the total time, as
+in our example above, because each activation on the stack adds to the
+cumulative time.
-@item self seconds
-The total number of seconds spent in the procedure itself (not counting
-children).
+Finally, the GC time measures the time spent in the garbage collector.
+On systems with multiple cores, this time can be larger than the run
+time, because it counts time spent in all threads, and will run the
+``marking'' phase of GC in parallel. If GC time is a significant
+fraction of the run time, that means that most time in your program is
+spent allocating objects and cleaning up after those allocations. To
+speed up your program, one good place to start would be to look at how
+to reduce the allocation rate.
-@item calls
-The total number of times the procedure was called.
+Statprof's main mode of operation is as a statistical profiler. However
+statprof can also run in a ``precise'' mode as well. Pass the
+@code{#:count-calls? #t} keyword argument to @code{statprof} to record
+all calls:
-@item self ms/call
-The average time taken by the procedure itself on each call, in ms.
+@example
+(use-modules (statprof))
+(statprof (lambda ()
+ (map 1+ (iota 1000000))
+ #f)
+ #:count-calls? #t)
+@end example
-@item total ms/call
-The average time taken by each call to the procedure, including time
-spent in child functions.
+The result has an additional @code{calls} column:
-@item name
-The name of the procedure.
+@example
+% cumulative self
+time seconds seconds calls procedure
+ 82.26 0.73 0.73 1000000 1+
+ 11.29 420925.80 0.10 1000001 ice-9/boot-9.scm:249:5:map1
+ 4.84 0.06 0.04 1 ice-9/boot-9.scm:1165:0:iota
+[...]
+---
+Sample count: 62
+Total time: 0.893098065 seconds (1.222796536 seconds in GC)
+@end example
-@end table
+As you can see, the profile is perturbed: @code{1+} ends up on top,
+whereas it was not marked as hot in the earlier profile. This is
+because the overhead of call-counting unfairly penalizes calls. Still,
+this precise mode can be useful at times to do algorithmic optimizations
+based on the precise call counts.
-The profiler uses @code{eq?} and the procedure object itself to identify
-the procedures, so it won't confuse different procedures with the same
-name. They will show up as two different rows in the output.
+@heading Implementation notes
-Right now the profiler is quite simplistic. I cannot provide call-graphs
-or other higher level information. What you see in the table is pretty
-much all there is. Patches are welcome :-)
-
-@section Implementation notes
The profiler works by setting the unix profiling signal
@code{ITIMER_PROF} to go off after the interval you define in the call
-to @code{statprof-reset}. When the signal fires, a sampling routine is
-run which looks at the current procedure that's executing, and then
-crawls up the stack, and for each procedure encountered, increments that
-procedure's sample count. Note that if a procedure is encountered
-multiple times on a given stack, it is only counted once. After the
-sampling is complete, the profiler resets profiling timer to fire again
-after the appropriate interval.
+to @code{statprof-reset}. When the signal fires, a sampling routine
+runs which crawls up the stack, recording all instruction pointers into
+a buffer. After the sample is complete, the profiler resets profiling
+timer to fire again after the appropriate interval.
-Meanwhile, the profiler keeps track, via @code{get-internal-run-time},
-how much CPU time (system and user -- which is also what
-@code{ITIMER_PROF} tracks), has elapsed while code has been executing
-within a statprof-start/stop block.
+Later, when profiling stops, that log buffer is analyzed to produce the
+``self seconds'' and ``cumulative seconds'' statistics. A procedure at
+the top of the stack counts toward ``self'' samples, and everything on
+the stack counts towards ``cumulative'' samples.
-The profiler also tries to avoid counting or timing its own code as much
-as possible.
+While the profiler is running it measures how much CPU time (system and
+user -- which is also what @code{ITIMER_PROF} tracks) has elapsed while
+code has been executing within the profiler. Only run time counts
+towards the profile, not wall-clock time. For example, sleeping and
+waiting for input or output do not cause the timer clock to advance.
-@section Usage
-@anchor{statprof statprof-active?}@defun statprof-active?
-Returns @code{#t} if @code{statprof-start} has been called more times
-than @code{statprof-stop}, @code{#f} otherwise.
+@heading Usage
-@end defun
-
-@anchor{statprof statprof-start}@defun statprof-start
-Start the profiler.@code{}
-
-@end defun
-
-@anchor{statprof statprof-stop}@defun statprof-stop
-Stop the profiler.@code{}
-
-@end defun
-
-@anchor{statprof statprof-reset}@defun statprof-reset sample-seconds sample-microseconds count-calls? [full-stacks?]
-Reset the statprof sampler interval to @var{sample-seconds} and
-@var{sample-microseconds}. If @var{count-calls?} is true, arrange to
-instrument procedure calls as well as collecting statistical profiling
-data. If @var{full-stacks?} is true, collect all sampled stacks into a
-list for later analysis.
-
-Enables traps and debugging as necessary.
-
-@end defun
-
-@anchor{statprof statprof-accumulated-time}@defun statprof-accumulated-time
-Returns the time accumulated during the last statprof run.@code{}
-
-@end defun
-
-@anchor{statprof statprof-sample-count}@defun statprof-sample-count
-Returns the number of samples taken during the last statprof run.@code{}
-
-@end defun
-
-@anchor{statprof statprof-fold-call-data}@defun statprof-fold-call-data proc init
-Fold @var{proc} over the call-data accumulated by statprof. Cannot be
-called while statprof is active. @var{proc} should take two arguments,
-@code{(@var{call-data} @var{prior-result})}.
-
-Note that a given proc-name may appear multiple times, but if it does,
-it represents different functions with the same name.
-
-@end defun
-
-@anchor{statprof statprof-proc-call-data}@defun statprof-proc-call-data proc
-Returns the call-data associated with @var{proc}, or @code{#f} if none
-is available.
-
-@end defun
-
-@anchor{statprof statprof-call-data-name}@defun statprof-call-data-name cd
-@end defun
-
-@anchor{statprof statprof-call-data-calls}@defun statprof-call-data-calls cd
-@end defun
-
-@anchor{statprof statprof-call-data-cum-samples}@defun statprof-call-data-cum-samples cd
-@end defun
-
-@anchor{statprof statprof-call-data-self-samples}@defun statprof-call-data-self-samples cd
-@end defun
-
-@anchor{statprof statprof-call-data->stats}@defun statprof-call-data->stats call-data
-Returns an object of type @code{statprof-stats}.
-
-@end defun
-
-@anchor{statprof statprof-stats-proc-name}@defun statprof-stats-proc-name stats
-@end defun
-
-@anchor{statprof statprof-stats-%-time-in-proc}@defun statprof-stats-%-time-in-proc stats
-@end defun
-
-@anchor{statprof statprof-stats-cum-secs-in-proc}@defun statprof-stats-cum-secs-in-proc stats
-@end defun
-
-@anchor{statprof statprof-stats-self-secs-in-proc}@defun statprof-stats-self-secs-in-proc stats
-@end defun
-
-@anchor{statprof statprof-stats-calls}@defun statprof-stats-calls stats
-@end defun
-
-@anchor{statprof statprof-stats-self-secs-per-call}@defun statprof-stats-self-secs-per-call stats
-@end defun
-
-@anchor{statprof statprof-stats-cum-secs-per-call}@defun statprof-stats-cum-secs-per-call stats
-@end defun
-
-@anchor{statprof statprof-display}@defun statprof-display . _
-Displays a gprof-like summary of the statistics collected. Unless an
-optional @var{port} argument is passed, uses the current output port.
-
-@end defun
-
-@anchor{statprof statprof-display-anomolies}@defun statprof-display-anomolies
-A sanity check that attempts to detect anomolies in statprof's
-statistics.@code{}
-
-@end defun
-
-@anchor{statprof statprof-fetch-stacks}@defun statprof-fetch-stacks
-Returns a list of stacks, as they were captured since the last call to
-@code{statprof-reset}.
-
-Note that stacks are only collected if the @var{full-stacks?} argument
-to @code{statprof-reset} is true.
-
-@end defun
-
-@anchor{statprof statprof-fetch-call-tree}@defun statprof-fetch-call-tree
-@verbatim
-Return a call tree for the previous statprof run.
-
-The return value is a list of nodes, each of which is of the type:
-@@code
- node ::= (@@var@{proc@} @@var@{count@} . @@var@{nodes@})
-@@end code
-@end verbatim
-
-@end defun
-
-@anchor{statprof statprof}@defun statprof thunk [#:loop] [#:hz] [#:count-calls?] [#:full-stacks?]
+@deffn {Scheme Procedure} statprof thunk @
+ [#:loop loop=1] [#:hz hz=100] @
+ [#:port port=(current-output-port)] @
+ [#:count-calls? count-calls?=#f] @
+ [#:display-style display-style='flat]
Profile the execution of @var{thunk}, and return its return values.
The stack will be sampled @var{hz} times per second, and the thunk
@@ -228,57 +124,131 @@ itself will be called @var{loop} times.
If @var{count-calls?} is true, all procedure calls will be recorded.
This operation is somewhat expensive.
-If @var{full-stacks?} is true, at each sample, statprof will store away
-the whole call tree, for later analysis. Use
-@code{statprof-fetch-stacks} or @code{statprof-fetch-call-tree} to
-retrieve the last-stored stacks.
+After the @var{thunk} has been profiled, print out a profile to
+@var{port}. If @var{display-style} is @code{flat}, the results will be
+printed as a flat profile. Otherwise if @var{display-style} is
+@code{tree}, print the results as a tree profile.
-@end defun
+Note that @code{statprof} requires a working profiling timer. Some
+platforms do not support profiling timers. @code{(provided?
+'ITIMER_PROF)} can be used to check for support of profiling timers.
+@end deffn
-@anchor{statprof with-statprof}@defspec with-statprof args
-Profile the expressions in the body, and return the body's return
-value.
+Profiling can also be enabled and disabled manually.
-Keyword arguments:
+@deffn {Scheme Procedure} statprof-active?
+Returns @code{#t} if @code{statprof-start} has been called more times
+than @code{statprof-stop}, @code{#f} otherwise.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-start
+@deffnx {Scheme Procedure} statprof-stop
+Start or stop the profiler.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-reset sample-seconds sample-microseconds count-calls?
+Reset the profiling sample interval to @var{sample-seconds} and
+@var{sample-microseconds}. If @var{count-calls?} is true, arrange to
+instrument procedure calls as well as collecting statistical profiling
+data.
+@end deffn
+
+If you use the manual @code{statprof-start}/@code{statprof-stop}
+interface, an implicit statprof state will persist starting from the
+last call to @code{statprof-reset}, or the first call to
+@code{statprof-start}. There are a number of accessors to fetch
+statistics from this implicit state.
+
+@deffn {Scheme Procedure} statprof-accumulated-time
+Returns the time accumulated during the last statprof run.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-sample-count
+Returns the number of samples taken during the last statprof run.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-fold-call-data proc init
+Fold @var{proc} over the call-data accumulated by statprof. This
+procedure cannot be called while statprof is active.
+
+@var{proc} will be called with arguments, @var{call-data} and
+@var{prior-result}.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-proc-call-data proc
+Returns the call-data associated with @var{proc}, or @code{#f} if none
+is available.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-call-data-name cd
+@deffnx {Scheme Procedure} statprof-call-data-calls cd
+@deffnx {Scheme Procedure} statprof-call-data-cum-samples cd
+@deffnx {Scheme Procedure} statprof-call-data-self-samples cd
+Accessors for the fields in a statprof call-data object.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-call-data->stats call-data
+Returns an object of type @code{statprof-stats}.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-stats-proc-name stats
+@deffnx {Scheme Procedure} statprof-stats-%-time-in-proc stats
+@deffnx {Scheme Procedure} statprof-stats-cum-secs-in-proc stats
+@deffnx {Scheme Procedure} statprof-stats-self-secs-in-proc stats
+@deffnx {Scheme Procedure} statprof-stats-calls stats
+@deffnx {Scheme Procedure} statprof-stats-self-secs-per-call stats
+@deffnx {Scheme Procedure} statprof-stats-cum-secs-per-call stats
+Accessors for the fields in a @code{statprof-stats} object.
+@end deffn
+
+@deffn {Scheme Procedure} statprof-display @
+ [port=(current-output-port)] [#:style style=flat]
+Displays a summary of the statistics collected. Possible values for
+@var{style} include:
@table @code
-@item #:loop
-Execute the body @var{loop} number of times, or @code{#f} for no looping
-
-default: @code{#f}
-
-@item #:hz
-Sampling rate
-
-default: @code{20}
-
-@item #:count-calls?
-Whether to instrument each function call (expensive)
-
-default: @code{#f}
-
-@item #:full-stacks?
-Whether to collect away all sampled stacks into a list
-
-default: @code{#f}
-
+@item flat
+Display a traditional gprof-style flat profile.
+@item anomalies
+Find statistical anomalies in the data.
+@item tree
+Display a tree profile.
@end table
+@end deffn
-@end defspec
+@deffn {Scheme Procedure} statprof-fetch-stacks
+Returns a list of stacks, as they were captured since the last call to
+@code{statprof-reset}.
+@end deffn
-@anchor{statprof gcprof}@defun gcprof thunk [#:loop] [#:full-stacks?]
-Do an allocation profile of the execution of @var{thunk}.
+@deffn {Scheme Procedure} statprof-fetch-call-tree [#:precise precise?=#f]
+@verbatim
+Return a call tree for the previous statprof run.
-The stack will be sampled soon after every garbage collection, yielding
-an approximate idea of what is causing allocation in your program.
+The return value is a list of nodes. A node is a list of the form:
+@code
+ node ::= (@var{proc} @var{count} . @var{nodes})
+@end code
+
+The @var{proc} is a printable representation of a procedure, as a
+string. If @var{precise?} is false, which is the default, then a node
+corresponds to a procedure invocation. If it is true, then a node
+corresponds to a return point in a procedure. Passing @code{#:precise?
+#t} allows a user to distinguish different source lines in a procedure,
+but usually it is too much detail, so it is off by default.
+@end verbatim
+
+@end deffn
+
+@deffn {Scheme Procedure} gcprof thunk [#:loop]
+Like the @code{statprof} procedure, but instead of profiling CPU time,
+we profile garbage collection.
+
+The stack will be sampled soon after every garbage collection during the
+evaluation of @var{thunk}, yielding an approximate idea of what is
+causing allocation in your program.
Since GC does not occur very frequently, you may need to use the
@var{loop} parameter, to cause @var{thunk} to be called @var{loop}
times.
-
-If @var{full-stacks?} is true, at each sample, statprof will store away
-the whole call tree, for later analysis. Use
-@code{statprof-fetch-stacks} or @code{statprof-fetch-call-tree} to
-retrieve the last-stored stacks.
-
-@end defun
+@end deffn
diff --git a/doc/ref/sxml-match.texi b/doc/ref/sxml-match.texi
index d2795a5f7..3adf34751 100644
--- a/doc/ref/sxml-match.texi
+++ b/doc/ref/sxml-match.texi
@@ -147,7 +147,7 @@ expressions which are evaluated if the pattern is successfully match. The
example above matches an element @code{e} with an attribute @code{i} and three
children.
-Pattern variables are must be ``unquoted'' in the pattern. The above expression
+Pattern variables must be ``unquoted'' in the pattern. The above expression
binds @var{d} to @code{1}, @var{a} to @code{3}, @var{b} to @code{4}, and @var{c}
to @code{5}.
diff --git a/doc/ref/sxml.texi b/doc/ref/sxml.texi
index 75867f3a6..19125091c 100644
--- a/doc/ref/sxml.texi
+++ b/doc/ref/sxml.texi
@@ -1,8 +1,12 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 2013 Free Software Foundation, Inc.
+@c Copyright (C) 2013, 2017 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
+@c SXPath documentation based on SXPath.scm by Oleg Kiselyov,
+@c which is in the public domain according to
+@c and .
+
@node SXML
@section SXML
@@ -17,7 +21,7 @@ fragment:
may be represented with the following SXML:
@example
-(parrot (@@ (type "African Grey)) (name "Alfie"))
+(parrot (@@ (type "African Grey")) (name "Alfie"))
@end example
SXML is very general, and is capable of representing all of XML.
@@ -28,14 +32,14 @@ Guile includes several facilities for working with XML and SXML:
parsers, serializers, and transformers.
@menu
-* SXML Overview:: XML, as it was meant to be
-* Reading and Writing XML:: Convenient XML parsing and serializing
-* SSAX:: Custom functional-style XML parsers
-* Transforming SXML:: Munging SXML with @code{pre-post-order}
-* SXML Tree Fold:: Fold-based SXML transformations
-* SXPath:: XPath for SXML
-* sxml apply-templates:: A more XSLT-like approach to SXML transformations
-* sxml ssax input-parse:: The SSAX tokenizer, optimized for Guile
+* SXML Overview:: XML, as it was meant to be
+* Reading and Writing XML:: Convenient XML parsing and serializing
+* SSAX:: Custom functional-style XML parsers
+* Transforming SXML:: Munging SXML with @code{pre-post-order}
+* SXML Tree Fold:: Fold-based SXML transformations
+* SXPath:: XPath for SXML
+* sxml ssax input-parse:: The SSAX tokenizer, optimized for Guile
+* sxml apply-templates:: A more XSLT-like approach to SXML transformations
@end menu
@node SXML Overview
@@ -250,8 +254,8 @@ internal and external parsed entities, user-controlled handling of
whitespace, and validation. This module therefore is intended to be a
framework, a set of ``Lego blocks'' you can use to build a parser
following any discipline and performing validation to any degree. As an
-example of the parser construction, this file includes a semi-validating
-SXML parser.
+example of the parser construction, the source file includes a
+semi-validating SXML parser.
SSAX has a ``sequential'' feel of SAX yet a ``functional style'' of DOM.
Like a SAX parser, the framework scans the document only once and
@@ -271,7 +275,7 @@ the middle- and high-level parsers are single-threaded through the
the @var{seed} in any way: they simply pass it around as an instance of
an opaque datatype. User functions, on the other hand, can use the seed
to maintain user's state, to accumulate parsing results, etc. A user
-can freely mix his own functions with those of the framework. On the
+can freely mix their own functions with those of the framework. On the
other hand, the user may wish to instantiate a high-level parser:
@code{SSAX:make-elem-parser} or @code{SSAX:make-parser}. In the latter
case, the user must provide functions of specific signatures, which are
@@ -576,7 +580,7 @@ A traversal combinator in the spirit of @code{pre-post-order}.
@example
bindings := (...)
-binding := ( ...)
+binding := ( ...)
| (*default* . )
| (*text* . )
tag :=
@@ -725,95 +729,323 @@ location path is a relative path applied to the root node.
Similarly to XPath, SXPath defines full and abbreviated notations for
location paths. In both cases, the abbreviated notation can be
mechanically expanded into the full form by simple rewriting rules. In
-case of SXPath the corresponding rules are given as comments to a sxpath
-function, below. The regression test suite at the end of this file shows
-a representative sample of SXPaths in both notations, juxtaposed with
-the corresponding XPath expressions. Most of the samples are borrowed
-literally from the XPath specification, while the others are adjusted
-for our running example, tree1.
+the case of SXPath the corresponding rules are given in the
+documentation of the @code{sxpath} procedure.
+@xref{sxpath-procedure-docs,,SXPath procedure documentation}.
+
+The regression test suite at the end of the file @file{SXPATH-old.scm}
+shows a representative sample of SXPaths in both notations, juxtaposed
+with the corresponding XPath expressions. Most of the samples are
+borrowed literally from the XPath specification.
+
+Much of the following material is taken from the SXPath sources by Oleg
+Kiselyov et al.
+
+@subsubsection Basic Converters and Applicators
+
+A converter is a function mapping a nodeset (or a single node) to another
+nodeset. Its type can be represented like this:
+
+@example
+type Converter = Node|Nodeset -> Nodeset
+@end example
+
+A converter can also play the role of a predicate: in that case, if a
+converter, applied to a node or a nodeset, yields a non-empty nodeset,
+the converter-predicate is deemed satisfied. Likewise, an empty nodeset
+is equivalent to @code{#f} in denoting failure.
-@subsubsection Usage
@deffn {Scheme Procedure} nodeset? x
+Return @code{#t} if @var{x} is a nodeset.
@end deffn
@deffn {Scheme Procedure} node-typeof? crit
+This function implements a 'Node test' as defined in Sec. 2.3 of the
+XPath document. A node test is one of the components of a location
+step. It is also a converter-predicate in SXPath.
+
+The function @code{node-typeof?} takes a type criterion and returns a
+function, which, when applied to a node, will tell if the node satisfies
+the test.
+
+The criterion @var{crit} is a symbol, one of the following:
+
+@table @code
+@item id
+tests if the node has the right name (id)
+
+@item @@
+tests if the node is an
+
+@item *
+tests if the node is an
+
+@item *text*
+tests if the node is a text node
+
+@item *PI*
+tests if the node is a PI (processing instruction) node
+
+@item *any*
+@code{#t} for any type of node
+@end table
@end deffn
@deffn {Scheme Procedure} node-eq? other
+A curried equivalence converter predicate that takes a node @var{other}
+and returns a function that takes another node. The two nodes are
+compared using @code{eq?}.
@end deffn
@deffn {Scheme Procedure} node-equal? other
+A curried equivalence converter predicate that takes a node @var{other}
+and returns a function that takes another node. The two nodes are
+compared using @code{equal?}.
@end deffn
@deffn {Scheme Procedure} node-pos n
+Select the @var{n}'th element of a nodeset and return as a singular
+nodeset. If the @var{n}'th element does not exist, return an empty
+nodeset. If @var{n} is a negative number the node is picked from the
+tail of the list.
+
+@example
+((node-pos 1) nodeset) ; return the the head of the nodeset (if exists)
+((node-pos 2) nodeset) ; return the node after that (if exists)
+((node-pos -1) nodeset) ; selects the last node of a non-empty nodeset
+((node-pos -2) nodeset) ; selects the last but one node, if exists.
+@end example
@end deffn
@deffn {Scheme Procedure} filter pred?
-@verbatim
- -- Scheme Procedure: filter pred list
- Return all the elements of 2nd arg LIST that satisfy predicate
- PRED. The list is not disordered - elements that appear in the
- result list occur in the same order as they occur in the argument
- list. The returned list may share a common tail with the argument
- list. The dynamic order in which the various applications of pred
- are made is not specified.
-
- (filter even? '(0 7 8 8 43 -4)) => (0 8 8 -4)
-
-
-@end verbatim
+A filter applicator, which introduces a filtering context. The argument
+converter @var{pred?} is considered a predicate, with either @code{#f}
+or @code{nil} meaning failure.
@end deffn
@deffn {Scheme Procedure} take-until pred?
+@example
+take-until:: Converter -> Converter, or
+take-until:: Pred -> Node|Nodeset -> Nodeset
+@end example
+
+Given a converter-predicate @var{pred?} and a nodeset, apply the
+predicate to each element of the nodeset, until the predicate yields
+anything but @code{#f} or @code{nil}. Return the elements of the input
+nodeset that have been processed until that moment (that is, which fail
+the predicate).
+
+@code{take-until} is a variation of the @code{filter} above:
+@code{take-until} passes elements of an ordered input set up to (but not
+including) the first element that satisfies the predicate. The nodeset
+returned by @code{((take-until (not pred)) nset)} is a subset -- to be
+more precise, a prefix -- of the nodeset returned by @code{((filter
+pred) nset)}.
@end deffn
@deffn {Scheme Procedure} take-after pred?
+@example
+take-after:: Converter -> Converter, or
+take-after:: Pred -> Node|Nodeset -> Nodeset
+@end example
+
+Given a converter-predicate @var{pred?} and a nodeset, apply the
+predicate to each element of the nodeset, until the predicate yields
+anything but @code{#f} or @code{nil}. Return the elements of the input
+nodeset that have not been processed: that is, return the elements of
+the input nodeset that follow the first element that satisfied the
+predicate.
+
+@code{take-after} along with @code{take-until} partition an input
+nodeset into three parts: the first element that satisfies a predicate,
+all preceding elements and all following elements.
@end deffn
@deffn {Scheme Procedure} map-union proc lst
+Apply @var{proc} to each element of @var{lst} and return the list of results.
+If @var{proc} returns a nodeset, splice it into the result
+
+From another point of view, @code{map-union} is a function
+@code{Converter->Converter}, which places an argument-converter in a joining
+context.
@end deffn
@deffn {Scheme Procedure} node-reverse node-or-nodeset
+@example
+node-reverse :: Converter, or
+node-reverse:: Node|Nodeset -> Nodeset
+@end example
+
+Reverses the order of nodes in the nodeset. This basic converter is
+needed to implement a reverse document order (see the XPath
+Recommendation).
@end deffn
@deffn {Scheme Procedure} node-trace title
+@example
+node-trace:: String -> Converter
+@end example
+
+@code{(node-trace title)} is an identity converter. In addition it
+prints out the node or nodeset it is applied to, prefixed with the
+@var{title}. This converter is very useful for debugging.
@end deffn
+@subsubsection Converter Combinators
+
+Combinators are higher-order functions that transmogrify a converter or
+glue a sequence of converters into a single, non-trivial converter. The
+goal is to arrive at converters that correspond to XPath location paths.
+
+From a different point of view, a combinator is a fixed, named
+@dfn{pattern} of applying converters. Given below is a complete set of
+such patterns that together implement XPath location path specification.
+As it turns out, all these combinators can be built from a small number
+of basic blocks: regular functional composition, @code{map-union} and
+@code{filter} applicators, and the nodeset union.
+
@deffn {Scheme Procedure} select-kids test-pred?
+@code{select-kids} takes a converter (or a predicate) as an argument and
+returns another converter. The resulting converter applied to a nodeset
+returns an ordered subset of its children that satisfy the predicate
+@var{test-pred?}.
@end deffn
@deffn {Scheme Procedure} node-self pred?
-@verbatim
- -- Scheme Procedure: filter pred list
- Return all the elements of 2nd arg LIST that satisfy predicate
- PRED. The list is not disordered - elements that appear in the
- result list occur in the same order as they occur in the argument
- list. The returned list may share a common tail with the argument
- list. The dynamic order in which the various applications of pred
- are made is not specified.
-
- (filter even? '(0 7 8 8 43 -4)) => (0 8 8 -4)
-
-
-@end verbatim
+Similar to @code{select-kids} except that the predicate @var{pred?} is
+applied to the node itself rather than to its children. The resulting
+nodeset will contain either one component, or will be empty if the node
+failed the predicate.
@end deffn
@deffn {Scheme Procedure} node-join . selectors
+@example
+node-join:: [LocPath] -> Node|Nodeset -> Nodeset, or
+node-join:: [Converter] -> Converter
+@end example
+
+Join the sequence of location steps or paths as described above.
@end deffn
@deffn {Scheme Procedure} node-reduce . converters
+@example
+node-reduce:: [LocPath] -> Node|Nodeset -> Nodeset, or
+node-reduce:: [Converter] -> Converter
+@end example
+
+A regular functional composition of converters. From a different point
+of view, @code{((apply node-reduce converters) nodeset)} is equivalent
+to @code{(foldl apply nodeset converters)}, i.e., folding, or reducing,
+a list of converters with the nodeset as a seed.
@end deffn
@deffn {Scheme Procedure} node-or . converters
+@example
+node-or:: [Converter] -> Converter
+@end example
+
+This combinator applies all converters to a given node and produces the
+union of their results. This combinator corresponds to a union
+(@code{|} operation) for XPath location paths.
@end deffn
@deffn {Scheme Procedure} node-closure test-pred?
+@example
+node-closure:: Converter -> Converter
+@end example
+
+Select all @emph{descendants} of a node that satisfy a
+converter-predicate @var{test-pred?}. This combinator is similar to
+@code{select-kids} but applies to grand... children as well. This
+combinator implements the @code{descendant::} XPath axis. Conceptually,
+this combinator can be expressed as
+
+@example
+(define (node-closure f)
+ (node-or
+ (select-kids f)
+ (node-reduce (select-kids (node-typeof? '*)) (node-closure f))))
+@end example
+
+This definition, as written, looks somewhat like a fixpoint, and it will
+run forever. It is obvious however that sooner or later
+@code{(select-kids (node-typeof? '*))} will return an empty nodeset. At
+this point further iterations will no longer affect the result and can
+be stopped.
@end deffn
@deffn {Scheme Procedure} node-parent rootnode
+@example
+node-parent:: RootNode -> Converter
+@end example
+
+@code{(node-parent rootnode)} yields a converter that returns a parent
+of a node it is applied to. If applied to a nodeset, it returns the
+list of parents of nodes in the nodeset. The @var{rootnode} does not
+have to be the root node of the whole SXML tree -- it may be a root node
+of a branch of interest.
+
+Given the notation of Philip Wadler's paper on semantics of XSLT,
+
+@verbatim
+ parent(x) = { y | y=subnode*(root), x=subnode(y) }
+@end verbatim
+
+Therefore, @code{node-parent} is not the fundamental converter: it can
+be expressed through the existing ones. Yet @code{node-parent} is a
+rather convenient converter. It corresponds to a @code{parent::} axis
+of SXPath. Note that the @code{parent::} axis can be used with an
+attribute node as well.
@end deffn
+@anchor{sxpath-procedure-docs}
@deffn {Scheme Procedure} sxpath path
+Evaluate an abbreviated SXPath.
+
+@example
+sxpath:: AbbrPath -> Converter, or
+sxpath:: AbbrPath -> Node|Nodeset -> Nodeset
+@end example
+
+@var{path} is a list. It is translated to the full SXPath according to
+the following rewriting rules:
+
+@example
+(sxpath '())
+@result{} (node-join)
+
+(sxpath '(path-component ...))
+@result{} (node-join (sxpath1 path-component) (sxpath '(...)))
+
+(sxpath1 '//)
+@result{} (node-or
+ (node-self (node-typeof? '*any*))
+ (node-closure (node-typeof? '*any*)))
+
+(sxpath1 '(equal? x))
+@result{} (select-kids (node-equal? x))
+
+(sxpath1 '(eq? x))
+@result{} (select-kids (node-eq? x))
+
+(sxpath1 ?symbol)
+@result{} (select-kids (node-typeof? ?symbol)
+
+(sxpath1 procedure)
+@result{} procedure
+
+(sxpath1 '(?symbol ...))
+@result{} (sxpath1 '((?symbol) ...))
+
+(sxpath1 '(path reducer ...))
+@result{} (node-reduce (sxpath path) (sxpathr reducer) ...)
+
+(sxpathr number)
+@result{} (node-pos number)
+
+(sxpathr path-filter)
+@result{} (filter (sxpath path-filter))
+@end example
@end deffn
@node sxml ssax input-parse
diff --git a/doc/ref/vm.texi b/doc/ref/vm.texi
index 6616af446..ac3889f41 100644
--- a/doc/ref/vm.texi
+++ b/doc/ref/vm.texi
@@ -62,10 +62,12 @@ The obvious solution is to compile to a virtual machine that is
present on all Guile installations.
The easiest (and most fun) way to depend on a virtual machine is to
-implement the virtual machine within Guile itself. This way the
-virtual machine provides what Scheme needs (tail calls, multiple
-values, @code{call/cc}) and can provide optimized inline instructions
-for Guile (@code{cons}, @code{struct-ref}, etc.).
+implement the virtual machine within Guile itself. Guile contains a
+bytecode interpreter (written in C) and a Scheme to bytecode compiler
+(written in Scheme). This way the virtual machine provides what Scheme
+needs (tail calls, multiple values, @code{call/cc}) and can provide
+optimized inline instructions for Guile (@code{cons}, @code{struct-ref},
+etc.).
So this is what Guile does. The rest of this section describes that VM
that Guile implements, and the compiled procedures that run on it.
@@ -80,11 +82,12 @@ but it is not normally used at runtime.)
The upside of implementing the interpreter in Scheme is that we preserve
tail calls and multiple-value handling between interpreted and compiled
-code. The downside is that the interpreter in Guile 2.2 is still slower
-than the interpreter in 1.8. We hope the that the compiler's speed makes
-up for the loss. In any case, once we have native compilation for
-Scheme code, we expect the new self-hosted interpreter to beat the old
-hand-tuned C implementation.
+code. The downside is that the interpreter in Guile 2.2 is still about
+twice as slow as the interpreter in 1.8. Since Scheme users are mostly
+running compiled code, the compiler's speed more than makes up for the
+loss. In any case, once we have native compilation for Scheme code, we
+expect the self-hosted interpreter to handily beat the old hand-tuned C
+implementation.
Also note that this decision to implement a bytecode compiler does not
preclude native compilation. We can compile from bytecode to native
@@ -143,27 +146,40 @@ course is the tail call case, @pxref{Tail Calls}.)
The structure of the top stack frame is as follows:
@example
- /------------------\ <- top of stack
- | Local N-1 | <- sp
| ... |
- | Local 1 |
- | Local 0 | <- fp = SCM_FRAME_LOCALS_ADDRESS (fp)
- +==================+
+ +==================+ <- fp + 2 = SCM_FRAME_PREVIOUS_SP (fp)
+ | Dynamic link |
+ +------------------+
| Return address |
- | Dynamic link | <- fp - 2 = SCM_FRAME_LOWER_ADDRESS (fp)
- +==================+
- | | <- fp - 3 = SCM_FRAME_PREVIOUS_SP (fp)
+ +==================+ <- fp
+ | Local 0 |
+ +------------------+
+ | Local 1 |
+ +------------------+
+ | ... |
+ +------------------+
+ | Local N-1 |
+ \------------------/ <- sp
@end example
-In the above drawing, the stack grows upward. Usually the procedure
-being applied is in local 0, followed by the arguments from local 1.
-After that are enough slots to store the various lexically-bound and
-temporary values that are needed in the function's application.
+In the above drawing, the stack grows downward. At the beginning of a
+function call, the procedure being applied is in local 0, followed by
+the arguments from local 1. After the procedure checks that it is being
+passed a compatible set of arguments, the procedure allocates some
+additional space in the frame to hold variables local to the function.
+
+Note that once a value in a local variable slot is no longer needed,
+Guile is free to re-use that slot. This applies to the slots that were
+initially used for the callee and arguments, too. For this reason,
+backtraces in Guile aren't always able to show all of the arguments: it
+could be that the slot corresponding to that argument was re-used by
+some other variable.
The @dfn{return address} is the @code{ip} that was in effect before this
program was applied. When we return from this activation frame, we will
jump back to this @code{ip}. Likewise, the @dfn{dynamic link} is the
-@code{fp} in effect before this program was applied.
+offset of the @code{fp} that was in effect before this program was
+applied, relative to the current @code{fp}.
To prepare for a non-tail application, Guile's VM will emit code that
shuffles the function to apply and its arguments into appropriate stack
@@ -175,6 +191,18 @@ new call frame.
In this way, the dynamic link links the current frame to the previous
frame. Computing a stack trace involves traversing these frames.
+Each stack local in Guile is 64 bits wide, even on 32-bit architectures.
+This allows Guile to preserve its uniform treatment of stack locals
+while allowing for unboxed arithmetic on 64-bit integers and
+floating-point numbers. @xref{Instruction Set}, for more on unboxed
+arithmetic.
+
+As an implementation detail, we actually store the dynamic link as an
+offset and not an absolute value because the stack can move at runtime
+as it expands or during partial continuation calls. If it were an
+absolute value, we would have to walk the frames, relocating frame
+pointers.
+
@node Variables and the VM
@subsection Variables and the VM
@@ -213,8 +241,9 @@ variables are allocated in ``boxes''---actually, in variable cells.
variables are indirected through the boxes.
Thus perhaps counterintuitively, what would seem ``closer to the
-metal'', viz @code{set!}, actually forces an extra memory allocation
-and indirection.
+metal'', viz @code{set!}, actually forces an extra memory allocation and
+indirection. Sometimes Guile's optimizer can remove this allocation,
+but not always.
Going back to our example, @code{b} may be allocated on the stack, as
it is never mutated.
@@ -261,54 +290,72 @@ We can see how these concepts tie together by disassembling the
@smallexample
scheme@@(guile-user)> (define (foo a) (lambda (b) (list foo a b)))
scheme@@(guile-user)> ,x foo
-Disassembly of # at #x203be34:
+Disassembly of # at #xea4ce4:
- 0 (assert-nargs-ee/locals 2 1) ;; 1 arg, 1 local at (unknown file):1:0
- 1 (make-closure 2 6 1) ;; anonymous procedure at #x203be50 (1 free var)
- 4 (free-set! 2 1 0) ;; free var 0
- 6 (return 2)
+ 0 (assert-nargs-ee/locals 2 0) ;; 2 slots (1 arg) at (unknown file):1:0
+ 1 (make-closure 1 7 1) ;; anonymous procedure at #xea4d04 (1 free var)
+ 4 (free-set! 1 0 0) ;; free var 0
+ 6 (mov 0 1)
+ 7 (return-values 2) ;; 1 value
----------------------------------------
-Disassembly of anonymous procedure at #x203be50:
+Disassembly of anonymous procedure at #xea4d04:
- 0 (assert-nargs-ee/locals 2 3) ;; 1 arg, 3 locals at (unknown file):1:0
- 1 (toplevel-box 2 73 57 71 #t) ;; `foo'
- 6 (box-ref 2 2)
- 7 (make-short-immediate 3 772) ;; ()
- 8 (cons 3 1 3)
- 9 (free-ref 4 0 0) ;; free var 0
- 11 (cons 3 4 3)
- 12 (cons 2 2 3)
- 13 (return 2)
+ 0 (assert-nargs-ee/locals 2 2) ;; 4 slots (1 arg) at (unknown file):1:16
+ 1 (toplevel-box 1 74 58 68 #t) ;; `foo'
+ 6 (box-ref 1 1)
+ 7 (make-short-immediate 0 772) ;; () at (unknown file):1:28
+ 8 (cons 2 2 0)
+ 9 (free-ref 3 3 0) ;; free var 0
+ 11 (cons 3 3 2)
+ 12 (cons 2 1 3)
+ 13 (return-values 2) ;; 1 value
@end smallexample
First there's some prelude, where @code{foo} checks that it was called
with only 1 argument. Then at @code{ip} 1, we allocate a new closure
-and store it in slot 2. The `6' in the @code{(make-closure 2 6 1)} is a
-relative offset from the instruction pointer of the code for the
-closure.
+and store it in slot 1, relative to the @code{sp}.
-A closure is code with data. We already have the code part initialized;
-what remains is to set the data. @code{Ip} 4 initializes free variable
-0 in the new closure with the value from local variable 1, which
-corresponds to the first argument of @code{foo}: `a'. Finally we return
-the closure.
+At run-time, local variables in Guile are usually addressed relative to
+the stack pointer, which leads to a pleasantly efficient
+@code{sp[@var{n}]} access. However it can make the disassembly hard to
+read, because the @code{sp} can change during the function, and because
+incoming arguments are relative to the @code{fp}, not the @code{sp}.
+
+To know what @code{fp}-relative slot corresponds to an
+@code{sp}-relative reference, scan up in the disassembly until you get
+to a ``@var{n} slots'' annotation; in our case, 2, indicating that the
+frame has space for 2 slots. Thus a zero-indexed @code{sp}-relative
+slot of 1 corresponds to the @code{fp}-relative slot of 0, which
+initially held the value of the closure being called. This means that
+Guile doesn't need the value of the closure to compute its result, and
+so slot 0 was free for re-use, in this case for the result of making a
+new closure.
+
+A closure is code with data. The @code{6} in the @code{(make-closure 1
+6 1)} is a relative offset from the instruction pointer of the code for
+the closure, and the final @code{1} indicates that the closure has space
+for 1 free variable. @code{Ip} 4 initializes free variable 0 in the new
+closure with the value from @code{sp}-relative slot 0, which corresponds
+to @code{fp}-relative slot 1, the first argument of @code{foo}:
+@code{a}. Finally we return the closure.
The second stanza disassembles the code for the closure. After the
prelude, we load the variable for the toplevel variable @code{foo} into
-local variable 2. This lookup occurs lazily, the first time the
-variable is actually referenced, and the location of the lookup is
-cached so that future references are very cheap. @xref{Top-Level
-Environment Instructions}, for more details. The @code{box-ref}
-dereferences the variable cell, replacing the contents of local 2.
+slot 1. This lookup occurs lazily, the first time the variable is
+actually referenced, and the location of the lookup is cached so that
+future references are very cheap. @xref{Top-Level Environment
+Instructions}, for more details. The @code{box-ref} dereferences the
+variable cell, replacing the contents of slot 1.
What follows is a sequence of conses to build up the result list.
@code{Ip} 7 makes the tail of the list. @code{Ip} 8 conses on the value
-in local 1, corresponding to the first argument to the closure: `b'.
-@code{Ip} 9 loads free variable 0 of local 0 -- the procedure being
-called -- into slot 4, then @code{ip} 11 conses it onto the list.
-Finally we cons local 2, containing the @code{foo} toplevel, onto the
-front of the list, and we return it.
+in slot 2, corresponding to the first argument to the closure: @code{b}.
+@code{Ip} 9 loads free variable 0 of slot 3 -- the procedure being
+called, in @code{fp}-relative slot 0 -- into slot 3, then @code{ip} 11
+conses it onto the list. Finally we cons the value in slot 1,
+containing the @code{foo} toplevel, onto the front of the list, and we
+return it.
@node Object File Format
@@ -397,6 +444,10 @@ A table mapping addresses in the @code{.rtl-text} to procedure names.
@itemx .guile.docstrs
@itemx .guile.docstrs.strtab
Side tables of procedure properties, arities, and docstrings.
+@item .guile.docstrs.strtab
+Side table of frame maps, describing the set of live slots for ever
+return point in the program text, and whether those slots are pointers
+are not. Used by the garbage collector.
@item .debug_info
@itemx .debug_abbrev
@itemx .debug_str
@@ -418,7 +469,7 @@ compiled @code{.go} files. It's good times!
@node Instruction Set
@subsection Instruction Set
-There are currently about 130 instructions in Guile's virtual machine.
+There are currently about 175 instructions in Guile's virtual machine.
These instructions represent atomic units of a program's execution.
Ideally, they perform one task without conditional branches, then
dispatch to the next instruction in the stream.
@@ -429,10 +480,16 @@ instruction describe the operands. There are a number of different ways
operands can be encoded.
@table @code
-@item u@var{n}
-An unsigned @var{n}-bit integer. Usually indicates the index of a local
-variable, but some instructions interpret these operands as immediate
-values.
+@item s@var{n}
+An unsigned @var{n}-bit integer, indicating the @code{sp}-relative index
+of a local variable.
+@item f@var{n}
+An unsigned @var{n}-bit integer, indicating the @code{fp}-relative index
+of a local variable. Used when a continuation accepts a variable number
+of values, to shuffle received values into known locations in the
+frame.
+@item c@var{n}
+An unsigned @var{n}-bit integer, indicating a constant value.
@item l24
An offset from the current @code{ip}, in 32-bit units, as a signed
24-bit value. Indicates a bytecode address, for a relative jump.
@@ -450,7 +507,7 @@ and indicate the high and low bits, respectively. Normally only used on
A statically allocated non-immediate. The address of the non-immediate
is encoded as a signed 32-bit integer, and indicates a relative offset
in 32-bit units. Think of it as @code{SCM x = ip + offset}.
-@item s32
+@item r32
Indirect scheme value, like @code{n32} but indirected. Think of it as
@code{SCM *x = ip + offset}.
@item l32
@@ -476,7 +533,7 @@ operands occupying the lower bits.
For example, consider the following instruction specification:
-@deftypefn Instruction {} free-set! u12:@var{dst} u12:@var{src} x8:@var{_} u24:@var{idx}
+@deftypefn Instruction {} free-set! s12:@var{dst} s12:@var{src} x8:@var{_} c24:@var{idx}
Set free variable @var{idx} from the closure @var{dst} to @var{src}.
@end deftypefn
@@ -502,10 +559,15 @@ In addition, some Scheme primitives have their own inline
implementations. For example, in the previous section we saw
@code{cons}.
-Guile's instruction set is a @emph{complete} instruction set, in that it
-provides the instructions that are suited to the problem, and is not
-concerned with making a minimal, orthogonal set of instructions. More
-instructions may be added over time.
+Finally, for instructions with operands that encode references to the
+stack, the interpretation of those stack values is up to the instruction
+itself. Most instructions expect their operands to be tagged SCM values
+(@code{scm} representation), but some instructions expect unboxed
+integers (@code{u64} and @code{s64} representations) or floating-point
+numbers (@var{f64} representation). Instructions have static types:
+they must receive their operands in the format they expect. It's up to
+the compiler to ensure this is the case. Unless otherwise mentioned,
+all operands and results are boxed as SCM values.
@menu
* Lexical Environment Instructions::
@@ -518,8 +580,11 @@ instructions may be added over time.
* Dynamic Environment Instructions::
* Miscellaneous Instructions::
* Inlined Scheme Instructions::
+* Inlined Atomic Instructions::
* Inlined Mathematical Instructions::
* Inlined Bytevector Instructions::
+* Unboxed Integer Arithmetic::
+* Unboxed Floating-Point Arithmetic::
@end menu
@@ -530,8 +595,8 @@ These instructions access and mutate the lexical environment of a
compiled procedure---its free and bound variables. @xref{Stack Layout},
for more information on the format of stack frames.
-@deftypefn Instruction {} mov u12:@var{dst} u12:@var{src}
-@deftypefnx Instruction {} long-mov u24:@var{dst} x8:@var{_} u24:@var{src}
+@deftypefn Instruction {} mov s12:@var{dst} s12:@var{src}
+@deftypefnx Instruction {} long-mov s24:@var{dst} x8:@var{_} s24:@var{src}
Copy a value from one local slot to another.
As discussed previously, procedure arguments and local variables are
@@ -541,7 +606,13 @@ instructions redundant. However there are some cases in which shuffling
is necessary, and in those cases, @code{mov} is the thing to use.
@end deftypefn
-@deftypefn Instruction {} make-closure u24:@var{dst} l32:@var{offset} x8:@var{_} u24:@var{nfree}
+@deftypefn Instruction {} long-fmov f24:@var{dst} x8:@var{_} f24:@var{src}
+Copy a value from one local slot to another, but addressing slots
+relative to the @code{fp} instead of the @code{sp}. This is used when
+shuffling values into place after multiple-value returns.
+@end deftypefn
+
+@deftypefn Instruction {} make-closure s24:@var{dst} l32:@var{offset} x8:@var{_} c24:@var{nfree}
Make a new closure, and write it to @var{dst}. The code for the closure
will be found at @var{offset} words from the current @code{ip}.
@var{offset} is a signed 32-bit integer. Space for @var{nfree} free
@@ -551,12 +622,12 @@ The size of a closure is currently two words, plus one word per free
variable.
@end deftypefn
-@deftypefn Instruction {} free-ref u12:@var{dst} u12:@var{src} x8:@var{_} u24:@var{idx}
+@deftypefn Instruction {} free-ref s12:@var{dst} s12:@var{src} x8:@var{_} c24:@var{idx}
Load free variable @var{idx} from the closure @var{src} into local slot
@var{dst}.
@end deftypefn
-@deftypefn Instruction {} free-set! u12:@var{dst} u12:@var{src} x8:@var{_} u24:@var{idx}
+@deftypefn Instruction {} free-set! s12:@var{dst} s12:@var{src} x8:@var{_} c24:@var{idx}
Set free variable @var{idx} from the closure @var{dst} to @var{src}.
This instruction is usually used when initializing a closure's free
@@ -570,16 +641,16 @@ their value at one point in time. Variables are also used in the
implementation of top-level bindings; see the next section for more
information.
-@deftypefn Instruction {} box u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} box s12:@var{dst} s12:@var{src}
Create a new variable holding @var{src}, and place it in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} box-ref u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} box-ref s12:@var{dst} s12:@var{src}
Unpack the variable at @var{src} into @var{dst}, asserting that the
variable is actually bound.
@end deftypefn
-@deftypefn Instruction {} box-set! u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} box-set! s12:@var{dst} s12:@var{src}
Set the contents of the variable at @var{dst} to @var{set}.
@end deftypefn
@@ -595,23 +666,23 @@ The location in which a toplevel binding is stored can be looked up once
and cached for later. The binding itself may change over time, but its
location will stay constant.
-@deftypefn Instruction {} current-module u24:@var{dst}
+@deftypefn Instruction {} current-module s24:@var{dst}
Store the current module in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} resolve u24:@var{dst} b1:@var{bound?} x7:@var{_} u24:@var{sym}
+@deftypefn Instruction {} resolve s24:@var{dst} b1:@var{bound?} x7:@var{_} s24:@var{sym}
Resolve @var{sym} in the current module, and place the resulting
variable in @var{dst}. An error will be signalled if no variable is
found. If @var{bound?} is true, an error will be signalled if the
variable is unbound.
@end deftypefn
-@deftypefn Instruction {} define! u12:@var{sym} u12:@var{val}
+@deftypefn Instruction {} define! s12:@var{dst} s12:@var{sym}
Look up a binding for @var{sym} in the current module, creating it if
-necessary. Set its value to @var{val}.
+necessary. Store that variable to @var{dst}.
@end deftypefn
-@deftypefn Instruction {} toplevel-box u24:@var{dst} s32:@var{var-offset} s32:@var{mod-offset} n32:@var{sym-offset} b1:@var{bound?} x31:@var{_}
+@deftypefn Instruction {} toplevel-box s24:@var{dst} r32:@var{var-offset} r32:@var{mod-offset} n32:@var{sym-offset} b1:@var{bound?} x31:@var{_}
Load a value. The value will be fetched from memory, @var{var-offset}
32-bit words away from the current instruction pointer.
@var{var-offset} is a signed value. Up to here, @code{toplevel-box} is
@@ -631,7 +702,7 @@ cache next time. If @var{bound?} is true, an error will be signalled if
the variable is unbound.
@end deftypefn
-@deftypefn Instruction {} module-box u24:@var{dst} s32:@var{var-offset} n32:@var{mod-offset} n32:@var{sym-offset} b1:@var{bound?} x31:@var{_}
+@deftypefn Instruction {} module-box s24:@var{dst} r32:@var{var-offset} n32:@var{mod-offset} n32:@var{sym-offset} b1:@var{bound?} x31:@var{_}
Like @code{toplevel-box}, except @var{mod-offset} points at a module
identifier instead of the module itself. A module identifier is a
module name, as a list, prefixed by a boolean. If the prefix is true,
@@ -649,23 +720,23 @@ is that arguments are passed and values returned on the stack.
For calls, both in tail position and in non-tail position, we require
that the procedure and the arguments already be shuffled into place
befor the call instruction. ``Into place'' for a tail call means that
-the procedure should be in slot 0, and the arguments should follow. For
-a non-tail call, if the procedure is in slot @var{n}, the arguments
-should follow from slot @var{n}+1, and there should be two free slots at
-@var{n}-1 and @var{n}-2 in which to save the @code{ip} and @code{fp}.
+the procedure should be in slot 0, relative to the @code{fp}, and the
+arguments should follow. For a non-tail call, if the procedure is in
+@code{fp}-relative slot @var{n}, the arguments should follow from slot
+@var{n}+1, and there should be two free slots at @var{n}-1 and @var{n}-2
+in which to save the @code{ip} and @code{fp}.
Returning values is similar. Multiple-value returns should have values
-already shuffled down to start from slot 1 before emitting
-@code{return-values}. There is a short-cut in the single-value case, in
-that @code{return} handles the trivial shuffling itself. We start from
-slot 1 instead of slot 0 to make tail calls to @code{values} trivial.
+already shuffled down to start from @code{fp}-relative slot 1 before
+emitting @code{return-values}. We start from slot 1 instead of slot 0
+to make tail calls to @code{values} trivial.
In both calls and returns, the @code{sp} is used to indicate to the
callee or caller the number of arguments or return values, respectively.
After receiving return values, it is the caller's responsibility to
@dfn{restore the frame} by resetting the @code{sp} to its former value.
-@deftypefn Instruction {} call u24:@var{proc} x8:@var{_} u24:@var{nlocals}
+@deftypefn Instruction {} call f24:@var{proc} x8:@var{_} c24:@var{nlocals}
Call a procedure. @var{proc} is the local corresponding to a procedure.
The two values below @var{proc} will be overwritten by the saved call
frame data. The new frame will have space for @var{nlocals} locals: one
@@ -678,7 +749,7 @@ number can be had by subtracting the address of @var{proc} from the
post-call @code{sp}.
@end deftypefn
-@deftypefn Instruction {} call-label u24:@var{proc} x8:@var{_} u24:@var{nlocals} l32:@var{label}
+@deftypefn Instruction {} call-label f24:@var{proc} x8:@var{_} c24:@var{nlocals} l32:@var{label}
Call a procedure in the same compilation unit.
This instruction is just like @code{call}, except that instead of
@@ -688,31 +759,31 @@ the current @code{ip}. Since @var{proc} is not dereferenced, it may be
some other representation of the closure.
@end deftypefn
-@deftypefn Instruction {} tail-call u24:@var{nlocals}
+@deftypefn Instruction {} tail-call c24:@var{nlocals}
Tail-call a procedure. Requires that the procedure and all of the
arguments have already been shuffled into position. Will reset the
frame to @var{nlocals}.
@end deftypefn
-@deftypefn Instruction {} tail-call-label u24:@var{nlocals} l32:@var{label}
+@deftypefn Instruction {} tail-call-label c24:@var{nlocals} l32:@var{label}
Tail-call a known procedure. As @code{call} is to @code{call-label},
@code{tail-call} is to @code{tail-call-label}.
@end deftypefn
-@deftypefn Instruction {} tail-call/shuffle u24:@var{from}
+@deftypefn Instruction {} tail-call/shuffle f24:@var{from}
Tail-call a procedure. The procedure should already be set to slot 0.
The rest of the args are taken from the frame, starting at @var{from},
shuffled down to start at slot 0. This is part of the implementation of
the @code{call-with-values} builtin.
@end deftypefn
-@deftypefn Instruction {} receive u12:@var{dst} u12:@var{proc} x8:@var{_} u24:@var{nlocals}
+@deftypefn Instruction {} receive f12:@var{dst} f12:@var{proc} x8:@var{_} c24:@var{nlocals}
Receive a single return value from a call whose procedure was in
@var{proc}, asserting that the call actually returned at least one
value. Afterwards, resets the frame to @var{nlocals} locals.
@end deftypefn
-@deftypefn Instruction {} receive-values u24:@var{proc} b1:@var{allow-extra?} x7:@var{_} u24:@var{nvalues}
+@deftypefn Instruction {} receive-values f24:@var{proc} b1:@var{allow-extra?} x7:@var{_} c24:@var{nvalues}
Receive a return of multiple values from a call whose procedure was in
@var{proc}. If fewer than @var{nvalues} values were returned, signal an
error. Unless @var{allow-extra?} is true, require that the number of
@@ -720,16 +791,13 @@ return values equals @var{nvalues} exactly. After @code{receive-values}
has run, the values can be copied down via @code{mov}, or used in place.
@end deftypefn
-@deftypefn Instruction {} return u24:@var{src}
-Return a value.
-@end deftypefn
-
-@deftypefn Instruction {} return-values x24:@var{_}
+@deftypefn Instruction {} return-values c24:@var{nlocals}
Return a number of values from a call frame. This opcode corresponds to
an application of @code{values} in tail position. As with tail calls,
we expect that the values have already been shuffled down to a
-contiguous array starting at slot 1. We also expect the frame has
-already been reset.
+contiguous array starting at slot 1. If @var{nlocals} is nonzero, reset
+the frame to hold that number of locals. Note that a frame reset to 1
+local returns 0 values.
@end deftypefn
@deftypefn Instruction {} call/cc x24:@var{_}
@@ -753,21 +821,21 @@ cost of parsing keyword arguments. (At the time of this writing, calling
procedures with keyword arguments is typically two to four times as
costly as calling procedures with a fixed set of arguments.)
-@deftypefn Instruction {} assert-nargs-ee u24:@var{expected}
-@deftypefnx Instruction {} assert-nargs-ge u24:@var{expected}
-@deftypefnx Instruction {} assert-nargs-le u24:@var{expected}
+@deftypefn Instruction {} assert-nargs-ee c24:@var{expected}
+@deftypefnx Instruction {} assert-nargs-ge c24:@var{expected}
+@deftypefnx Instruction {} assert-nargs-le c24:@var{expected}
If the number of actual arguments is not @code{==}, @code{>=}, or
@code{<=} @var{expected}, respectively, signal an error.
-The number of arguments is determined by subtracting the frame pointer
-from the stack pointer (@code{sp + 1 - fp}). @xref{Stack Layout}, for
-more details on stack frames. Note that @var{expected} includes the
+The number of arguments is determined by subtracting the stack pointer
+from the frame pointer (@code{fp - sp}). @xref{Stack Layout}, for more
+details on stack frames. Note that @var{expected} includes the
procedure itself.
@end deftypefn
-@deftypefn Instruction {} br-if-nargs-ne u24:@var{expected} x8:@var{_} l24:@var{offset}
-@deftypefnx Instruction {} br-if-nargs-lt u24:@var{expected} x8:@var{_} l24:@var{offset}
-@deftypefnx Instruction {} br-if-nargs-gt u24:@var{expected} x8:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-nargs-ne c24:@var{expected} x8:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-nargs-lt c24:@var{expected} x8:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-nargs-gt c24:@var{expected} x8:@var{_} l24:@var{offset}
If the number of actual arguments is not equal, less than, or greater
than @var{expected}, respectively, add @var{offset}, a signed 24-bit
number, to the current instruction pointer. Note that @var{expected}
@@ -777,26 +845,26 @@ These instructions are used to implement multiple arities, as in
@code{case-lambda}. @xref{Case-lambda}, for more information.
@end deftypefn
-@deftypefn Instruction {} alloc-frame u24:@var{nlocals}
+@deftypefn Instruction {} alloc-frame c24:@var{nlocals}
Ensure that there is space on the stack for @var{nlocals} local
variables, setting them all to @code{SCM_UNDEFINED}, except those values
that are already on the stack.
@end deftypefn
-@deftypefn Instruction {} reset-frame u24:@var{nlocals}
+@deftypefn Instruction {} reset-frame c24:@var{nlocals}
Like @code{alloc-frame}, but doesn't check that the stack is big enough,
and doesn't initialize values to @code{SCM_UNDEFINED}. Used to reset
the frame size to something less than the size that was previously set
via alloc-frame.
@end deftypefn
-@deftypefn Instruction {} assert-nargs-ee/locals u12:@var{expected} u12:@var{nlocals}
+@deftypefn Instruction {} assert-nargs-ee/locals c12:@var{expected} c12:@var{nlocals}
Equivalent to a sequence of @code{assert-nargs-ee} and
@code{reserve-locals}. The number of locals reserved is @var{expected}
+ @var{nlocals}.
@end deftypefn
-@deftypefn Instruction {} br-if-npos-gt u24:@var{nreq} x8:@var{_} u24:@var{npos} x8:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-npos-gt c24:@var{nreq} x8:@var{_} c24:@var{npos} x8:@var{_} l24:@var{offset}
Find the first positional argument after @var{nreq}. If it is greater
than @var{npos}, jump to @var{offset}.
@@ -806,7 +874,7 @@ and an earlier clause has keywords and no rest arguments.
clause to apply.
@end deftypefn
-@deftypefn Instruction {} bind-kwargs u24:@var{nreq} u8:@var{flags} u24:@var{nreq-and-opt} x8:@var{_} u24:@var{ntotal} n32:@var{kw-offset}
+@deftypefn Instruction {} bind-kwargs c24:@var{nreq} c8:@var{flags} c24:@var{nreq-and-opt} x8:@var{_} c24:@var{ntotal} n32:@var{kw-offset}
@var{flags} is a bitfield, whose lowest bit is @var{allow-other-keys},
second bit is @var{has-rest}, and whose following six bits are unused.
@@ -827,7 +895,7 @@ will signal an error if an unknown key is found.
A macro-mega-instruction.
@end deftypefn
-@deftypefn Instruction {} bind-rest u24:@var{dst}
+@deftypefn Instruction {} bind-rest f24:@var{dst}
Collect any arguments at or above @var{dst} into a list, and store that
list at @var{dst}.
@end deftypefn
@@ -849,25 +917,24 @@ compiler probably shouldn't emit code with these instructions. However,
it's still interesting to know how these things work, so we document
these trampoline instructions here.
-@deftypefn Instruction {} subr-call u24:@var{ptr-idx}
-Call a subr, passing all locals in this frame as arguments. Fetch the
-foreign pointer from @var{ptr-idx}, a free variable. Return from the
-calling frame.
+@deftypefn Instruction {} subr-call x24:@var{_}
+Call a subr, passing all locals in this frame as arguments. Return from
+the calling frame.
@end deftypefn
-@deftypefn Instruction {} foreign-call u12:@var{cif-idx} u12:@var{ptr-idx}
+@deftypefn Instruction {} foreign-call c12:@var{cif-idx} c12:@var{ptr-idx}
Call a foreign function. Fetch the @var{cif} and foreign pointer from
@var{cif-idx} and @var{ptr-idx}, both free variables. Return from the calling
frame. Arguments are taken from the stack.
@end deftypefn
-@deftypefn Instruction {} continuation-call u24:@var{contregs}
+@deftypefn Instruction {} continuation-call c24:@var{contregs}
Return to a continuation, nonlocally. The arguments to the continuation
are taken from the stack. @var{contregs} is a free variable containing
the reified continuation.
@end deftypefn
-@deftypefn Instruction {} compose-continuation u24:@var{cont}
+@deftypefn Instruction {} compose-continuation c24:@var{cont}
Compose a partial continution with the current continuation. The
arguments to the continuation are taken from the stack. @var{cont} is a
free variable containing the reified continuation.
@@ -879,10 +946,17 @@ This instruction is part of the implementation of @code{apply}, and is
not generated by the compiler.
@end deftypefn
-@deftypefn Instruction {} builtin-ref u12:@var{dst} u12:@var{idx}
+@deftypefn Instruction {} builtin-ref s12:@var{dst} c12:@var{idx}
Load a builtin stub by index into @var{dst}.
@end deftypefn
+@deftypefn Instruction {} apply-non-program x24:@var{_}
+An instruction used only by a special trampoline that the VM uses to
+apply non-programs. Using that trampoline allows profilers and
+backtrace utilities to avoid seeing the instruction pointer from the
+calling frame.
+@end deftypefn
+
@node Branch Instructions
@subsubsection Branch Instructions
@@ -899,60 +973,59 @@ All the conditional branch instructions described below have an
@var{invert} parameter, which if true reverses the test:
@code{br-if-true} becomes @code{br-if-false}, and so on.
-@deftypefn Instruction {} br-if-true u24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-true s24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{test} is true for the purposes of Scheme, add
@var{offset} to the current instruction pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-null u24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-null s24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{test} is the end-of-list or Lisp nil, add
@var{offset} to the current instruction pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-nil u24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-nil s24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{test} is false to Lisp, add @var{offset} to the
current instruction pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-pair u24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-pair s24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{test} is a pair, add @var{offset} to the current
instruction pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-struct u24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-struct s24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{test} is a struct, add @var{offset} number to the
current instruction pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-char u24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-char s24:@var{test} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{test} is a char, add @var{offset} to the current
instruction pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-tc7 u24:@var{test} b1:@var{invert} u7:@var{tc7} l24:@var{offset}
+@deftypefn Instruction {} br-if-tc7 s24:@var{test} b1:@var{invert} u7:@var{tc7} l24:@var{offset}
If the value in @var{test} has the TC7 given in the second word, add
@var{offset} to the current instruction pointer. TC7 codes are part of
the way Guile represents non-immediate objects, and are deep wizardry.
See @code{libguile/tags.h} for all the details.
@end deftypefn
-@deftypefn Instruction {} br-if-eq u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
-@deftypefnx Instruction {} br-if-eqv u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
-@deftypefnx Instruction {} br-if-equal u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
-If the value in @var{a} is @code{eq?}, @code{eqv?}, or @code{equal?} to
-the value in @var{b}, respectively, add @var{offset} to the current
-instruction pointer.
+@deftypefn Instruction {} br-if-eq s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-eqv s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+If the value in @var{a} is @code{eq?} or @code{eqv?} to the value in
+@var{b}, respectively, add @var{offset} to the current instruction
+pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-= u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
-@deftypefnx Instruction {} br-if-< u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
-@deftypefnx Instruction {} br-if-<= u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-< s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-<= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the value in @var{a} is @code{=}, @code{<}, or @code{<=} to the value
in @var{b}, respectively, add @var{offset} to the current instruction
pointer.
@end deftypefn
-@deftypefn Instruction {} br-if-logtest u12:@var{a} u12:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefn Instruction {} br-if-logtest s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
If the bitwise intersection of the integers in @var{a} and @var{b} is
nonzero, add @var{offset} to the current instruction pointer.
@end deftypefn
@@ -967,17 +1040,17 @@ two kinds.
The first set of instructions loads immediate values. These
instructions encode the immediate directly into the instruction stream.
-@deftypefn Instruction {} make-short-immediate u8:@var{dst} i16:@var{low-bits}
+@deftypefn Instruction {} make-short-immediate s8:@var{dst} i16:@var{low-bits}
Make an immediate whose low bits are @var{low-bits}, and whose top bits are
0.
@end deftypefn
-@deftypefn Instruction {} make-long-immediate u24:@var{dst} i32:@var{low-bits}
+@deftypefn Instruction {} make-long-immediate s24:@var{dst} i32:@var{low-bits}
Make an immediate whose low bits are @var{low-bits}, and whose top bits are
0.
@end deftypefn
-@deftypefn Instruction {} make-long-long-immediate u24:@var{dst} a32:@var{high-bits} b32:@var{low-bits}
+@deftypefn Instruction {} make-long-long-immediate s24:@var{dst} a32:@var{high-bits} b32:@var{low-bits}
Make an immediate with @var{high-bits} and @var{low-bits}.
@end deftypefn
@@ -988,7 +1061,7 @@ compiled image. A reference to a string will use
@code{make-non-immediate} to treat a pointer into the compilation unit
as a @code{SCM} value directly.
-@deftypefn Instruction {} make-non-immediate u24:@var{dst} n32:@var{offset}
+@deftypefn Instruction {} make-non-immediate s24:@var{dst} n32:@var{offset}
Load a pointer to statically allocated memory into @var{dst}. The
object's memory is will be found @var{offset} 32-bit words away from the
current instruction pointer. Whether the object is mutable or immutable
@@ -1002,7 +1075,7 @@ initialize them when the compilation unit is loaded, storing them into a
slot in the image. References go indirectly through that slot.
@code{static-ref} is used in this case.
-@deftypefn Instruction {} static-ref u24:@var{dst} s32:@var{offset}
+@deftypefn Instruction {} static-ref s24:@var{dst} r32:@var{offset}
Load a @var{scm} value into @var{dst}. The @var{scm} value will be fetched from
memory, @var{offset} 32-bit words away from the current instruction
pointer. @var{offset} is a signed value.
@@ -1014,7 +1087,7 @@ the case, for example, for a pair containing a non-immediate in one of
its fields. @code{static-ref} and @code{static-patch!} are used in
these situations.
-@deftypefn Instruction {} static-set! u24:@var{src} lo32:@var{offset}
+@deftypefn Instruction {} static-set! s24:@var{src} lo32:@var{offset}
Store a @var{scm} value into memory, @var{offset} 32-bit words away from the
current instruction pointer. @var{offset} is a signed value.
@end deftypefn
@@ -1031,19 +1104,19 @@ case for vectors, strings, uniform vectors, pairs, and procedures with
no free variables. Other kinds of data might need special initializers;
those instructions follow.
-@deftypefn Instruction {} string->number u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} string->number s12:@var{dst} s12:@var{src}
Parse a string in @var{src} to a number, and store in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} string->symbol u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} string->symbol s12:@var{dst} s12:@var{src}
Parse a string in @var{src} to a symbol, and store in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} symbol->keyword u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} symbol->keyword s12:@var{dst} s12:@var{src}
Make a keyword from the symbol in @var{src}, and store it in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} load-typed-array u8:@var{dst} u8:@var{type} u8:@var{shape} n32:@var{offset} u32:@var{len}
+@deftypefn Instruction {} load-typed-array s24:@var{dst} x8:@var{_} s24:@var{type} x8:@var{_} s24:@var{shape} n32:@var{offset} u32:@var{len}
Load the contiguous typed array located at @var{offset} 32-bit words away
from the instruction pointer, and store into @var{dst}. @var{len} is a byte
length. @var{offset} is signed.
@@ -1075,7 +1148,7 @@ function, a call to @code{abort-to-prompt} looks like any other function
call.
@end deftypefn
-@deftypefn Instruction {} prompt u24:@var{tag} b1:@var{escape-only?} x7:@var{_} u24:@var{proc-slot} x8:@var{_} l24:@var{handler-offset}
+@deftypefn Instruction {} prompt s24:@var{tag} b1:@var{escape-only?} x7:@var{_} f24:@var{proc-slot} x8:@var{_} l24:@var{handler-offset}
Push a new prompt on the dynamic stack, with a tag from @var{tag} and a
handler at @var{handler-offset} words from the current @var{ip}.
@@ -1094,7 +1167,7 @@ continuation.
@xref{Prompts}, for more information on prompts.
@end deftypefn
-@deftypefn Instruction {} wind u12:@var{winder} u12:@var{unwinder}
+@deftypefn Instruction {} wind s12:@var{winder} s12:@var{unwinder}
Push wind and unwind procedures onto the dynamic stack. Note that
neither are actually called; the compiler should emit calls to wind and
unwind for the normal dynamic-wind control flow. Also note that the
@@ -1107,7 +1180,7 @@ thunks, if it could not prove that to be the case. @xref{Dynamic Wind}.
entry off of the dynamic stack.
@end deftypefn
-@deftypefn Instruction {} push-fluid u12:@var{fluid} u12:@var{value}
+@deftypefn Instruction {} push-fluid s12:@var{fluid} s12:@var{value}
Dynamically bind @var{value} to @var{fluid} by creating a with-fluids
object and pushing that object on the dynamic stack. @xref{Fluids and
Dynamic States}.
@@ -1119,14 +1192,30 @@ the fluid to its previous value. @code{push-fluid} should always be
balanced with @code{pop-fluid}.
@end deftypefn
-@deftypefn Instruction {} fluid-ref u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} fluid-ref s12:@var{dst} s12:@var{src}
Reference the fluid in @var{src}, and place the value in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} fluid-set u12:@var{fluid} u12:@var{val}
+@deftypefn Instruction {} fluid-set! s12:@var{fluid} s12:@var{val}
Set the value of the fluid in @var{dst} to the value in @var{src}.
@end deftypefn
+@deftypefn Instruction {} current-thread s24:@var{dst}
+Write the value of the current thread to @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} push-dynamic-state s24:@var{state}
+Save the current set of fluid bindings on the dynamic stack and instate
+the bindings from @var{state} instead. @xref{Fluids and Dynamic
+States}.
+@end deftypefn
+
+@deftypefn Instruction {} pop-dynamic-state x24:@var{_}
+Restore a saved set of fluid bindings from the dynamic stack.
+@code{push-dynamic-state} should always be balanced with
+@code{pop-dynamic-state}.
+@end deftypefn
+
@node Miscellaneous Instructions
@subsubsection Miscellaneous Instructions
@@ -1136,6 +1225,41 @@ Bring the VM to a halt, returning all the values from the stack. Used
in the ``boot continuation'', which is used when entering the VM from C.
@end deftypefn
+@deftypefn Instruction {} push s24:@var{src}
+Bump the stack pointer by one word, and fill it with the value from slot
+@var{src}. The offset to @var{src} is calculated before the stack
+pointer is adjusted.
+@end deftypefn
+
+The @code{push} instruction is used when another instruction is unable
+to address an operand because the operand is encoded with fewer than 24
+bits. In that case, Guile's assembler will transparently emit code that
+temporarily pushes any needed operands onto the stack, emits the
+original instruction to address those now-near variables, then shuffles
+the result (if any) back into place.
+
+@deftypefn Instruction {} pop s24:@var{dst}
+Pop the stack pointer, storing the value that was there in slot
+@var{dst}. The offset to @var{dst} is calculated after the stack
+pointer is adjusted.
+@end deftypefn
+
+@deftypefn Instruction {} drop c24:@var{count}
+Pop the stack pointer by @var{count} words, discarding any values that
+were stored there.
+@end deftypefn
+
+@deftypefn Instruction {} handle-interrupts x24:@var{_}
+Handle pending asynchronous interrupts (asyncs). @xref{Asyncs}. The
+compiler inserts @code{handle-interrupts} instructions before any call,
+return, or loop back-edge.
+@end deftypefn
+
+@deftypefn Instruction {} return-from-interrupt x24:@var{_}
+A special instruction to return from a call and also pop off the stack
+frame from the call. Used when returning from asynchronous interrupts.
+@end deftypefn
+
@node Inlined Scheme Instructions
@subsubsection Inlined Scheme Instructions
@@ -1145,107 +1269,162 @@ procedures. It tries to inline these small operations to avoid the
overhead of creating new stack frames. This allows the compiler to
optimize better.
-@deftypefn Instruction {} make-vector u8:@var{dst} u8:@var{length} u8:@var{init}
+@deftypefn Instruction {} make-vector s8:@var{dst} s8:@var{length} s8:@var{init}
Make a vector and write it to @var{dst}. The vector will have space for
@var{length} slots. They will be filled with the value in slot
@var{init}.
@end deftypefn
-@deftypefn Instruction {} make-vector/immediate u8:@var{dst} u8:@var{length} u8:@var{init}
+@deftypefn Instruction {} make-vector/immediate s8:@var{dst} s8:@var{length} c8:@var{init}
Make a short vector of known size and write it to @var{dst}. The vector
will have space for @var{length} slots, an immediate value. They will
be filled with the value in slot @var{init}.
@end deftypefn
-@deftypefn Instruction {} vector-length u12:@var{dst} u12:@var{src}
-Store the length of the vector in @var{src} in @var{dst}.
+@deftypefn Instruction {} vector-length s12:@var{dst} s12:@var{src}
+Store the length of the vector in @var{src} in @var{dst}, as an unboxed
+unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} vector-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
+@deftypefn Instruction {} vector-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
Fetch the item at position @var{idx} in the vector in @var{src}, and
-store it in @var{dst}.
+store it in @var{dst}. The @var{idx} value should be an unboxed
+unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} vector-ref/immediate u8:@var{dst} u8:@var{src} u8:@var{idx}
+@deftypefn Instruction {} vector-ref/immediate s8:@var{dst} s8:@var{src} c8:@var{idx}
Fill @var{dst} with the item @var{idx} elements into the vector at
@var{src}. Useful for building data types using vectors.
@end deftypefn
-@deftypefn Instruction {} vector-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-Store @var{src} into the vector @var{dst} at index @var{idx}.
+@deftypefn Instruction {} vector-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+Store @var{src} into the vector @var{dst} at index @var{idx}. The
+@var{idx} value should be an unboxed unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} vector-set!/immediate u8:@var{dst} u8:@var{idx} u8:@var{src}
+@deftypefn Instruction {} vector-set!/immediate s8:@var{dst} c8:@var{idx} s8:@var{src}
Store @var{src} into the vector @var{dst} at index @var{idx}. Here
@var{idx} is an immediate value.
@end deftypefn
-@deftypefn Instruction {} struct-vtable u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} struct-vtable s12:@var{dst} s12:@var{src}
Store the vtable of @var{src} into @var{dst}.
@end deftypefn
-@deftypefn Instruction {} allocate-struct u8:@var{dst} u8:@var{vtable} u8:@var{nfields}
+@deftypefn Instruction {} allocate-struct s8:@var{dst} s8:@var{vtable} s8:@var{nfields}
Allocate a new struct with @var{vtable}, and place it in @var{dst}. The
struct will be constructed with space for @var{nfields} fields, which
-should correspond to the field count of the @var{vtable}.
+should correspond to the field count of the @var{vtable}. The @var{idx}
+value should be an unboxed unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} struct-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
+@deftypefn Instruction {} struct-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
Fetch the item at slot @var{idx} in the struct in @var{src}, and store
-it in @var{dst}.
+it in @var{dst}. The @var{idx} value should be an unboxed unsigned
+64-bit integer.
@end deftypefn
-@deftypefn Instruction {} struct-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-Store @var{src} into the struct @var{dst} at slot @var{idx}.
+@deftypefn Instruction {} struct-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+Store @var{src} into the struct @var{dst} at slot @var{idx}. The
+@var{idx} value should be an unboxed unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} allocate-struct/immediate u8:@var{dst} u8:@var{vtable} u8:@var{nfields}
-@deftypefnx Instruction {} struct-ref/immediate u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} struct-set!/immediate u8:@var{dst} u8:@var{idx} u8:@var{src}
+@deftypefn Instruction {} allocate-struct/immediate s8:@var{dst} s8:@var{vtable} c8:@var{nfields}
+@deftypefnx Instruction {} struct-ref/immediate s8:@var{dst} s8:@var{src} c8:@var{idx}
+@deftypefnx Instruction {} struct-set!/immediate s8:@var{dst} c8:@var{idx} s8:@var{src}
Variants of the struct instructions, but in which the @var{nfields} or
@var{idx} fields are immediate values.
@end deftypefn
-@deftypefn Instruction {} class-of u12:@var{dst} u12:@var{type}
+@deftypefn Instruction {} class-of s12:@var{dst} s12:@var{type}
Store the vtable of @var{src} into @var{dst}.
@end deftypefn
-@deftypefn Instruction {} make-array u8:@var{dst} u8:@var{type} u8:@var{fill} x8:@var{_} u24:@var{bounds}
+@deftypefn Instruction {} make-array s24:@var{dst} x8:@var{_} s24:@var{type} x8:@var{_} s24:@var{fill} x8:@var{_} s24:@var{bounds}
Make a new array with @var{type}, @var{fill}, and @var{bounds}, storing it in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} string-length u12:@var{dst} u12:@var{src}
-Store the length of the string in @var{src} in @var{dst}.
+@deftypefn Instruction {} string-length s12:@var{dst} s12:@var{src}
+Store the length of the string in @var{src} in @var{dst}, as an unboxed
+unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} string-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-Fetch the character at position @var{idx} in the string in @var{src}, and store
-it in @var{dst}.
+@deftypefn Instruction {} string-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+Fetch the character at position @var{idx} in the string in @var{src},
+and store it in @var{dst}. The @var{idx} value should be an unboxed
+unsigned 64-bit integer.
@end deftypefn
-@deftypefn Instruction {} cons u8:@var{dst} u8:@var{car} u8:@var{cdr}
+@deftypefn Instruction {} string-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+Store the character @var{src} into the string @var{dst} at index
+@var{idx}. The @var{idx} value should be an unboxed unsigned 64-bit
+integer.
+@end deftypefn
+
+@deftypefn Instruction {} cons s8:@var{dst} s8:@var{car} s8:@var{cdr}
Cons @var{car} and @var{cdr}, and store the result in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} car u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} car s12:@var{dst} s12:@var{src}
Place the car of @var{src} in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} cdr u12:@var{dst} u12:@var{src}
+@deftypefn Instruction {} cdr s12:@var{dst} s12:@var{src}
Place the cdr of @var{src} in @var{dst}.
@end deftypefn
-@deftypefn Instruction {} set-car! u12:@var{pair} u12:@var{car}
+@deftypefn Instruction {} set-car! s12:@var{pair} s12:@var{car}
Set the car of @var{dst} to @var{src}.
@end deftypefn
-@deftypefn Instruction {} set-cdr! u12:@var{pair} u12:@var{cdr}
+@deftypefn Instruction {} set-cdr! s12:@var{pair} s12:@var{cdr}
Set the cdr of @var{dst} to @var{src}.
@end deftypefn
Note that @code{caddr} and friends compile to a series of @code{car}
and @code{cdr} instructions.
+@deftypefn Instruction {} integer->char s12:@var{dst} s12:@var{src}
+Convert the @code{u64} value in @var{src} to a Scheme character, and
+place it in @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} char->integer s12:@var{dst} s12:@var{src}
+Convert the Scheme character in @var{src} to an integer, and place it in
+@var{dst} as an unboxed @code{u64} value.
+@end deftypefn
+
+
+@node Inlined Atomic Instructions
+@subsubsection Inlined Atomic Instructions
+
+@xref{Atomics}, for more on atomic operations in Guile.
+
+@deftypefn Instruction {} make-atomic-box s12:@var{dst} s12:@var{src}
+Create a new atomic box initialized to @var{src}, and place it in
+@var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} atomic-box-ref s12:@var{dst} s12:@var{box}
+Fetch the value of the atomic box at @var{box} into @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} atomic-box-set! s12:@var{box} s12:@var{val}
+Set the contents of the atomic box at @var{box} to @var{val}.
+@end deftypefn
+
+@deftypefn Instruction {} atomic-box-swap! s12:@var{dst} s12:@var{box} x8:@var{_} s24:@var{val}
+Replace the contents of the atomic box at @var{box} to @var{val} and
+store the previous value at @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} atomic-box-compare-and-swap! s12:@var{dst} s12:@var{box} x8:@var{_} s24:@var{expected} x8:@var{_} s24:@var{desired}
+If the value of the atomic box at @var{box} is the same as the SCM value
+at @var{expected} (in the sense of @code{eq?}), replace the contents of
+the box with the SCM value at @var{desired}. Otherwise does not update
+the box. Set @var{dst} to the previous value of the box in either case.
+@end deftypefn
+
@node Inlined Mathematical Instructions
@subsubsection Inlined Mathematical Instructions
@@ -1260,58 +1439,62 @@ More instructions could be added here over time.
All of these operations place their result in their first operand,
@var{dst}.
-@deftypefn Instruction {} add u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} add s8:@var{dst} s8:@var{a} s8:@var{b}
Add @var{a} to @var{b}.
@end deftypefn
-@deftypefn Instruction {} add1 u12:@var{dst} u12:@var{src}
-Add 1 to the value in @var{src}.
+@deftypefn Instruction {} add/immediate s8:@var{dst} s8:@var{src} c8:@var{imm}
+Add the unsigned integer @var{imm} to the value in @var{src}.
@end deftypefn
-@deftypefn Instruction {} sub u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} sub s8:@var{dst} s8:@var{a} s8:@var{b}
Subtract @var{b} from @var{a}.
@end deftypefn
-@deftypefn Instruction {} sub1 u12:@var{dst} u12:@var{src}
-Subtract 1 from @var{src}.
+@deftypefn Instruction {} sub/immediate s8:@var{dst} s8:@var{src} s8:@var{imm}
+Subtract the unsigned integer @var{imm} from the value in @var{src}.
@end deftypefn
-@deftypefn Instruction {} mul u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} mul s8:@var{dst} s8:@var{a} s8:@var{b}
Multiply @var{a} and @var{b}.
@end deftypefn
-@deftypefn Instruction {} div u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} div s8:@var{dst} s8:@var{a} s8:@var{b}
Divide @var{a} by @var{b}.
@end deftypefn
-@deftypefn Instruction {} quo u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} quo s8:@var{dst} s8:@var{a} s8:@var{b}
Divide @var{a} by @var{b}.
@end deftypefn
-@deftypefn Instruction {} rem u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} rem s8:@var{dst} s8:@var{a} s8:@var{b}
Divide @var{a} by @var{b}.
@end deftypefn
-@deftypefn Instruction {} mod u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} mod s8:@var{dst} s8:@var{a} s8:@var{b}
Compute the modulo of @var{a} by @var{b}.
@end deftypefn
-@deftypefn Instruction {} ash u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} ash s8:@var{dst} s8:@var{a} s8:@var{b}
Shift @var{a} arithmetically by @var{b} bits.
@end deftypefn
-@deftypefn Instruction {} logand u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} logand s8:@var{dst} s8:@var{a} s8:@var{b}
Compute the bitwise @code{and} of @var{a} and @var{b}.
@end deftypefn
-@deftypefn Instruction {} logior u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} logior s8:@var{dst} s8:@var{a} s8:@var{b}
Compute the bitwise inclusive @code{or} of @var{a} with @var{b}.
@end deftypefn
-@deftypefn Instruction {} logxor u8:@var{dst} u8:@var{a} u8:@var{b}
+@deftypefn Instruction {} logxor s8:@var{dst} s8:@var{a} s8:@var{b}
Compute the bitwise exclusive @code{or} of @var{a} with @var{b}.
@end deftypefn
+@deftypefn Instruction {} logsub s8:@var{dst} s8:@var{a} s8:@var{b}
+Place the bitwise @code{and} of @var{a} and the bitwise @code{not} of
+@var{b} into @var{dst}.
+@end deftypefn
@node Inlined Bytevector Instructions
@subsubsection Inlined Bytevector Instructions
@@ -1322,32 +1505,188 @@ a clear path for eventual native compilation. Without this, Scheme
programs would need other primitives for accessing raw bytes -- but
these primitives are as good as any.
-@deftypefn Instruction {} bv-u8-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-s8-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-u16-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-s16-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-u32-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-s32-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-u64-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-s64-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-f32-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
-@deftypefnx Instruction {} bv-f64-ref u8:@var{dst} u8:@var{src} u8:@var{idx}
+@deftypefn Instruction {} bv-length s12:@var{dst} s12:@var{src}
+Store the length of the bytevector in @var{src} in @var{dst}, as an
+unboxed unsigned 64-bit integer.
+@end deftypefn
+
+@deftypefn Instruction {} bv-u8-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-s8-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-u16-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-s16-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-u32-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-s32-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-u64-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-s64-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-f32-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
+@deftypefnx Instruction {} bv-f64-ref s8:@var{dst} s8:@var{src} s8:@var{idx}
Fetch the item at byte offset @var{idx} in the bytevector @var{src}, and
store it in @var{dst}. All accesses use native endianness.
+
+The @var{idx} value should be an unboxed unsigned 64-bit integer.
+
+The results are all written to the stack as unboxed values, either as
+signed 64-bit integers, unsigned 64-bit integers, or IEEE double
+floating point numbers.
@end deftypefn
-@deftypefn Instruction {} bv-u8-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-s8-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-u16-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-s16-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-u32-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-s32-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-u64-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-s64-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-f32-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
-@deftypefnx Instruction {} bv-f64-set! u8:@var{dst} u8:@var{idx} u8:@var{src}
+@deftypefn Instruction {} bv-u8-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-s8-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-u16-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-s16-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-u32-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-s32-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-u64-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-s64-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-f32-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
+@deftypefnx Instruction {} bv-f64-set! s8:@var{dst} s8:@var{idx} s8:@var{src}
Store @var{src} into the bytevector @var{dst} at byte offset @var{idx}.
Multibyte values are written using native endianness.
+
+The @var{idx} value should be an unboxed unsigned 64-bit integer.
+
+The @var{src} values are all unboxed, either as signed 64-bit integers,
+unsigned 64-bit integers, or IEEE double floating point numbers.
+@end deftypefn
+
+
+@node Unboxed Integer Arithmetic
+@subsubsection Unboxed Integer Arithmetic
+
+Guile supports two kinds of unboxed integers: unsigned 64-bit integers,
+and signed 64-bit integers. Guile prefers unsigned integers, in the
+sense that Guile's compiler supports them better and the virtual machine
+has more operations that work on them. Still, signed integers are
+supported at least to allow @code{bv-s64-ref} and related instructions
+to avoid boxing their values.
+
+@deftypefn Instruction {} scm->u64 s12:@var{dst} s12:@var{src}
+Unbox the SCM value at @var{src} to a unsigned 64-bit integer, placing
+the result in @var{dst}. If the @var{src} value is not an exact integer
+in the unsigned 64-bit range, signal an error.
+@end deftypefn
+
+@deftypefn Instruction {} u64->scm s12:@var{dst} s12:@var{src}
+Box the unsigned 64-bit integer at @var{src} to a SCM value and place
+the result in @var{dst}. The result will be a fixnum or a bignum.
+@end deftypefn
+
+@deftypefn Instruction {} load-u64 s24:@var{dst} au32:@var{high-bits} au32:@var{low-bits}
+Load a 64-bit value formed by joining @var{high-bits} and
+@var{low-bits}, and write it to @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} scm->s64 s12:@var{dst} s12:@var{src}
+@deftypefnx Instruction {} s64->scm s12:@var{dst} s12:@var{src}
+@deftypefnx Instruction {} load-s64 s24:@var{dst} as32:@var{high-bits} as32:@var{low-bits}
+Like @code{scm->u64}, @code{u64->scm}, and @code{load-u64}, but for
+signed 64-bit integers.
+@end deftypefn
+
+Sometimes the compiler can know that we will only need a subset of the
+bits in an integer. In that case we can sometimes unbox an integer even
+if it might be out of range.
+
+@deftypefn Instruction {} scm->u64/truncate s12:@var{dst} s12:@var{src}
+Take the SCM value in @var{dst} and @code{logand} it with @code{(1- (ash
+1 64))}. Place the unboxed result in @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} br-if-u64-= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-u64-< s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-u64-<= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+If the unboxed unsigned 64-bit integer value in @var{a} is @code{=},
+@code{<}, or @code{<=} to the unboxed unsigned 64-bit integer value in
+@var{b}, respectively, add @var{offset} to the current instruction
+pointer.
+@end deftypefn
+
+@deftypefn Instruction {} br-if-u64-=-scm s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-u64-<-scm s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-u64-<=-scm s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+If the unboxed unsigned 64-bit integer value in @var{a} is @code{=},
+@code{<}, or @code{<=} to the SCM value in @var{b}, respectively, add
+@var{offset} to the current instruction pointer.
+@end deftypefn
+
+@deftypefn Instruction {} uadd s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} usub s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} umul s8:@var{dst} s8:@var{a} s8:@var{b}
+Like @code{add}, @code{sub}, and @code{mul}, except taking
+the operands as unboxed unsigned 64-bit integers, and producing the
+same. The result will be silently truncated to 64 bits.
+@end deftypefn
+
+@deftypefn Instruction {} uadd/immediate s8:@var{dst} s8:@var{a} c8:@var{b}
+@deftypefnx Instruction {} usub/immediate s8:@var{dst} s8:@var{a} c8:@var{b}
+@deftypefnx Instruction {} umul/immediate s8:@var{dst} s8:@var{a} c8:@var{b}
+Like @code{uadd}, @code{usub}, and @code{umul}, except the second
+operand is an immediate unsigned 8-bit integer.
+@end deftypefn
+
+@deftypefn Instruction {} ulogand s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} ulogior s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} ulogxor s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} ulogsub s8:@var{dst} s8:@var{a} s8:@var{b}
+Like @code{logand}, @code{logior}, @code{logxor}, and @code{logsub}, but
+operating on unboxed unsigned 64-bit integers.
+@end deftypefn
+
+@deftypefn Instruction {} ulsh s8:@var{dst} s8:@var{a} s8:@var{b}
+Shift the unboxed unsigned 64-bit integer in @var{a} left by @var{b}
+bits, also an unboxed unsigned 64-bit integer. Truncate to 64 bits and
+write to @var{dst} as an unboxed value. Only the lower 6 bits of
+@var{b} are used.
+@end deftypefn
+
+@deftypefn Instruction {} ursh s8:@var{dst} s8:@var{a} s8:@var{b}
+Like @code{ulsh}, but shifting right.
+@end deftypefn
+
+@deftypefn Instruction {} ulsh/immediate s8:@var{dst} s8:@var{a} c8:@var{b}
+@deftypefnx Instruction {} ursh/immediate s8:@var{dst} s8:@var{a} c8:@var{b}
+Like @code{ulsh} and @code{ursh}, but encoding @code{b} as an immediate
+8-bit unsigned integer.
+@end deftypefn
+
+
+@node Unboxed Floating-Point Arithmetic
+@subsubsection Unboxed Floating-Point Arithmetic
+
+@deftypefn Instruction {} scm->f64 s12:@var{dst} s12:@var{src}
+Unbox the SCM value at @var{src} to an IEEE double, placing the result
+in @var{dst}. If the @var{src} value is not a real number, signal an
+error.
+@end deftypefn
+
+@deftypefn Instruction {} f64->scm s12:@var{dst} s12:@var{src}
+Box the IEEE double at @var{src} to a SCM value and place the result in
+@var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} load-f64 s24:@var{dst} au32:@var{high-bits} au32:@var{low-bits}
+Load a 64-bit value formed by joining @var{high-bits} and
+@var{low-bits}, and write it to @var{dst}.
+@end deftypefn
+
+@deftypefn Instruction {} fadd s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} fsub s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} fmul s8:@var{dst} s8:@var{a} s8:@var{b}
+@deftypefnx Instruction {} fdiv s8:@var{dst} s8:@var{a} s8:@var{b}
+Like @code{add}, @code{sub}, @code{div}, and @code{mul}, except taking
+the operands as unboxed IEEE double floating-point numbers, and producing
+the same.
+@end deftypefn
+
+@deftypefn Instruction {} br-if-f64-= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-f64-< s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-f64-<= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-f64-> s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+@deftypefnx Instruction {} br-if-f64->= s24:@var{a} x8:@var{_} s24:@var{b} b1:@var{invert} x7:@var{_} l24:@var{offset}
+If the unboxed IEEE double value in @var{a} is @code{=}, @code{<},
+@code{<=}, @code{>}, or @code{>=} to the unboxed IEEE double value in
+@var{b}, respectively, add @var{offset} to the current instruction
+pointer.
@end deftypefn
diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 2311b8225..7c6a9545e 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -173,23 +173,13 @@ Guile provides a standard data type for Universal Resource Identifiers
The generic URI syntax is as follows:
@example
-URI := scheme ":" ["//" [userinfo "@@"] host [":" port]] path \
- [ "?" query ] [ "#" fragment ]
+URI-reference := [scheme ":"] ["//" [userinfo "@@"] host [":" port]] path \
+ [ "?" query ] [ "#" fragment ]
@end example
For example, in the URI, @indicateurl{http://www.gnu.org/help/}, the
scheme is @code{http}, the host is @code{www.gnu.org}, the path is
-@code{/help/}, and there is no userinfo, port, query, or fragment. All
-URIs have a scheme and a path (though the path might be empty). Some
-URIs have a host, and some of those have ports and userinfo. Any URI
-might have a query part or a fragment.
-
-There is also a ``URI-reference'' data type, which is the same as a URI
-but where the scheme is optional. In this case, the scheme is taken to
-be relative to some other related URI. A common use of URI references
-is when you want to be vague regarding the choice of HTTP or HTTPS --
-serving a web page referring to @code{/foo.css} will use HTTPS if loaded
-over HTTPS, or HTTP otherwise.
+@code{/help/}, and there is no userinfo, port, query, or fragment.
Userinfo is something of an abstraction, as some legacy URI schemes
allowed userinfo of the form @code{@var{username}:@var{passwd}}. But
@@ -197,14 +187,6 @@ since passwords do not belong in URIs, the RFC does not want to condone
this practice, so it calls anything before the @code{@@} sign
@dfn{userinfo}.
-Properly speaking, a fragment is not part of a URI. For example, when a
-web browser follows a link to @indicateurl{http://example.com/#foo}, it
-sends a request for @indicateurl{http://example.com/}, then looks in the
-resulting page for the fragment identified @code{foo} reference. A
-fragment identifies a part of a resource, not the resource itself. But
-it is useful to have a fragment field in the URI record itself, so we
-hope you will forgive the inconsistency.
-
@example
(use-modules (web uri))
@end example
@@ -213,40 +195,36 @@ The following procedures can be found in the @code{(web uri)}
module. Load it into your Guile, using a form like the above, to have
access to them.
+The most common way to build a URI from Scheme is with the
+@code{build-uri} function.
+
@deffn {Scheme Procedure} build-uri scheme @
[#:userinfo=@code{#f}] [#:host=@code{#f}] [#:port=@code{#f}] @
[#:path=@code{""}] [#:query=@code{#f}] [#:fragment=@code{#f}] @
[#:validate?=@code{#t}]
-Construct a URI object. @var{scheme} should be a symbol, @var{port}
-either a positive, exact integer or @code{#f}, and the rest of the
-fields are either strings or @code{#f}. If @var{validate?} is true,
-also run some consistency checks to make sure that the constructed URI
-is valid.
+Construct a URI. @var{scheme} should be a symbol, @var{port} either a
+positive, exact integer or @code{#f}, and the rest of the fields are
+either strings or @code{#f}. If @var{validate?} is true, also run some
+consistency checks to make sure that the constructed URI is valid.
@end deffn
-
-@deffn {Scheme Procedure} build-uri-reference [#:scheme=@code{#f}]@
- [#:userinfo=@code{#f}] [#:host=@code{#f}] [#:port=@code{#f}] @
- [#:path=@code{""}] [#:query=@code{#f}] [#:fragment=@code{#f}] @
- [#:validate?=@code{#t}]
-Like @code{build-uri}, but with an optional scheme.
-@end deffn
-
-In Guile, both URI and URI reference data types are represented in the
-same way, as URI objects.
-
@deffn {Scheme Procedure} uri? obj
-@deffnx {Scheme Procedure} uri-scheme uri
+Return @code{#t} if @var{obj} is a URI.
+@end deffn
+
+Guile, URIs are represented as URI records, with a number of associated
+accessors.
+
+@deffn {Scheme Procedure} uri-scheme uri
@deffnx {Scheme Procedure} uri-userinfo uri
@deffnx {Scheme Procedure} uri-host uri
@deffnx {Scheme Procedure} uri-port uri
@deffnx {Scheme Procedure} uri-path uri
@deffnx {Scheme Procedure} uri-query uri
@deffnx {Scheme Procedure} uri-fragment uri
-A predicate and field accessors for the URI record type. The URI scheme
-will be a symbol, or @code{#f} if the object is a URI reference but not
-a URI. The port will be either a positive, exact integer or @code{#f},
-and the rest of the fields will be either strings or @code{#f} if not
-present.
+Field accessors for the URI record type. The URI scheme will be a
+symbol, or @code{#f} if the object is a relative-ref (see below). The
+port will be either a positive, exact integer or @code{#f}, and the rest
+of the fields will be either strings or @code{#f} if not present.
@end deffn
@deffn {Scheme Procedure} string->uri string
@@ -254,22 +232,18 @@ Parse @var{string} into a URI object. Return @code{#f} if the string
could not be parsed.
@end deffn
-@deffn {Scheme Procedure} string->uri-reference string
-Parse @var{string} into a URI object, while not requiring a scheme.
-Return @code{#f} if the string could not be parsed.
-@end deffn
-
-@deffn {Scheme Procedure} uri->string uri
+@deffn {Scheme Procedure} uri->string uri [#:include-fragment?=@code{#t}]
Serialize @var{uri} to a string. If the URI has a port that is the
default port for its scheme, the port is not included in the
-serialization.
+serialization. If @var{include-fragment?} is given as false, the
+resulting string will omit the fragment (if any).
@end deffn
@deffn {Scheme Procedure} declare-default-port! scheme port
Declare a default port for the given URI scheme.
@end deffn
-@deffn {Scheme Procedure} uri-decode str [#:encoding=@code{"utf-8"}]
+@deffn {Scheme Procedure} uri-decode str [#:encoding=@code{"utf-8"}] [#:decode-plus-to-space? #t]
Percent-decode the given @var{str}, according to @var{encoding}, which
should be the name of a character encoding.
@@ -286,6 +260,11 @@ decoded bytes are not valid for the given encoding. Pass @code{#f} for
@xref{Ports, @code{set-port-encoding!}}, for more information on
character encodings.
+If @var{decode-plus-to-space?} is true, which is the default, also
+replace instances of the plus character @samp{+} with a space character.
+This is needed when parsing @code{application/x-www-form-urlencoded}
+data.
+
Returns a string of the decoded characters, or a bytevector if
@var{encoding} was @code{#f}.
@end deffn
@@ -318,6 +297,70 @@ For example, the list @code{("scrambled eggs" "biscuits&gravy")} encodes
as @code{"scrambled%20eggs/biscuits%26gravy"}.
@end deffn
+@subsubheading Subtypes of URI
+
+As we noted above, not all URI objects have a scheme. You might have
+noted in the ``generic URI syntax'' example that the left-hand side of
+that grammar definition was URI-reference, not URI. A
+@dfn{URI-reference} is a generalization of a URI where the scheme is
+optional. If no scheme is specified, it is taken to be relative to some
+other related URI. A common use of URI references is when you want to
+be vague regarding the choice of HTTP or HTTPS -- serving a web page
+referring to @code{/foo.css} will use HTTPS if loaded over HTTPS, or
+HTTP otherwise.
+
+@deffn {Scheme Procedure} build-uri-reference [#:scheme=@code{#f}]@
+ [#:userinfo=@code{#f}] [#:host=@code{#f}] [#:port=@code{#f}] @
+ [#:path=@code{""}] [#:query=@code{#f}] [#:fragment=@code{#f}] @
+ [#:validate?=@code{#t}]
+Like @code{build-uri}, but with an optional scheme.
+@end deffn
+@deffn {Scheme Procedure} uri-reference? obj
+Return @code{#t} if @var{obj} is a URI-reference. This is the most
+general URI predicate, as it includes not only full URIs that have
+schemes (those that match @code{uri?}) but also URIs without schemes.
+@end deffn
+
+It's also possible to build a @dfn{relative-ref}: a URI-reference that
+explicitly lacks a scheme.
+
+@deffn {Scheme Procedure} build-relative-ref @
+ [#:userinfo=@code{#f}] [#:host=@code{#f}] [#:port=@code{#f}] @
+ [#:path=@code{""}] [#:query=@code{#f}] [#:fragment=@code{#f}] @
+ [#:validate?=@code{#t}]
+Like @code{build-uri}, but with no scheme.
+@end deffn
+@deffn {Scheme Procedure} relative-ref? obj
+Return @code{#t} if @var{obj} is a ``relative-ref'': a URI-reference
+that has no scheme. Every URI-reference will either match @code{uri?}
+or @code{relative-ref?} (but not both).
+@end deffn
+
+In case it's not clear from the above, the most general of these URI
+types is the URI-reference, with @code{build-uri-reference} as the most
+general constructor. @code{build-uri} and @code{build-relative-ref}
+enforce enforce specific restrictions on the URI-reference. The most
+generic URI parser is then @code{string->uri-reference}, and there is
+also a parser for when you know that you want a relative-ref.
+
+@deffn {Scheme Procedure} string->uri-reference string
+Parse @var{string} into a URI object, while not requiring a scheme.
+Return @code{#f} if the string could not be parsed.
+@end deffn
+
+@deffn {Scheme Procedure} string->relative-ref string
+Parse @var{string} into a URI object, while asserting that no scheme is
+present. Return @code{#f} if the string could not be parsed.
+@end deffn
+
+For compatibility reasons, note that @code{uri?} will return @code{#t}
+for all URI objects, even relative-refs. In contrast, @code{build-uri}
+and @code{string->uri} require that the resulting URI not be a
+relative-ref. As a predicate to distinguish relative-refs from proper
+URIs (in the language of RFC 3986), use something like @code{(and
+(uri-reference? @var{x}) (not (relative-ref? @var{x})))}.
+
+
@node HTTP
@subsection The Hyper-Text Transfer Protocol
@@ -747,9 +790,9 @@ a resource.
@deftypevr {HTTP Header} List content-type
The MIME type of a resource, as a symbol, along with any parameters.
@example
-(parse-header 'content-length "text/plain")
+(parse-header 'content-type "text/plain")
@result{} (text/plain)
-(parse-header 'content-length "text/plain;charset=utf-8")
+(parse-header 'content-type "text/plain;charset=utf-8")
@result{} (text/plain (charset . "utf-8"))
@end example
Note that the @code{charset} parameter is something is a misnomer, and
@@ -1417,7 +1460,11 @@ the lower-level HTTP, request, and response modules.
@end example
@deffn {Scheme Procedure} open-socket-for-uri uri
-Return an open input/output port for a connection to URI.
+Return an open input/output port for a connection to URI. Guile
+dynamically loads GnuTLS for HTTPS support.
+@xref{Guile Preparations,
+how to install the GnuTLS bindings for Guile,, gnutls-guile,
+GnuTLS-Guile}, for more information.
@end deffn
@deffn {Scheme Procedure} http-get uri arg...
diff --git a/doc/release.org b/doc/release.org
index 875ec27ff..9a38445a1 100644
--- a/doc/release.org
+++ b/doc/release.org
@@ -1,9 +1,9 @@
-#+TITLE: Release Process for GNU Guile 2.0
+#+TITLE: Release Process for GNU Guile 2.2
#+AUTHOR: Ludovic Courtès
#+STARTUP: content
#+EMAIL: ludo@gnu.org
-This document describes the typical release process for Guile 2.0.
+This document describes the typical release process for Guile 2.2.
* Preparing & uploading the tarball
@@ -69,17 +69,16 @@ if in doubt.
`libguile/libguile.map' should also be updated as new public symbols are
added. Ideally, new symbols should get under a new version
-symbol---e.g., `GUILE_2.0.3' for symbols introduced in Guile 2.0.3.
-However, this has not been done for Guile <= 2.0.2.
+symbol---e.g., `GUILE_2.2.3' for symbols introduced in Guile 2.2.3.
-** Tag v2.0.x
+** Tag v2.2.x
Create a signed Git tag, like this:
- $ git tag -s -u MY-KEY -m "GNU Guile 2.0.X." v2.0.X
+ $ git tag -s -u MY-KEY -m "GNU Guile 2.2.X." v2.2.X
-The tag *must* be `v2.0.X'. For the sake of consistency, always use
-"GNU Guile 2.0.X." as the tag comment.
+The tag *must* be `v2.2.X'. For the sake of consistency, always use
+"GNU Guile 2.2.X." as the tag comment.
** Push the tag and changes
@@ -98,7 +97,7 @@ reports the new version number.
** Upload
- $ ./build-aux/gnupload --to ftp.gnu.org:guile guile-2.0.X.tar.gz
+ $ ./build-aux/gnupload --to ftp.gnu.org:guile guile-2.2.X.tar.gz
You'll get an email soon after when the upload is complete.
@@ -115,10 +114,10 @@ Make sure the file was uploaded and is available for download as
expected:
$ mkdir t && cd t && \
- wget ftp.gnu.org/gnu/guile/guile-2.0.X.tar.gz && \
- wget ftp.gnu.org/gnu/guile/guile-2.0.X.tar.xz
- $ diff guile-2.0.X.tar.gz ../guile-2.0.X.tar.gz
- $ diff guile-2.0.X.tar.xz ../guile-2.0.X.tar.xz
+ wget ftp.gnu.org/gnu/guile/guile-2.2.X.tar.gz && \
+ wget ftp.gnu.org/gnu/guile/guile-2.2.X.tar.xz
+ $ diff guile-2.2.X.tar.gz ../guile-2.2.X.tar.gz
+ $ diff guile-2.2.X.tar.xz ../guile-2.2.X.tar.xz
You're almost done!
@@ -138,17 +137,17 @@ Announcements").
Use `build-aux/gendocs', add to the manual/ directory of the web site.
$ cd doc/ref
- $ ../../build-aux/gendocs.sh guile "GNU Guile 2.0.X Reference Manual"
+ $ ../../build-aux/gendocs.sh guile "GNU Guile 2.2.X Reference Manual"
** Prepare the email announcement
$ build-aux/announce-gen --release-type=stable --package-name=guile \
- --previous-version=2.0.1 --current-version=2.0.2 \
+ --previous-version=2.2.1 --current-version=2.2.2 \
--gpg-key-id=MY-KEY --url-directory=ftp://ftp.gnu.org/gnu/guile \
--bootstrap-tools=autoconf,automake,libtool,gnulib,makeinfo \
--gnulib-version=$( cd ~/src/gnulib ; git describe )
-The subject must be "GNU Guile 2.0.X released". The text should remain
+The subject must be "GNU Guile 2.2.X released". The text should remain
formal and impersonal (it is sent on behalf of the Guile and GNU
projects.) It must include a description of what Guile is (not everyone
reading info-gnu may know about it.) Use the text of previous
@@ -173,7 +172,7 @@ more informal, with a link to the email announcement for details.
-Copyright © 2011, 2012, 2013 Free Software Foundation, Inc.
+Copyright © 2011, 2012, 2013, 2017 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
diff --git a/gnulib-local/build-aux/git-version-gen.diff b/gnulib-local/build-aux/git-version-gen.diff
index f875f49d9..8451701d5 100644
--- a/gnulib-local/build-aux/git-version-gen.diff
+++ b/gnulib-local/build-aux/git-version-gen.diff
@@ -2,17 +2,19 @@ This patch is being discussed
at .
Remove when integrated in Gnulib.
+diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
+index bd2c4b6..4458d7d 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -86,6 +86,7 @@ Print a version string.
Options:
- --prefix prefix of git tags (default 'v')
+ --prefix PREFIX prefix of git tags (default 'v')
+ --match pattern for git tags to match (default: '\$prefix*')
- --fallback fallback version to use if \"git --version\" fails
+ --fallback VERSION
+ fallback version to use if \"git --version\" fails
- --help display this help and exit
-@@ -96,11 +97,15 @@ Running without arguments will suffice in most cases."
+@@ -97,11 +98,15 @@ Running without arguments will suffice in most cases."
prefix=v
fallback=
@@ -23,12 +25,12 @@ Remove when integrated in Gnulib.
case $1 in
--help) echo "$usage"; exit 0;;
--version) echo "$version"; exit 0;;
- --prefix) shift; prefix="$1";;
+ --prefix) shift; prefix=${1?};;
+ --match) shift; match="$1";;
- --fallback) shift; fallback="$1";;
+ --fallback) shift; fallback=${1?};;
-*)
echo "$0: Unknown option '$1'." >&2
-@@ -124,6 +129,7 @@ if test "x$tarball_version_file" = x; then
+@@ -125,6 +130,7 @@ if test "x$tarball_version_file" = x; then
exit 1
fi
@@ -36,7 +38,7 @@ Remove when integrated in Gnulib.
tag_sed_script="${tag_sed_script:-s/x/x/}"
nl='
-@@ -154,7 +160,7 @@ then
+@@ -155,7 +161,7 @@ then
# directory, and "git describe" output looks sensible, use that to
# derive a version string.
elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
diff --git a/guile-readline/readline.c b/guile-readline/readline.c
index aac6e18c2..c15275dd3 100644
--- a/guile-readline/readline.c
+++ b/guile-readline/readline.c
@@ -2,17 +2,17 @@
/* Copyright (C) 1997,1999,2000,2001, 2002, 2003, 2006, 2007, 2008,
* 2009, 2010, 2013 Free Software Foundation, Inc.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -47,12 +47,14 @@ scm_t_option scm_readline_opts[] = {
"History length." },
{ SCM_OPTION_INTEGER, "bounce-parens", 500,
"Time (ms) to show matching opening parenthesis (0 = off)."},
+ { SCM_OPTION_BOOLEAN, "bracketed-paste", 1,
+ "Disable interpretation of control characters in pastes." },
{ 0 }
};
extern void stifle_history (int max);
-SCM_DEFINE (scm_readline_options, "readline-options-interface", 0, 1, 0,
+SCM_DEFINE (scm_readline_options, "readline-options-interface", 0, 1, 0,
(SCM setting),
"")
#define FUNC_NAME s_scm_readline_options
@@ -60,7 +62,9 @@ SCM_DEFINE (scm_readline_options, "readline-options-interface", 0, 1, 0,
SCM ans = scm_options (setting,
scm_readline_opts,
FUNC_NAME);
- stifle_history (SCM_HISTORY_LENGTH);
+ if (!SCM_UNBNDP (setting)) {
+ stifle_history (SCM_HISTORY_LENGTH);
+ }
return ans;
}
#undef FUNC_NAME
@@ -107,13 +111,13 @@ void
rl_free_line_state ()
{
register HIST_ENTRY *entry;
-
+
free_undo_list ();
entry = current_history ();
if (entry)
- entry->data = (char *)NULL;
-
+ entry->data = (char *)NULL;
+
_rl_kill_kbd_macro ();
rl_clear_message ();
_rl_init_argument ();
@@ -145,15 +149,15 @@ static void unwind_readline (void *unused);
static void reentry_barrier (void);
-SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
+SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
(SCM text, SCM inp, SCM outp, SCM read_hook),
"")
#define FUNC_NAME s_scm_readline
{
SCM ans;
-
+
reentry_barrier ();
-
+
before_read = SCM_BOOL_F;
if (!SCM_UNBNDP (text))
@@ -164,7 +168,7 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
scm_wrong_type_arg (s_scm_readline, SCM_ARG1, text);
}
}
-
+
if (!((SCM_UNBNDP (inp) && SCM_OPINFPORTP (scm_current_input_port ()))
|| SCM_OPINFPORTP (inp)))
{
@@ -173,7 +177,7 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
"Input port is not open or not a file port",
SCM_EOL);
}
-
+
if (!((SCM_UNBNDP (outp) && SCM_OPOUTFPORTP (scm_current_output_port ()))
|| SCM_OPOUTFPORTP (outp)))
{
@@ -197,7 +201,7 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
scm_dynwind_begin (0);
scm_dynwind_unwind_handler (unwind_readline, NULL, 0);
-
+
ans = internal_readline (text);
scm_dynwind_end ();
@@ -249,7 +253,7 @@ internal_readline (SCM text)
s = readline (prompt);
if (s)
ret = scm_from_port_string (s, output_port);
- else
+ else
ret = SCM_EOF_VAL;
if (!SCM_UNBNDP (text))
@@ -287,10 +291,10 @@ scm_readline_init_ports (SCM inp, SCM outp)
{
if (SCM_UNBNDP (inp))
inp = scm_current_input_port ();
-
+
if (SCM_UNBNDP (outp))
outp = scm_current_output_port ();
-
+
if (!SCM_OPINFPORTP (inp)) {
scm_misc_error (0,
"Input port is not open or not a file port",
@@ -311,7 +315,7 @@ scm_readline_init_ports (SCM inp, SCM outp)
-SCM_DEFINE (scm_add_history, "add-history", 1, 0, 0,
+SCM_DEFINE (scm_add_history, "add-history", 1, 0, 0,
(SCM text),
"")
#define FUNC_NAME s_scm_add_history
@@ -327,7 +331,7 @@ SCM_DEFINE (scm_add_history, "add-history", 1, 0, 0,
#undef FUNC_NAME
-SCM_DEFINE (scm_read_history, "read-history", 1, 0, 0,
+SCM_DEFINE (scm_read_history, "read-history", 1, 0, 0,
(SCM file),
"")
#define FUNC_NAME s_scm_read_history
@@ -343,7 +347,7 @@ SCM_DEFINE (scm_read_history, "read-history", 1, 0, 0,
#undef FUNC_NAME
-SCM_DEFINE (scm_write_history, "write-history", 1, 0, 0,
+SCM_DEFINE (scm_write_history, "write-history", 1, 0, 0,
(SCM file),
"")
#define FUNC_NAME s_scm_write_history
@@ -358,7 +362,7 @@ SCM_DEFINE (scm_write_history, "write-history", 1, 0, 0,
}
#undef FUNC_NAME
-SCM_DEFINE (scm_clear_history, "clear-history", 0, 0, 0,
+SCM_DEFINE (scm_clear_history, "clear-history", 0, 0, 0,
(),
"Clear the history buffer of the readline machinery.")
#define FUNC_NAME s_scm_clear_history
@@ -369,7 +373,7 @@ SCM_DEFINE (scm_clear_history, "clear-history", 0, 0, 0,
#undef FUNC_NAME
-SCM_DEFINE (scm_filename_completion_function, "filename-completion-function", 2, 0, 0,
+SCM_DEFINE (scm_filename_completion_function, "filename-completion-function", 2, 0, 0,
(SCM text, SCM continuep),
"")
#define FUNC_NAME s_scm_filename_completion_function
@@ -408,10 +412,10 @@ completion_function (char *text, int continuep)
SCM t = scm_from_locale_string (text);
SCM c = scm_from_bool (continuep);
res = scm_apply (compfunc, scm_list_2 (t, c), SCM_EOL);
-
+
if (scm_is_false (res))
return NULL;
-
+
return scm_to_locale_string (res);
}
}
@@ -525,7 +529,7 @@ scm_init_readline ()
rl_getc_function = current_input_getc;
#if defined (_RL_FUNCTION_TYPEDEF)
rl_completion_entry_function = (rl_compentry_func_t*) completion_function;
-#else
+#else
rl_completion_entry_function = (Function*) completion_function;
#endif
rl_basic_word_break_characters = " \t\n\"'`;()";
@@ -535,15 +539,18 @@ scm_init_readline ()
#if defined (HAVE_DECL_RL_CATCH_SIGNALS) && HAVE_DECL_RL_CATCH_SIGNALS
rl_catch_signals = 0;
#endif
-
+
/* But let readline handle SIGWINCH. */
#if defined (HAVE_DECL_RL_CATCH_SIGWINCH) && HAVE_DECL_RL_CATCH_SIGWINCH
rl_catch_sigwinch = 1;
#endif
-
+
reentry_barrier_mutex = scm_make_mutex ();
scm_init_opts (scm_readline_options,
- scm_readline_opts);
+ scm_readline_opts);
+ rl_variable_bind ("enable-bracketed-paste",
+ SCM_READLINE_BRACKETED_PASTE ? "on" : "off");
+
#if HAVE_RL_GET_KEYMAP
init_bouncing_parens();
#endif
diff --git a/guile-readline/readline.h b/guile-readline/readline.h
index 2bf5f8000..3c935e2aa 100644
--- a/guile-readline/readline.h
+++ b/guile-readline/readline.h
@@ -39,7 +39,8 @@ SCM_RL_API scm_t_option scm_readline_opts[];
#define SCM_HISTORY_FILE_P scm_readline_opts[0].val
#define SCM_HISTORY_LENGTH scm_readline_opts[1].val
#define SCM_READLINE_BOUNCE_PARENS scm_readline_opts[2].val
-#define SCM_N_READLINE_OPTIONS 3
+#define SCM_READLINE_BRACKETED_PASTE scm_readline_opts[3].val
+#define SCM_N_READLINE_OPTIONS 4
SCM_RL_API SCM scm_readline_options (SCM setting);
SCM_RL_API void scm_readline_init_ports (SCM inp, SCM outp);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5d9c902fc..6336db4cf 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2017 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,9 +21,9 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=lock --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close connect copysign dirfd duplocale environ extensions flock floor fpieee frexp fstat fsync full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isfinite isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring link listen localcharset locale log1p lstat maintainer-makefile malloc-gnu malloca mkdir mkstemp nl_langinfo nproc open pipe-posix pipe2 poll putenv readlink recv recvfrom regex rename rmdir select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat time times trunc unistd verify vsnprintf warnings wchar
+# Reproduce by: gnulib-tool --import --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=lock --avoid=unistr/base --avoid=unistr/u8-mbtouc --avoid=unistr/u8-mbtouc-unsafe --avoid=unistr/u8-mbtoucr --avoid=unistr/u8-prev --avoid=unistr/u8-uctomb --avoid=unitypes --lgpl=3 --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept4 alignof alloca-opt announce-gen autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close connect copysign dirfd dirname-lgpl duplocale environ extensions flock floor fpieee frexp fstat fsync full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isfinite isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring link listen localcharset locale log1p lstat maintainer-makefile malloc-gnu malloca mkdir mkostemp nl_langinfo nproc open pipe-posix pipe2 poll putenv readlink recv recvfrom regex rename rmdir select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat time times trunc unistd verify vsnprintf warnings wchar
-AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
+AUTOMAKE_OPTIONS = 1.9.6 gnits
SUBDIRS =
noinst_HEADERS =
@@ -63,6 +63,7 @@ libgnu_la_LDFLAGS += $(ISNANL_LIBM)
libgnu_la_LDFLAGS += $(LDEXP_LIBM)
libgnu_la_LDFLAGS += $(LIBSOCKET)
libgnu_la_LDFLAGS += $(LIB_CLOCK_GETTIME)
+libgnu_la_LDFLAGS += $(LIB_GETLOGIN)
libgnu_la_LDFLAGS += $(LIB_POLL)
libgnu_la_LDFLAGS += $(LIB_SELECT)
libgnu_la_LDFLAGS += $(LOG1P_LIBM)
@@ -92,6 +93,12 @@ EXTRA_libgnu_la_SOURCES += accept.c
## end gnulib module accept
+## begin gnulib module accept4
+
+libgnu_la_SOURCES += accept4.c
+
+## end gnulib module accept4
+
## begin gnulib module alignof
@@ -101,9 +108,11 @@ EXTRA_DIST += alignof.h
## begin gnulib module alloca
+if gl_GNULIB_ENABLED_alloca
libgnu_la_LIBADD += @LTALLOCA@
libgnu_la_DEPENDENCIES += @LTALLOCA@
+endif
EXTRA_DIST += alloca.c
EXTRA_libgnu_la_SOURCES += alloca.c
@@ -176,6 +185,15 @@ EXTRA_DIST += arpa_inet.in.h
## end gnulib module arpa_inet
+## begin gnulib module assure
+
+if gl_GNULIB_ENABLED_assure
+
+endif
+EXTRA_DIST += assure.h
+
+## end gnulib module assure
+
## begin gnulib module binary-io
libgnu_la_SOURCES += binary-io.h binary-io.c
@@ -193,7 +211,9 @@ EXTRA_libgnu_la_SOURCES += bind.c
## begin gnulib module btowc
+if gl_GNULIB_ENABLED_btowc
+endif
EXTRA_DIST += btowc.c
EXTRA_libgnu_la_SOURCES += btowc.c
@@ -406,7 +426,9 @@ EXTRA_DIST += dosname.h
## begin gnulib module dup2
+if gl_GNULIB_ENABLED_dup2
+endif
EXTRA_DIST += dup2.c
EXTRA_libgnu_la_SOURCES += dup2.c
@@ -493,12 +515,23 @@ EXTRA_DIST += fcntl.in.h
## begin gnulib module fd-hook
+if gl_GNULIB_ENABLED_43fe87a341d9b4b93c47c3ad819a5239
libgnu_la_SOURCES += fd-hook.c
+endif
EXTRA_DIST += fd-hook.h
## end gnulib module fd-hook
+## begin gnulib module flexmember
+
+if gl_GNULIB_ENABLED_flexmember
+
+endif
+EXTRA_DIST += flexmember.h
+
+## end gnulib module flexmember
+
## begin gnulib module float
BUILT_SOURCES += $(FLOAT_H)
@@ -645,8 +678,10 @@ EXTRA_libgnu_la_SOURCES += getsockopt.c
## begin gnulib module gettext-h
+if gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36
libgnu_la_SOURCES += gettext.h
+endif
## end gnulib module gettext-h
## begin gnulib module gettimeofday
@@ -699,9 +734,22 @@ EXTRA_DIST += $(top_srcdir)/build-aux/gnupload
## begin gnulib module gperf
GPERF = gperf
+V_GPERF = $(V_GPERF_@AM_V@)
+V_GPERF_ = $(V_GPERF_@AM_DEFAULT_V@)
+V_GPERF_0 = @echo " GPERF " $@;
## end gnulib module gperf
+## begin gnulib module hard-locale
+
+if gl_GNULIB_ENABLED_30838f5439487421042f2225bed3af76
+libgnu_la_SOURCES += hard-locale.c
+
+endif
+EXTRA_DIST += hard-locale.h
+
+## end gnulib module hard-locale
+
## begin gnulib module havelib
@@ -748,19 +796,19 @@ EXTRA_DIST += iconv.in.h
## begin gnulib module iconv_open
iconv_open-aix.h: iconv_open-aix.gperf
- $(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t
+ $(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t && \
mv $(srcdir)/iconv_open-aix.h-t $(srcdir)/iconv_open-aix.h
iconv_open-hpux.h: iconv_open-hpux.gperf
- $(GPERF) -m 10 $(srcdir)/iconv_open-hpux.gperf > $(srcdir)/iconv_open-hpux.h-t
+ $(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-hpux.gperf > $(srcdir)/iconv_open-hpux.h-t && \
mv $(srcdir)/iconv_open-hpux.h-t $(srcdir)/iconv_open-hpux.h
iconv_open-irix.h: iconv_open-irix.gperf
- $(GPERF) -m 10 $(srcdir)/iconv_open-irix.gperf > $(srcdir)/iconv_open-irix.h-t
+ $(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-irix.gperf > $(srcdir)/iconv_open-irix.h-t && \
mv $(srcdir)/iconv_open-irix.h-t $(srcdir)/iconv_open-irix.h
iconv_open-osf.h: iconv_open-osf.gperf
- $(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t
+ $(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t && \
mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h
iconv_open-solaris.h: iconv_open-solaris.gperf
- $(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t
+ $(V_GPERF)$(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t && \
mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h
BUILT_SOURCES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h
MOSTLYCLEANFILES += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t iconv_open-solaris.h-t
@@ -791,6 +839,15 @@ EXTRA_libgnu_la_SOURCES += inet_pton.c
## end gnulib module inet_pton
+## begin gnulib module intprops
+
+if gl_GNULIB_ENABLED_intprops
+
+endif
+EXTRA_DIST += intprops.h
+
+## end gnulib module intprops
+
## begin gnulib module isfinite
@@ -820,7 +877,9 @@ EXTRA_libgnu_la_SOURCES += isnan.c isnand.c
## begin gnulib module isnand-nolibm
+if gl_GNULIB_ENABLED_b1df7117b479d2da59d76deba468ee21
+endif
EXTRA_DIST += float+.h isnan.c isnand-nolibm.h isnand.c
EXTRA_libgnu_la_SOURCES += isnan.c isnand.c
@@ -838,7 +897,9 @@ EXTRA_libgnu_la_SOURCES += isnan.c isnanf.c
## begin gnulib module isnanf-nolibm
+if gl_GNULIB_ENABLED_3f0e593033d1fc2c127581960f641b66
+endif
EXTRA_DIST += float+.h isnan.c isnanf-nolibm.h isnanf.c
EXTRA_libgnu_la_SOURCES += isnan.c isnanf.c
@@ -856,7 +917,9 @@ EXTRA_libgnu_la_SOURCES += isnan.c isnanl.c
## begin gnulib module isnanl-nolibm
+if gl_GNULIB_ENABLED_dbdf22868a5367f28bf18e0013ac6f8f
+endif
EXTRA_DIST += float+.h isnan.c isnanl-nolibm.h isnanl.c
EXTRA_libgnu_la_SOURCES += isnan.c isnanl.c
@@ -913,6 +976,34 @@ EXTRA_DIST += libunistring.valgrind
## end gnulib module libunistring
+## begin gnulib module limits-h
+
+BUILT_SOURCES += $(LIMITS_H)
+
+# We need the following in order to create when the system
+# doesn't have one that is compatible with GNU.
+if GL_GENERATE_LIMITS_H
+limits.h: limits.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
+ < $(srcdir)/limits.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+limits.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += limits.h limits.h-t
+
+EXTRA_DIST += limits.in.h
+
+## end gnulib module limits-h
+
## begin gnulib module link
@@ -1042,7 +1133,9 @@ EXTRA_DIST += locale.in.h
## begin gnulib module localeconv
+if gl_GNULIB_ENABLED_localeconv
+endif
EXTRA_DIST += localeconv.c
EXTRA_libgnu_la_SOURCES += localeconv.c
@@ -1051,7 +1144,9 @@ EXTRA_libgnu_la_SOURCES += localeconv.c
## begin gnulib module log
+if gl_GNULIB_ENABLED_log
+endif
EXTRA_DIST += log.c
EXTRA_libgnu_la_SOURCES += log.c
@@ -1317,11 +1412,18 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
-e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
| \
- sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
+ sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \
+ -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \
+ -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \
+ -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \
+ -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
-e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \
-e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
-e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
-e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
+ -e 's|@''REPLACE_COSF''@|$(REPLACE_COSF)|g' \
+ -e 's|@''REPLACE_COSHF''@|$(REPLACE_COSHF)|g' \
+ -e 's|@''REPLACE_EXPF''@|$(REPLACE_EXPF)|g' \
-e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \
-e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \
-e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \
@@ -1377,7 +1479,12 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
-e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
-e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
+ -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \
+ -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \
+ -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \
-e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
+ -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \
+ -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \
-e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
-e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \
-e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
@@ -1394,7 +1501,9 @@ EXTRA_DIST += math.in.h
## begin gnulib module mbrtowc
+if gl_GNULIB_ENABLED_mbrtowc
+endif
EXTRA_DIST += mbrtowc.c
EXTRA_libgnu_la_SOURCES += mbrtowc.c
@@ -1403,7 +1512,9 @@ EXTRA_libgnu_la_SOURCES += mbrtowc.c
## begin gnulib module mbsinit
+if gl_GNULIB_ENABLED_mbsinit
+endif
EXTRA_DIST += mbsinit.c
EXTRA_libgnu_la_SOURCES += mbsinit.c
@@ -1412,7 +1523,9 @@ EXTRA_libgnu_la_SOURCES += mbsinit.c
## begin gnulib module mbtowc
+if gl_GNULIB_ENABLED_mbtowc
+endif
EXTRA_DIST += mbtowc-impl.h mbtowc.c
EXTRA_libgnu_la_SOURCES += mbtowc.c
@@ -1421,7 +1534,9 @@ EXTRA_libgnu_la_SOURCES += mbtowc.c
## begin gnulib module memchr
+if gl_GNULIB_ENABLED_memchr
+endif
EXTRA_DIST += memchr.c memchr.valgrind
EXTRA_libgnu_la_SOURCES += memchr.c
@@ -1437,14 +1552,36 @@ EXTRA_libgnu_la_SOURCES += mkdir.c
## end gnulib module mkdir
-## begin gnulib module mkstemp
+## begin gnulib module mkostemp
-EXTRA_DIST += mkstemp.c
+EXTRA_DIST += mkostemp.c
-EXTRA_libgnu_la_SOURCES += mkstemp.c
+EXTRA_libgnu_la_SOURCES += mkostemp.c
-## end gnulib module mkstemp
+## end gnulib module mkostemp
+
+## begin gnulib module mktime
+
+if gl_GNULIB_ENABLED_mktime
+
+endif
+EXTRA_DIST += mktime-internal.h mktime.c
+
+EXTRA_libgnu_la_SOURCES += mktime.c
+
+## end gnulib module mktime
+
+## begin gnulib module mktime-internal
+
+if gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31
+
+endif
+EXTRA_DIST += mktime-internal.h mktime.c
+
+EXTRA_libgnu_la_SOURCES += mktime.c
+
+## end gnulib module mktime-internal
## begin gnulib module msvc-inval
@@ -1557,7 +1694,9 @@ EXTRA_libgnu_la_SOURCES += open.c
## begin gnulib module pathmax
+if gl_GNULIB_ENABLED_pathmax
+endif
EXTRA_DIST += pathmax.h
## end gnulib module pathmax
@@ -1626,7 +1765,9 @@ EXTRA_libgnu_la_SOURCES += putenv.c
## begin gnulib module raise
+if gl_GNULIB_ENABLED_raise
+endif
EXTRA_DIST += raise.c
EXTRA_libgnu_la_SOURCES += raise.c
@@ -1698,7 +1839,9 @@ EXTRA_libgnu_la_SOURCES += rmdir.c
## begin gnulib module round
+if gl_GNULIB_ENABLED_round
+endif
EXTRA_DIST += round.c
EXTRA_libgnu_la_SOURCES += round.c
@@ -1725,14 +1868,18 @@ EXTRA_libgnu_la_SOURCES += safe-read.c
## begin gnulib module same-inode
+if gl_GNULIB_ENABLED_9bc5f216d57e231e4834049d67d0db62
+endif
EXTRA_DIST += same-inode.h
## end gnulib module same-inode
## begin gnulib module secure_getenv
+if gl_GNULIB_ENABLED_secure_getenv
+endif
EXTRA_DIST += secure_getenv.c
EXTRA_libgnu_la_SOURCES += secure_getenv.c
@@ -1837,7 +1984,9 @@ EXTRA_DIST += signal.in.h
## begin gnulib module signbit
+if gl_GNULIB_ENABLED_signbit
+endif
EXTRA_DIST += float+.h signbitd.c signbitf.c signbitl.c
EXTRA_libgnu_la_SOURCES += signbitd.c signbitf.c signbitl.c
@@ -1846,8 +1995,10 @@ EXTRA_libgnu_la_SOURCES += signbitd.c signbitf.c signbitl.c
## begin gnulib module size_max
+if gl_GNULIB_ENABLED_size_max
libgnu_la_SOURCES += size_max.h
+endif
## end gnulib module size_max
## begin gnulib module snippet/_Noreturn
@@ -1911,31 +2062,6 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h
## end gnulib module snippet/c++defs
-## begin gnulib module snippet/unused-parameter
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += unused-parameter.h
-# The unused-parameter.h that gets inserted into generated .h files is the same
-# as build-aux/snippet/unused-parameter.h, except that it has the copyright
-# header cut off.
-unused-parameter.h: $(top_srcdir)/build-aux/snippet/unused-parameter.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
- < $(top_srcdir)/build-aux/snippet/unused-parameter.h \
- > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
-
-UNUSED_PARAMETER_H=unused-parameter.h
-
-EXTRA_DIST += $(top_srcdir)/build-aux/snippet/unused-parameter.h
-
-## end gnulib module snippet/unused-parameter
-
## begin gnulib module snippet/warn-on-use
BUILT_SOURCES += warn-on-use.h
@@ -1958,7 +2084,9 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
## begin gnulib module snprintf
+if gl_GNULIB_ENABLED_snprintf
+endif
EXTRA_DIST += snprintf.c
EXTRA_libgnu_la_SOURCES += snprintf.c
@@ -1976,15 +2104,19 @@ EXTRA_libgnu_la_SOURCES += socket.c
## begin gnulib module sockets
+if gl_GNULIB_ENABLED_sockets
libgnu_la_SOURCES += sockets.h sockets.c
+endif
EXTRA_DIST += w32sock.h
## end gnulib module sockets
## begin gnulib module stat
+if gl_GNULIB_ENABLED_stat
+endif
EXTRA_DIST += stat.c
EXTRA_libgnu_la_SOURCES += stat.c
@@ -2060,6 +2192,7 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
-e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
-e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
< $(srcdir)/stddef.in.h; \
@@ -2091,6 +2224,7 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+ -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
-e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
@@ -2112,6 +2246,7 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
-e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
-e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
-e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
< $(srcdir)/stdint.in.h; \
} > $@-t && \
mv $@-t $@
@@ -2286,6 +2421,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
-e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
-e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
+ -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \
-e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
-e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
-e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
@@ -2315,6 +2451,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
-e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
-e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
+ -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
-e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
@@ -2337,6 +2474,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
-e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
@@ -2358,7 +2496,9 @@ EXTRA_DIST += stdlib.in.h
## begin gnulib module strdup-posix
+if gl_GNULIB_ENABLED_f9850631dca91859e9cddac9359921c0
+endif
EXTRA_DIST += strdup.c
EXTRA_libgnu_la_SOURCES += strdup.c
@@ -2367,7 +2507,9 @@ EXTRA_libgnu_la_SOURCES += strdup.c
## begin gnulib module streq
+if gl_GNULIB_ENABLED_streq
+endif
EXTRA_DIST += streq.h
## end gnulib module streq
@@ -2786,8 +2928,10 @@ EXTRA_DIST += sys_uio.in.h
## begin gnulib module tempname
+if gl_GNULIB_ENABLED_tempname
libgnu_la_SOURCES += tempname.c
+endif
EXTRA_DIST += tempname.h
## end gnulib module tempname
@@ -2812,10 +2956,12 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
-e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
-e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
+ -e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \
-e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
-e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
+ -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
-e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
-e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
@@ -2825,6 +2971,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@@ -2839,13 +2986,35 @@ EXTRA_DIST += time.in.h
## begin gnulib module time_r
+if gl_GNULIB_ENABLED_time_r
+endif
EXTRA_DIST += time_r.c
EXTRA_libgnu_la_SOURCES += time_r.c
## end gnulib module time_r
+## begin gnulib module time_rz
+
+
+EXTRA_DIST += time-internal.h time_rz.c
+
+EXTRA_libgnu_la_SOURCES += time_rz.c
+
+## end gnulib module time_rz
+
+## begin gnulib module timegm
+
+if gl_GNULIB_ENABLED_timegm
+
+endif
+EXTRA_DIST += mktime-internal.h timegm.c
+
+EXTRA_libgnu_la_SOURCES += timegm.c
+
+## end gnulib module timegm
+
## begin gnulib module times
@@ -2944,7 +3113,6 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
-e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
-e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
- -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
-e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
-e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
@@ -2966,6 +3134,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
-e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
-e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
-e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
@@ -2995,9 +3164,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
-e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
-e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
+ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
-e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
@@ -3016,77 +3187,16 @@ EXTRA_DIST += unistd.in.h
## end gnulib module unistd
-## begin gnulib module unistr/base
+## begin gnulib module unsetenv
-BUILT_SOURCES += $(LIBUNISTRING_UNISTR_H)
+if gl_GNULIB_ENABLED_unsetenv
-unistr.h: unistr.in.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/unistr.in.h; \
- } > $@-t && \
- mv -f $@-t $@
-MOSTLYCLEANFILES += unistr.h unistr.h-t
-
-EXTRA_DIST += unistr.in.h
-
-## end gnulib module unistr/base
-
-## begin gnulib module unistr/u8-mbtouc
-
-if LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUC
-libgnu_la_SOURCES += unistr/u8-mbtouc.c unistr/u8-mbtouc-aux.c
endif
+EXTRA_DIST += unsetenv.c
-## end gnulib module unistr/u8-mbtouc
+EXTRA_libgnu_la_SOURCES += unsetenv.c
-## begin gnulib module unistr/u8-mbtouc-unsafe
-
-if LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUC_UNSAFE
-libgnu_la_SOURCES += unistr/u8-mbtouc-unsafe.c unistr/u8-mbtouc-unsafe-aux.c
-endif
-
-## end gnulib module unistr/u8-mbtouc-unsafe
-
-## begin gnulib module unistr/u8-mbtoucr
-
-if LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR
-libgnu_la_SOURCES += unistr/u8-mbtoucr.c
-endif
-
-## end gnulib module unistr/u8-mbtoucr
-
-## begin gnulib module unistr/u8-prev
-
-if LIBUNISTRING_COMPILE_UNISTR_U8_PREV
-libgnu_la_SOURCES += unistr/u8-prev.c
-endif
-
-## end gnulib module unistr/u8-prev
-
-## begin gnulib module unistr/u8-uctomb
-
-if LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB
-libgnu_la_SOURCES += unistr/u8-uctomb.c unistr/u8-uctomb-aux.c
-endif
-
-## end gnulib module unistr/u8-uctomb
-
-## begin gnulib module unitypes
-
-BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H)
-
-unitypes.h: unitypes.in.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/unitypes.in.h; \
- } > $@-t && \
- mv -f $@-t $@
-MOSTLYCLEANFILES += unitypes.h unitypes.h-t
-
-EXTRA_DIST += unitypes.in.h
-
-## end gnulib module unitypes
+## end gnulib module unsetenv
## begin gnulib module useless-if-before-free
@@ -3097,7 +3207,9 @@ EXTRA_DIST += $(top_srcdir)/build-aux/useless-if-before-free
## begin gnulib module vasnprintf
+if gl_GNULIB_ENABLED_vasnprintf
+endif
EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h
EXTRA_libgnu_la_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c
@@ -3143,6 +3255,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
-e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
-e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
-e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \
-e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \
-e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \
@@ -3250,7 +3363,9 @@ EXTRA_DIST += wchar.in.h
## begin gnulib module wcrtomb
+if gl_GNULIB_ENABLED_wcrtomb
+endif
EXTRA_DIST += wcrtomb.c
EXTRA_libgnu_la_SOURCES += wcrtomb.c
@@ -3259,6 +3374,7 @@ EXTRA_libgnu_la_SOURCES += wcrtomb.c
## begin gnulib module wctype-h
+if gl_GNULIB_ENABLED_3dcce957eadc896e63ab5f137947b410
BUILT_SOURCES += wctype.h
libgnu_la_SOURCES += wctype-h.c
@@ -3273,6 +3389,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
-e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
-e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
-e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
@@ -3293,6 +3410,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
mv $@-t $@
MOSTLYCLEANFILES += wctype.h wctype.h-t
+endif
EXTRA_DIST += wctype.in.h
## end gnulib module wctype-h
@@ -3306,10 +3424,19 @@ EXTRA_libgnu_la_SOURCES += write.c
## end gnulib module write
+## begin gnulib module xalloc-oversized
+
+
+EXTRA_DIST += xalloc-oversized.h
+
+## end gnulib module xalloc-oversized
+
## begin gnulib module xsize
+if gl_GNULIB_ENABLED_xsize
libgnu_la_SOURCES += xsize.h xsize.c
+endif
## end gnulib module xsize
diff --git a/lib/accept.c b/lib/accept.c
index b216c6bd6..1aee71f42 100644
--- a/lib/accept.c
+++ b/lib/accept.c
@@ -1,6 +1,6 @@
/* accept.c --- wrappers for Windows accept function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/accept4.c b/lib/accept4.c
new file mode 100644
index 000000000..9fab9c645
--- /dev/null
+++ b/lib/accept4.c
@@ -0,0 +1,128 @@
+/* Accept a connection on a socket, with specific opening flags.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along
+ with this program; if not, see . */
+
+#include
+
+/* Specification. */
+#include
+
+#include
+#include
+#include "binary-io.h"
+#include "msvc-nothrow.h"
+
+#ifndef SOCK_CLOEXEC
+# define SOCK_CLOEXEC 0
+#endif
+
+int
+accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
+{
+ int fd;
+
+#if HAVE_ACCEPT4
+# undef accept4
+ /* Try the system call first, if it exists. (We may be running with a glibc
+ that has the function but with an older kernel that lacks it.) */
+ {
+ /* Cache the information whether the system call really exists. */
+ static int have_accept4_really; /* 0 = unknown, 1 = yes, -1 = no */
+ if (have_accept4_really >= 0)
+ {
+ int result = accept4 (sockfd, addr, addrlen, flags);
+ if (!(result < 0 && errno == ENOSYS))
+ {
+ have_accept4_really = 1;
+ return result;
+ }
+ have_accept4_really = -1;
+ }
+ }
+#endif
+
+ /* Check the supported flags. */
+ if ((flags & ~(SOCK_CLOEXEC | O_TEXT | O_BINARY)) != 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ fd = accept (sockfd, addr, addrlen);
+ if (fd < 0)
+ return -1;
+
+#if SOCK_CLOEXEC
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Native Windows API. */
+ if (flags & SOCK_CLOEXEC)
+ {
+ HANDLE curr_process = GetCurrentProcess ();
+ HANDLE old_handle = (HANDLE) _get_osfhandle (fd);
+ HANDLE new_handle;
+ int nfd;
+
+ if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
+ old_handle, /* SourceHandle */
+ curr_process, /* TargetProcessHandle */
+ (PHANDLE) &new_handle, /* TargetHandle */
+ (DWORD) 0, /* DesiredAccess */
+ FALSE, /* InheritHandle */
+ DUPLICATE_SAME_ACCESS)) /* Options */
+ {
+ close (fd);
+ errno = EBADF; /* arbitrary */
+ return -1;
+ }
+
+ /* Closing fd before allocating the new fd ensures that the new fd will
+ have the minimum possible value. */
+ close (fd);
+ nfd = _open_osfhandle ((intptr_t) new_handle,
+ O_NOINHERIT | (flags & (O_TEXT | O_BINARY)));
+ if (nfd < 0)
+ {
+ CloseHandle (new_handle);
+ return -1;
+ }
+ return nfd;
+ }
+# else
+/* Unix API. */
+ if (flags & SOCK_CLOEXEC)
+ {
+ int fcntl_flags;
+
+ if ((fcntl_flags = fcntl (fd, F_GETFD, 0)) < 0
+ || fcntl (fd, F_SETFD, fcntl_flags | FD_CLOEXEC) == -1)
+ {
+ int saved_errno = errno;
+ close (fd);
+ errno = saved_errno;
+ return -1;
+ }
+ }
+# endif
+#endif
+
+#if O_BINARY
+ if (flags & O_BINARY)
+ set_binary_mode (fd, O_BINARY);
+ else if (flags & O_TEXT)
+ set_binary_mode (fd, O_TEXT);
+#endif
+
+ return fd;
+}
diff --git a/lib/alignof.h b/lib/alignof.h
index 280f3e384..53583b833 100644
--- a/lib/alignof.h
+++ b/lib/alignof.h
@@ -1,5 +1,5 @@
/* Determine alignment of types.
- Copyright (C) 2003-2004, 2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2006, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index e3aa62d2d..f6d41db8d 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -1,6 +1,6 @@
/* Memory allocation on the stack.
- Copyright (C) 1995, 1999, 2001-2004, 2006-2014 Free Software Foundation,
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2017 Free Software Foundation,
Inc.
This program is free software; you can redistribute it and/or modify it
@@ -51,6 +51,8 @@ extern "C"
void *_alloca (unsigned short);
# pragma intrinsic (_alloca)
# define alloca _alloca
+# elif defined __MVS__
+# include
# else
# include
# ifdef __cplusplus
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index 3f5df4776..6efde0a69 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -1,6 +1,6 @@
/* A GNU-like .
- Copyright (C) 2005-2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/asnprintf.c b/lib/asnprintf.c
index 7806f6888..1e8819cd9 100644
--- a/lib/asnprintf.c
+++ b/lib/asnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/assure.h b/lib/assure.h
new file mode 100644
index 000000000..cef2a7353
--- /dev/null
+++ b/lib/assure.h
@@ -0,0 +1,37 @@
+/* Run-time assert-like macros.
+
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
+
+/* Written by Paul Eggert. */
+
+#ifndef _GL_ASSURE_H
+#define _GL_ASSURE_H
+
+#include
+
+/* Check E's value at runtime, and report an error and abort if not.
+ However, do nothng if NDEBUG is defined.
+
+ Unlike standard 'assert', this macro always compiles E even when NDEBUG
+ is defined, so as to catch typos and avoid some GCC warnings. */
+
+#ifdef NDEBUG
+# define assure(E) ((void) (0 && (E)))
+#else
+# define assure(E) assert (E)
+#endif
+
+#endif
diff --git a/lib/basename-lgpl.c b/lib/basename-lgpl.c
index fe007936f..0e6b0a1db 100644
--- a/lib/basename-lgpl.c
+++ b/lib/basename-lgpl.c
@@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2014 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2017 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/binary-io.c b/lib/binary-io.c
index 8bbdb44d1..d828bcd01 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -1,3 +1,4 @@
#include
#define BINARY_IO_INLINE _GL_EXTERN_INLINE
#include "binary-io.h"
+typedef int dummy;
diff --git a/lib/binary-io.h b/lib/binary-io.h
index c276faa88..9aeebb7a6 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -1,5 +1,5 @@
/* Binary mode I/O.
- Copyright (C) 2001, 2003, 2005, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2005, 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -60,7 +60,7 @@ set_binary_mode (int fd, int mode)
/* SET_BINARY (fd);
changes the file descriptor fd to perform binary I/O. */
-#ifdef __DJGPP__
+#if defined __DJGPP__ || defined __EMX__
# include /* declares isatty() */
/* Avoid putting stdin/stdout in binary mode if it is connected to
the console, because that would make it impossible for the user
diff --git a/lib/bind.c b/lib/bind.c
index 36750c9a8..666e800c7 100644
--- a/lib/bind.c
+++ b/lib/bind.c
@@ -1,6 +1,6 @@
/* bind.c --- wrappers for Windows bind function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/btowc.c b/lib/btowc.c
index aad27f593..bfc694e15 100644
--- a/lib/btowc.c
+++ b/lib/btowc.c
@@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
- Copyright (C) 2008, 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/byteswap.in.h b/lib/byteswap.in.h
index 130c79dfb..026f5fc0f 100644
--- a/lib/byteswap.in.h
+++ b/lib/byteswap.in.h
@@ -1,5 +1,5 @@
/* byteswap.h - Byte swapping
- Copyright (C) 2005, 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009-2017 Free Software Foundation, Inc.
Written by Oskar Liljeblad , 2005.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/c-ctype.c b/lib/c-ctype.c
index 7fe3f7efa..5d9d4d87a 100644
--- a/lib/c-ctype.c
+++ b/lib/c-ctype.c
@@ -1,395 +1,3 @@
-/* Character handling in C locale.
-
- Copyright 2000-2003, 2006, 2009-2014 Free Software Foundation, Inc.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this program; if not, see . */
-
#include
-
-/* Specification. */
-#define NO_C_CTYPE_MACROS
+#define C_CTYPE_INLINE _GL_EXTERN_INLINE
#include "c-ctype.h"
-
-/* The function isascii is not locale dependent. Its use in EBCDIC is
- questionable. */
-bool
-c_isascii (int c)
-{
- return (c >= 0x00 && c <= 0x7f);
-}
-
-bool
-c_isalnum (int c)
-{
-#if C_CTYPE_CONSECUTIVE_DIGITS \
- && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#if C_CTYPE_ASCII
- return ((c >= '0' && c <= '9')
- || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'));
-#else
- return ((c >= '0' && c <= '9')
- || (c >= 'A' && c <= 'Z')
- || (c >= 'a' && c <= 'z'));
-#endif
-#else
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_isalpha (int c)
-{
-#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#if C_CTYPE_ASCII
- return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z');
-#else
- return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
-#endif
-#else
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_isblank (int c)
-{
- return (c == ' ' || c == '\t');
-}
-
-bool
-c_iscntrl (int c)
-{
-#if C_CTYPE_ASCII
- return ((c & ~0x1f) == 0 || c == 0x7f);
-#else
- switch (c)
- {
- case ' ': case '!': case '"': case '#': case '$': case '%':
- case '&': case '\'': case '(': case ')': case '*': case '+':
- case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>': case '?':
- case '@':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case '[': case '\\': case ']': case '^': case '_': case '`':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- case '{': case '|': case '}': case '~':
- return 0;
- default:
- return 1;
- }
-#endif
-}
-
-bool
-c_isdigit (int c)
-{
-#if C_CTYPE_CONSECUTIVE_DIGITS
- return (c >= '0' && c <= '9');
-#else
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_islower (int c)
-{
-#if C_CTYPE_CONSECUTIVE_LOWERCASE
- return (c >= 'a' && c <= 'z');
-#else
- switch (c)
- {
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_isgraph (int c)
-{
-#if C_CTYPE_ASCII
- return (c >= '!' && c <= '~');
-#else
- switch (c)
- {
- case '!': case '"': case '#': case '$': case '%': case '&':
- case '\'': case '(': case ')': case '*': case '+': case ',':
- case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>': case '?':
- case '@':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case '[': case '\\': case ']': case '^': case '_': case '`':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- case '{': case '|': case '}': case '~':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_isprint (int c)
-{
-#if C_CTYPE_ASCII
- return (c >= ' ' && c <= '~');
-#else
- switch (c)
- {
- case ' ': case '!': case '"': case '#': case '$': case '%':
- case '&': case '\'': case '(': case ')': case '*': case '+':
- case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>': case '?':
- case '@':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- case '[': case '\\': case ']': case '^': case '_': case '`':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
- case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
- case 's': case 't': case 'u': case 'v': case 'w': case 'x':
- case 'y': case 'z':
- case '{': case '|': case '}': case '~':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_ispunct (int c)
-{
-#if C_CTYPE_ASCII
- return ((c >= '!' && c <= '~')
- && !((c >= '0' && c <= '9')
- || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')));
-#else
- switch (c)
- {
- case '!': case '"': case '#': case '$': case '%': case '&':
- case '\'': case '(': case ')': case '*': case '+': case ',':
- case '-': case '.': case '/':
- case ':': case ';': case '<': case '=': case '>': case '?':
- case '@':
- case '[': case '\\': case ']': case '^': case '_': case '`':
- case '{': case '|': case '}': case '~':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_isspace (int c)
-{
- return (c == ' ' || c == '\t'
- || c == '\n' || c == '\v' || c == '\f' || c == '\r');
-}
-
-bool
-c_isupper (int c)
-{
-#if C_CTYPE_CONSECUTIVE_UPPERCASE
- return (c >= 'A' && c <= 'Z');
-#else
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
- case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
- case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
- case 'Y': case 'Z':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-bool
-c_isxdigit (int c)
-{
-#if C_CTYPE_CONSECUTIVE_DIGITS \
- && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#if C_CTYPE_ASCII
- return ((c >= '0' && c <= '9')
- || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F'));
-#else
- return ((c >= '0' && c <= '9')
- || (c >= 'A' && c <= 'F')
- || (c >= 'a' && c <= 'f'));
-#endif
-#else
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- return 1;
- default:
- return 0;
- }
-#endif
-}
-
-int
-c_tolower (int c)
-{
-#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
- return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
-#else
- switch (c)
- {
- case 'A': return 'a';
- case 'B': return 'b';
- case 'C': return 'c';
- case 'D': return 'd';
- case 'E': return 'e';
- case 'F': return 'f';
- case 'G': return 'g';
- case 'H': return 'h';
- case 'I': return 'i';
- case 'J': return 'j';
- case 'K': return 'k';
- case 'L': return 'l';
- case 'M': return 'm';
- case 'N': return 'n';
- case 'O': return 'o';
- case 'P': return 'p';
- case 'Q': return 'q';
- case 'R': return 'r';
- case 'S': return 's';
- case 'T': return 't';
- case 'U': return 'u';
- case 'V': return 'v';
- case 'W': return 'w';
- case 'X': return 'x';
- case 'Y': return 'y';
- case 'Z': return 'z';
- default: return c;
- }
-#endif
-}
-
-int
-c_toupper (int c)
-{
-#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
- return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
-#else
- switch (c)
- {
- case 'a': return 'A';
- case 'b': return 'B';
- case 'c': return 'C';
- case 'd': return 'D';
- case 'e': return 'E';
- case 'f': return 'F';
- case 'g': return 'G';
- case 'h': return 'H';
- case 'i': return 'I';
- case 'j': return 'J';
- case 'k': return 'K';
- case 'l': return 'L';
- case 'm': return 'M';
- case 'n': return 'N';
- case 'o': return 'O';
- case 'p': return 'P';
- case 'q': return 'Q';
- case 'r': return 'R';
- case 's': return 'S';
- case 't': return 'T';
- case 'u': return 'U';
- case 'v': return 'V';
- case 'w': return 'W';
- case 'x': return 'X';
- case 'y': return 'Y';
- case 'z': return 'Z';
- default: return c;
- }
-#endif
-}
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index a258019f4..a789222bc 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -5,7 +5,7 @@
functions' behaviour depends on the current locale set via
setlocale.
- Copyright (C) 2000-2003, 2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2006, 2008-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -25,6 +25,13 @@ along with this program; if not, see . */
#include
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef C_CTYPE_INLINE
+# define C_CTYPE_INLINE _GL_INLINE
+#endif
#ifdef __cplusplus
extern "C" {
@@ -39,38 +46,6 @@ extern "C" {
characters. */
-/* Check whether the ASCII optimizations apply. */
-
-/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that
- '0', '1', ..., '9' have consecutive integer values. */
-#define C_CTYPE_CONSECUTIVE_DIGITS 1
-
-#if ('A' <= 'Z') \
- && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \
- && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \
- && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \
- && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \
- && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \
- && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \
- && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \
- && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \
- && ('Y' + 1 == 'Z')
-#define C_CTYPE_CONSECUTIVE_UPPERCASE 1
-#endif
-
-#if ('a' <= 'z') \
- && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \
- && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \
- && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \
- && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \
- && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \
- && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \
- && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \
- && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \
- && ('y' + 1 == 'z')
-#define C_CTYPE_CONSECUTIVE_LOWERCASE 1
-#endif
-
#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
@@ -96,11 +71,84 @@ extern "C" {
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
Testing the value of '\n' and '\r' is not relevant. */
-#define C_CTYPE_ASCII 1
+# define C_CTYPE_ASCII 1
+#elif ! (' ' == '\x40' && '0' == '\xf0' \
+ && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \
+ && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2')
+# error "Only ASCII and EBCDIC are supported"
#endif
+#if 'A' < 0
+# error "EBCDIC and char is signed -- not supported"
+#endif
-/* Function declarations. */
+/* Cases for control characters. */
+
+#define _C_CTYPE_CNTRL \
+ case '\a': case '\b': case '\f': case '\n': \
+ case '\r': case '\t': case '\v': \
+ _C_CTYPE_OTHER_CNTRL
+
+/* ASCII control characters other than those with \-letter escapes. */
+
+#if C_CTYPE_ASCII
+# define _C_CTYPE_OTHER_CNTRL \
+ case '\x00': case '\x01': case '\x02': case '\x03': \
+ case '\x04': case '\x05': case '\x06': case '\x0e': \
+ case '\x0f': case '\x10': case '\x11': case '\x12': \
+ case '\x13': case '\x14': case '\x15': case '\x16': \
+ case '\x17': case '\x18': case '\x19': case '\x1a': \
+ case '\x1b': case '\x1c': case '\x1d': case '\x1e': \
+ case '\x1f': case '\x7f'
+#else
+ /* Use EBCDIC code page 1047's assignments for ASCII control chars;
+ assume all EBCDIC code pages agree about these assignments. */
+# define _C_CTYPE_OTHER_CNTRL \
+ case '\x00': case '\x01': case '\x02': case '\x03': \
+ case '\x07': case '\x0e': case '\x0f': case '\x10': \
+ case '\x11': case '\x12': case '\x13': case '\x18': \
+ case '\x19': case '\x1c': case '\x1d': case '\x1e': \
+ case '\x1f': case '\x26': case '\x27': case '\x2d': \
+ case '\x2e': case '\x32': case '\x37': case '\x3c': \
+ case '\x3d': case '\x3f'
+#endif
+
+/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */
+
+#define _C_CTYPE_LOWER_A_THRU_F_N(N) \
+ case 'a' + (N): case 'b' + (N): case 'c' + (N): case 'd' + (N): \
+ case 'e' + (N): case 'f' + (N)
+#define _C_CTYPE_LOWER_N(N) \
+ _C_CTYPE_LOWER_A_THRU_F_N(N): \
+ case 'g' + (N): case 'h' + (N): case 'i' + (N): case 'j' + (N): \
+ case 'k' + (N): case 'l' + (N): case 'm' + (N): case 'n' + (N): \
+ case 'o' + (N): case 'p' + (N): case 'q' + (N): case 'r' + (N): \
+ case 's' + (N): case 't' + (N): case 'u' + (N): case 'v' + (N): \
+ case 'w' + (N): case 'x' + (N): case 'y' + (N): case 'z' + (N)
+
+/* Cases for hex letters, digits, lower, punct, and upper. */
+
+#define _C_CTYPE_A_THRU_F \
+ _C_CTYPE_LOWER_A_THRU_F_N (0): \
+ _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a')
+#define _C_CTYPE_DIGIT \
+ case '0': case '1': case '2': case '3': \
+ case '4': case '5': case '6': case '7': \
+ case '8': case '9'
+#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0)
+#define _C_CTYPE_PUNCT \
+ case '!': case '"': case '#': case '$': \
+ case '%': case '&': case '\'': case '(': \
+ case ')': case '*': case '+': case ',': \
+ case '-': case '.': case '/': case ':': \
+ case ';': case '<': case '=': case '>': \
+ case '?': case '@': case '[': case '\\': \
+ case ']': case '^': case '_': case '`': \
+ case '{': case '|': case '}': case '~'
+#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a')
+
+
+/* Function definitions. */
/* Unlike the functions in , which require an argument in the range
of the 'unsigned char' type, the functions here operate on values that are
@@ -117,179 +165,202 @@ extern "C" {
if (c_isalpha (*s)) ...
*/
-extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */
+C_CTYPE_INLINE bool
+c_isalnum (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_islower (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST;
+C_CTYPE_INLINE bool
+c_isalpha (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_LOWER:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
-extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
+/* The function isascii is not locale dependent.
+ Its use in EBCDIC is questionable. */
+C_CTYPE_INLINE bool
+c_isascii (int c)
+{
+ switch (c)
+ {
+ case ' ':
+ _C_CTYPE_CNTRL:
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_PUNCT:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
+C_CTYPE_INLINE bool
+c_isblank (int c)
+{
+ return c == ' ' || c == '\t';
+}
-#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \
- && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS)
+C_CTYPE_INLINE bool
+c_iscntrl (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_CNTRL:
+ return true;
+ default:
+ return false;
+ }
+}
-/* ASCII optimizations. */
+C_CTYPE_INLINE bool
+c_isdigit (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ return true;
+ default:
+ return false;
+ }
+}
-#undef c_isascii
-#define c_isascii(c) \
- ({ int __c = (c); \
- (__c >= 0x00 && __c <= 0x7f); \
- })
+C_CTYPE_INLINE bool
+c_isgraph (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_PUNCT:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_CONSECUTIVE_DIGITS \
- && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#if C_CTYPE_ASCII
-#undef c_isalnum
-#define c_isalnum(c) \
- ({ int __c = (c); \
- ((__c >= '0' && __c <= '9') \
- || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
- })
-#else
-#undef c_isalnum
-#define c_isalnum(c) \
- ({ int __c = (c); \
- ((__c >= '0' && __c <= '9') \
- || (__c >= 'A' && __c <= 'Z') \
- || (__c >= 'a' && __c <= 'z')); \
- })
-#endif
-#endif
+C_CTYPE_INLINE bool
+c_islower (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_LOWER:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#if C_CTYPE_ASCII
-#undef c_isalpha
-#define c_isalpha(c) \
- ({ int __c = (c); \
- ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
- })
-#else
-#undef c_isalpha
-#define c_isalpha(c) \
- ({ int __c = (c); \
- ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
- })
-#endif
-#endif
+C_CTYPE_INLINE bool
+c_isprint (int c)
+{
+ switch (c)
+ {
+ case ' ':
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_PUNCT:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#undef c_isblank
-#define c_isblank(c) \
- ({ int __c = (c); \
- (__c == ' ' || __c == '\t'); \
- })
+C_CTYPE_INLINE bool
+c_ispunct (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_PUNCT:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_ASCII
-#undef c_iscntrl
-#define c_iscntrl(c) \
- ({ int __c = (c); \
- ((__c & ~0x1f) == 0 || __c == 0x7f); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_isspace (int c)
+{
+ switch (c)
+ {
+ case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_CONSECUTIVE_DIGITS
-#undef c_isdigit
-#define c_isdigit(c) \
- ({ int __c = (c); \
- (__c >= '0' && __c <= '9'); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_isupper (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_CONSECUTIVE_LOWERCASE
-#undef c_islower
-#define c_islower(c) \
- ({ int __c = (c); \
- (__c >= 'a' && __c <= 'z'); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_isxdigit (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_A_THRU_F:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_ASCII
-#undef c_isgraph
-#define c_isgraph(c) \
- ({ int __c = (c); \
- (__c >= '!' && __c <= '~'); \
- })
-#endif
-
-#if C_CTYPE_ASCII
-#undef c_isprint
-#define c_isprint(c) \
- ({ int __c = (c); \
- (__c >= ' ' && __c <= '~'); \
- })
-#endif
-
-#if C_CTYPE_ASCII
-#undef c_ispunct
-#define c_ispunct(c) \
- ({ int _c = (c); \
- (c_isgraph (_c) && ! c_isalnum (_c)); \
- })
-#endif
-
-#undef c_isspace
-#define c_isspace(c) \
- ({ int __c = (c); \
- (__c == ' ' || __c == '\t' \
- || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \
- })
-
-#if C_CTYPE_CONSECUTIVE_UPPERCASE
-#undef c_isupper
-#define c_isupper(c) \
- ({ int __c = (c); \
- (__c >= 'A' && __c <= 'Z'); \
- })
-#endif
-
-#if C_CTYPE_CONSECUTIVE_DIGITS \
- && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#if C_CTYPE_ASCII
-#undef c_isxdigit
-#define c_isxdigit(c) \
- ({ int __c = (c); \
- ((__c >= '0' && __c <= '9') \
- || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
- })
-#else
-#undef c_isxdigit
-#define c_isxdigit(c) \
- ({ int __c = (c); \
- ((__c >= '0' && __c <= '9') \
- || (__c >= 'A' && __c <= 'F') \
- || (__c >= 'a' && __c <= 'f')); \
- })
-#endif
-#endif
-
-#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-#undef c_tolower
-#define c_tolower(c) \
- ({ int __c = (c); \
- (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
- })
-#undef c_toupper
-#define c_toupper(c) \
- ({ int __c = (c); \
- (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
- })
-#endif
-
-#endif /* optimizing for speed */
+C_CTYPE_INLINE int
+c_tolower (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_UPPER:
+ return c - 'A' + 'a';
+ default:
+ return c;
+ }
+}
+C_CTYPE_INLINE int
+c_toupper (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_LOWER:
+ return c - 'a' + 'A';
+ default:
+ return c;
+ }
+}
#ifdef __cplusplus
}
#endif
+_GL_INLINE_HEADER_END
+
#endif /* C_CTYPE_H */
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index ee3bd3f72..3f7d9b0fd 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -1,5 +1,5 @@
/* Case-insensitive string comparison functions in C locale.
- Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2014 Free Software
+ Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2017 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index 5059cc659..6eba82676 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -1,5 +1,5 @@
/* c-strcasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/c-strcaseeq.h b/lib/c-strcaseeq.h
index 44d375148..7c303f5df 100644
--- a/lib/c-strcaseeq.h
+++ b/lib/c-strcaseeq.h
@@ -1,5 +1,5 @@
/* Optimized case-insensitive string comparison in C locale.
- Copyright (C) 2001-2002, 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@@ -33,9 +33,6 @@
# if C_CTYPE_ASCII
# define CASEEQ(other,upper) \
(c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper))
-# elif C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-# define CASEEQ(other,upper) \
- (c_isupper (upper) ? (other) == (upper) || (other) == (upper) - 'A' + 'a' : (other) == (upper))
# else
# define CASEEQ(other,upper) \
(c_toupper (other) == (upper))
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index 614598156..5431aafd6 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -1,5 +1,5 @@
/* c-strncasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index a999c9c84..e5706969f 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-2014 Free Software Foundation, Inc.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -83,7 +83,23 @@
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
#endif
+/* Define this independently so that stdint.h is not a prerequisite. */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
#if !FUNC_REALPATH_WORKS || defined _LIBC
+
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the malloc or realloc modules; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* Return the canonical absolute name of file NAME. A canonical name
does not contain any ".", ".." components nor any repeated path
separators ('/') or symlinks. All path components must exist. If
@@ -135,9 +151,7 @@ __realpath (const char *name, char *resolved)
rpath = malloc (path_max);
if (rpath == NULL)
{
- /* It's easier to set errno to ENOMEM than to rely on the
- 'malloc-posix' gnulib module. */
- errno = ENOMEM;
+ alloc_failed ();
return NULL;
}
}
@@ -185,7 +199,6 @@ __realpath (const char *name, char *resolved)
#else
struct stat st;
#endif
- int n;
/* Skip sequence of multiple path-separators. */
while (ISSLASH (*start))
@@ -238,9 +251,7 @@ __realpath (const char *name, char *resolved)
new_rpath = (char *) realloc (rpath, new_size);
if (new_rpath == NULL)
{
- /* It's easier to set errno to ENOMEM than to rely on the
- 'realloc-posix' gnulib module. */
- errno = ENOMEM;
+ alloc_failed ();
goto error;
}
rpath = new_rpath;
@@ -268,6 +279,7 @@ __realpath (const char *name, char *resolved)
{
char *buf;
size_t len;
+ ssize_t n;
if (++num_links > MAXSYMLINKS)
{
@@ -278,7 +290,7 @@ __realpath (const char *name, char *resolved)
buf = malloca (path_max);
if (!buf)
{
- errno = ENOMEM;
+ __set_errno (ENOMEM);
goto error;
}
@@ -287,7 +299,7 @@ __realpath (const char *name, char *resolved)
{
int saved_errno = errno;
freea (buf);
- errno = saved_errno;
+ __set_errno (saved_errno);
goto error;
}
buf[n] = '\0';
@@ -298,13 +310,14 @@ __realpath (const char *name, char *resolved)
if (!extra_buf)
{
freea (buf);
- errno = ENOMEM;
+ __set_errno (ENOMEM);
goto error;
}
}
len = strlen (end);
- if ((long int) (n + len) >= path_max)
+ /* Check that n + len + 1 doesn't overflow and is <= path_max. */
+ if (n >= SIZE_MAX - len || n + len >= path_max)
{
freea (buf);
__set_errno (ENAMETOOLONG);
@@ -370,7 +383,7 @@ error:
freea (extra_buf);
if (resolved == NULL)
free (rpath);
- errno = saved_errno;
+ __set_errno (saved_errno);
}
return NULL;
}
diff --git a/lib/ceil.c b/lib/ceil.c
index 7e810357b..d253d4856 100644
--- a/lib/ceil.c
+++ b/lib/ceil.c
@@ -1,5 +1,5 @@
/* Round towards positive infinity.
- Copyright (C) 2007, 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/close.c b/lib/close.c
index 9d2e0276a..bb635c3b0 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -1,5 +1,5 @@
/* close replacement.
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/config.charset b/lib/config.charset
index 8fe2507d9..83cf4ec3e 100644
--- a/lib/config.charset
+++ b/lib/config.charset
@@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
-# Copyright (C) 2000-2004, 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2004, 2006-2017 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@@ -348,12 +348,10 @@ case "$os" in
#echo "sun_eu_greek ?" # what is this?
echo "UTF-8 UTF-8"
;;
- freebsd* | os2*)
+ freebsd*)
# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
- # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
- # reuse FreeBSD's locale data for OS/2.
echo "C ASCII"
echo "US-ASCII ASCII"
for l in la_LN lt_LN; do
diff --git a/lib/connect.c b/lib/connect.c
index 295fe95d8..d3a2e124a 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1,6 +1,6 @@
/* connect.c --- wrappers for Windows connect function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/copysign.c b/lib/copysign.c
index 616ea356e..a0d2b6806 100644
--- a/lib/copysign.c
+++ b/lib/copysign.c
@@ -1,5 +1,5 @@
/* Copy sign into another 'double' number.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 3418bd9dc..e5a31e34c 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -1,5 +1,5 @@
/* A GNU-like .
- Copyright (C) 2006-2014 Free Software Foundation, Inc.
+ Copyright (C) 2006-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -77,6 +77,7 @@ typedef struct gl_directory DIR;
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef opendir
# define opendir rpl_opendir
+# define GNULIB_defined_opendir 1
# endif
_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
@@ -128,6 +129,7 @@ _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef closedir
# define closedir rpl_closedir
+# define GNULIB_defined_closedir 1
# endif
_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
@@ -156,6 +158,13 @@ _GL_WARN_ON_USE (closedir, "closedir is not portable - "
# endif
_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
+
+# ifdef __KLIBC__
+/* Gnulib internal hooks needed to maintain the dirfd metadata. */
+_GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
+ _GL_ARG_NONNULL ((2));
+_GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
+# endif
# else
# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
/* dirfd is defined as a macro and not as a function.
diff --git a/lib/dirfd.c b/lib/dirfd.c
index 86f8e0a1a..2082bdbbd 100644
--- a/lib/dirfd.c
+++ b/lib/dirfd.c
@@ -1,6 +1,6 @@
/* dirfd.c -- return the file descriptor associated with an open DIR*
- Copyright (C) 2001, 2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2006, 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -22,11 +22,77 @@
#include
#include
+#ifdef __KLIBC__
+# include
+# include
+
+static struct dirp_fd_list
+{
+ DIR *dirp;
+ int fd;
+ struct dirp_fd_list *next;
+} *dirp_fd_start = NULL;
+
+/* Register fd associated with dirp to dirp_fd_list. */
+int
+_gl_register_dirp_fd (int fd, DIR *dirp)
+{
+ struct dirp_fd_list *new_dirp_fd = malloc (sizeof *new_dirp_fd);
+ if (!new_dirp_fd)
+ return -1;
+
+ new_dirp_fd->dirp = dirp;
+ new_dirp_fd->fd = fd;
+ new_dirp_fd->next = dirp_fd_start;
+
+ dirp_fd_start = new_dirp_fd;
+
+ return 0;
+}
+
+/* Unregister fd from dirp_fd_list with closing it */
+void
+_gl_unregister_dirp_fd (int fd)
+{
+ struct dirp_fd_list *dirp_fd;
+ struct dirp_fd_list *dirp_fd_prev;
+
+ for (dirp_fd_prev = NULL, dirp_fd = dirp_fd_start; dirp_fd;
+ dirp_fd_prev = dirp_fd, dirp_fd = dirp_fd->next)
+ {
+ if (dirp_fd->fd == fd)
+ {
+ if (dirp_fd_prev)
+ dirp_fd_prev->next = dirp_fd->next;
+ else /* dirp_fd == dirp_fd_start */
+ dirp_fd_start = dirp_fd_start->next;
+
+ close (fd);
+ free (dirp_fd);
+ break;
+ }
+ }
+}
+#endif
+
int
dirfd (DIR *dir_p)
{
int fd = DIR_TO_FD (dir_p);
if (fd == -1)
+#ifndef __KLIBC__
errno = ENOTSUP;
+#else
+ {
+ struct dirp_fd_list *dirp_fd;
+
+ for (dirp_fd = dirp_fd_start; dirp_fd; dirp_fd = dirp_fd->next)
+ if (dirp_fd->dirp == dir_p)
+ return dirp_fd->fd;
+
+ errno = EINVAL;
+ }
+#endif
+
return fd;
}
diff --git a/lib/dirname-lgpl.c b/lib/dirname-lgpl.c
index 121d38754..4fb9ba821 100644
--- a/lib/dirname-lgpl.c
+++ b/lib/dirname-lgpl.c
@@ -1,6 +1,6 @@
/* dirname.c -- return all but the last element in a file name
- Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2014 Free Software
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2017 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/dirname.h b/lib/dirname.h
index e31cb6190..99a3e9b1d 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
- Copyright (C) 1998, 2001, 2003-2006, 2009-2014 Free Software Foundation,
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2017 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -31,6 +31,10 @@
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
# endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
# if GNULIB_DIRNAME
char *base_name (char const *file);
char *dir_name (char const *file);
@@ -43,4 +47,8 @@ char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
bool strip_trailing_slashes (char *file);
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
#endif /* not DIRNAME_H_ */
diff --git a/lib/dosname.h b/lib/dosname.h
index b81163d4b..774623f78 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -1,6 +1,6 @@
/* File names on MS-DOS/Windows systems.
- Copyright (C) 2000-2001, 2004-2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2000-2001, 2004-2006, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/dup2.c b/lib/dup2.c
index 9709b7a64..0871eda68 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
- Copyright (C) 1999, 2004-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004-2007, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -85,6 +85,57 @@ ms_windows_dup2 (int fd, int desired_fd)
# define dup2 ms_windows_dup2
+# elif defined __KLIBC__
+
+# include
+
+static int
+klibc_dup2dirfd (int fd, int desired_fd)
+{
+ int tempfd;
+ int dupfd;
+
+ tempfd = open ("NUL", O_RDONLY);
+ if (tempfd == -1)
+ return -1;
+
+ if (tempfd == desired_fd)
+ {
+ close (tempfd);
+
+ char path[_MAX_PATH];
+ if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
+ return -1;
+
+ return open(path, O_RDONLY);
+ }
+
+ dupfd = klibc_dup2dirfd (fd, desired_fd);
+
+ close (tempfd);
+
+ return dupfd;
+}
+
+static int
+klibc_dup2 (int fd, int desired_fd)
+{
+ int dupfd;
+ struct stat sbuf;
+
+ dupfd = dup2 (fd, desired_fd);
+ if (dupfd == -1 && errno == ENOTSUP \
+ && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
+ {
+ close (desired_fd);
+
+ return klibc_dup2dirfd (fd, desired_fd);
+ }
+
+ return dupfd;
+}
+
+# define dup2 klibc_dup2
# endif
int
diff --git a/lib/duplocale.c b/lib/duplocale.c
index 86d5ce59a..eb7b8d365 100644
--- a/lib/duplocale.c
+++ b/lib/duplocale.c
@@ -1,5 +1,5 @@
/* Duplicate a locale object.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/errno.in.h b/lib/errno.in.h
index 8dbb5f97a..48c5d935d 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -1,6 +1,6 @@
/* A POSIX-like .
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 1cd197002..dc8d7340f 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -1,6 +1,6 @@
/* Like , but with non-working flags defined to 0.
- Copyright (C) 2006-2014 Free Software Foundation, Inc.
+ Copyright (C) 2006-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -34,7 +34,7 @@
extern "C" { ... } block, which leads to errors in C++ mode with the
overridden from gnulib. These errors are known to be gone
with g++ version >= 4.3. */
-#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include
#endif
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
@@ -53,7 +53,7 @@
extern "C" { ... } block, which leads to errors in C++ mode with the
overridden from gnulib. These errors are known to be gone
with g++ version >= 4.3. */
-#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include
#endif
/* The include_next requires a split double-inclusion guard. */
@@ -186,6 +186,22 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
/* Fix up the O_* macros. */
+/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
+ to values outside 'int' range, so omit these misdefinitions.
+ But avoid namespace pollution on non-AIX systems. */
+#ifdef _AIX
+# include
+# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
+# undef O_CLOEXEC
+# endif
+# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
+# undef O_NOFOLLOW
+# endif
+# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
+# undef O_TTY_INIT
+# endif
+#endif
+
#if !defined O_DIRECT && defined O_DIRECTIO
/* Tru64 spells it 'O_DIRECTIO'. */
# define O_DIRECT O_DIRECTIO
diff --git a/lib/fd-hook.c b/lib/fd-hook.c
index fd07578f1..627863a29 100644
--- a/lib/fd-hook.c
+++ b/lib/fd-hook.c
@@ -1,5 +1,5 @@
/* Hook for making making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/lib/fd-hook.h b/lib/fd-hook.h
index 5ff0f73fc..246ca7769 100644
--- a/lib/fd-hook.h
+++ b/lib/fd-hook.h
@@ -1,5 +1,5 @@
/* Hook for making making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
diff --git a/lib/flexmember.h b/lib/flexmember.h
new file mode 100644
index 000000000..3ef4f9802
--- /dev/null
+++ b/lib/flexmember.h
@@ -0,0 +1,42 @@
+/* Sizes of structs with flexible array members.
+
+ Copyright 2016-2017 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see .
+
+ Written by Paul Eggert. */
+
+#include
+
+/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
+ On older platforms without _Alignof, use a pessimistic bound that is
+ safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
+ On newer platforms, use _Alignof to get a tighter bound. */
+
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
+#else
+# define FLEXALIGNOF(type) _Alignof (type)
+#endif
+
+/* Upper bound on the size of a struct of type TYPE with a flexible
+ array member named MEMBER that is followed by N bytes of other data.
+ This is not simply sizeof (TYPE) + N, since it may require
+ alignment on unusually picky C11 platforms, and
+ FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms.
+ Yield a value less than N if and only if arithmetic overflow occurs. */
+
+#define FLEXSIZEOF(type, member, n) \
+ ((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
+ & ~ (FLEXALIGNOF (type) - 1))
diff --git a/lib/float+.h b/lib/float+.h
index 085c379b1..41c3d57b4 100644
--- a/lib/float+.h
+++ b/lib/float+.h
@@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
- Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2007.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/float.c b/lib/float.c
index 3faa5eede..48567817f 100644
--- a/lib/float.c
+++ b/lib/float.c
@@ -1,5 +1,5 @@
/* Auxiliary definitions for .
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/float.in.h b/lib/float.in.h
index e814eaba5..2b0625359 100644
--- a/lib/float.in.h
+++ b/lib/float.in.h
@@ -1,6 +1,6 @@
/* A correct .
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/flock.c b/lib/flock.c
index 928e151b0..7698e43ff 100644
--- a/lib/flock.c
+++ b/lib/flock.c
@@ -6,7 +6,7 @@
Written by Richard W.M. Jones
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/lib/floor.c b/lib/floor.c
index a00f937ed..5305fb3ae 100644
--- a/lib/floor.c
+++ b/lib/floor.c
@@ -1,5 +1,5 @@
/* Round towards negative infinity.
- Copyright (C) 2007, 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/frexp.c b/lib/frexp.c
index 6eff94574..8bcf890c9 100644
--- a/lib/frexp.c
+++ b/lib/frexp.c
@@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/fstat.c b/lib/fstat.c
index 17ccc8e29..4832548f1 100644
--- a/lib/fstat.c
+++ b/lib/fstat.c
@@ -1,5 +1,5 @@
/* fstat() replacement.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/fsync.c b/lib/fsync.c
index 99475ff65..8304751a4 100644
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -7,7 +7,7 @@
Written by Richard W.M. Jones
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/lib/full-read.c b/lib/full-read.c
index 4d67afb92..97ac45fa1 100644
--- a/lib/full-read.c
+++ b/lib/full-read.c
@@ -1,5 +1,5 @@
/* An interface to read that retries after partial reads and interrupts.
- Copyright (C) 2002-2003, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/full-read.h b/lib/full-read.h
index 954b94dce..d1277635c 100644
--- a/lib/full-read.h
+++ b/lib/full-read.h
@@ -1,6 +1,6 @@
/* An interface to read() that reads all it is asked to read.
- Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -13,7 +13,6 @@
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, read to the Free Software Foundation,
along with this program. If not, see . */
#include
diff --git a/lib/full-write.c b/lib/full-write.c
index 6a77b7b45..75fd857d8 100644
--- a/lib/full-write.c
+++ b/lib/full-write.c
@@ -1,6 +1,6 @@
/* An interface to read and write that retries (if necessary) until complete.
- Copyright (C) 1993-1994, 1997-2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1993-1994, 1997-2006, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/full-write.h b/lib/full-write.h
index 2fab6fa02..002924991 100644
--- a/lib/full-write.h
+++ b/lib/full-write.h
@@ -1,6 +1,6 @@
/* An interface to write() that writes all it is asked to write.
- Copyright (C) 2002-2003, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/gai_strerror.c b/lib/gai_strerror.c
index d0c589da1..20d5513d4 100644
--- a/lib/gai_strerror.c
+++ b/lib/gai_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2014 Free Software
+/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2017 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell , 1997.
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index 6581dd55a..361dbc25a 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -1,5 +1,5 @@
/* Get address information (partial implementation).
- Copyright (C) 1997, 2001-2002, 2004-2014 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2001-2002, 2004-2017 Free Software Foundation, Inc.
Contributed by Simon Josefsson .
This program is free software; you can redistribute it and/or modify
diff --git a/lib/getlogin.c b/lib/getlogin.c
index f8cfe5d78..47c586a62 100644
--- a/lib/getlogin.c
+++ b/lib/getlogin.c
@@ -1,6 +1,6 @@
/* Provide a working getlogin for systems which lack it.
- Copyright (C) 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2010-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/getpeername.c b/lib/getpeername.c
index e5b3eaea3..e36e57bb0 100644
--- a/lib/getpeername.c
+++ b/lib/getpeername.c
@@ -1,6 +1,6 @@
/* getpeername.c --- wrappers for Windows getpeername function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/getsockname.c b/lib/getsockname.c
index d26bae592..08d0ead77 100644
--- a/lib/getsockname.c
+++ b/lib/getsockname.c
@@ -1,6 +1,6 @@
/* getsockname.c --- wrappers for Windows getsockname function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/getsockopt.c b/lib/getsockopt.c
index 0b2fb2b73..eabbd246c 100644
--- a/lib/getsockopt.c
+++ b/lib/getsockopt.c
@@ -1,6 +1,6 @@
/* getsockopt.c --- wrappers for Windows getsockopt function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/gettext.h b/lib/gettext.h
index 330d8dad4..da14fdcde 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU .
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2014 Free Software
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2017 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -225,15 +225,17 @@ dcpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
+ int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
+ found_translation = (translation != msg_ctxt_id);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
- if (translation != msg_ctxt_id)
+ if (found_translation)
return translation;
}
return msgid;
@@ -271,15 +273,17 @@ dcnpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
+ int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
- if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ if (found_translation)
return translation;
}
return (n == 1 ? msgid : msgid_plural);
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index c4e40fbe9..b4375fef7 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -1,6 +1,6 @@
/* Provide gettimeofday for systems that don't have it or for which it's broken.
- Copyright (C) 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2007, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/hard-locale.c b/lib/hard-locale.c
new file mode 100644
index 000000000..845282dd3
--- /dev/null
+++ b/lib/hard-locale.c
@@ -0,0 +1,72 @@
+/* hard-locale.c -- Determine whether a locale is hard.
+
+ Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2017 Free Software
+ Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
+
+#include
+
+#include "hard-locale.h"
+
+#include
+#include
+#include
+
+#ifdef __GLIBC__
+# define GLIBC_VERSION __GLIBC__
+#elif defined __UCLIBC__
+# define GLIBC_VERSION 2
+#else
+# define GLIBC_VERSION 0
+#endif
+
+/* Return true if the current CATEGORY locale is hard, i.e. if you
+ can't get away with assuming traditional C or POSIX behavior. */
+bool
+hard_locale (int category)
+{
+ bool hard = true;
+ char const *p = setlocale (category, NULL);
+
+ if (p)
+ {
+ if (2 <= GLIBC_VERSION)
+ {
+ if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
+ hard = false;
+ }
+ else
+ {
+ char *locale = strdup (p);
+ if (locale)
+ {
+ /* Temporarily set the locale to the "C" and "POSIX" locales
+ to find their names, so that we can determine whether one
+ or the other is the caller's locale. */
+ if (((p = setlocale (category, "C"))
+ && strcmp (p, locale) == 0)
+ || ((p = setlocale (category, "POSIX"))
+ && strcmp (p, locale) == 0))
+ hard = false;
+
+ /* Restore the caller's locale. */
+ setlocale (category, locale);
+ free (locale);
+ }
+ }
+ }
+
+ return hard;
+}
diff --git a/lib/hard-locale.h b/lib/hard-locale.h
new file mode 100644
index 000000000..b7cd5d19e
--- /dev/null
+++ b/lib/hard-locale.h
@@ -0,0 +1,25 @@
+/* Determine whether a locale is hard.
+
+ Copyright (C) 1999, 2003-2004, 2009-2017 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
+
+#ifndef HARD_LOCALE_H_
+# define HARD_LOCALE_H_ 1
+
+# include
+
+bool hard_locale (int);
+
+#endif /* HARD_LOCALE_H_ */
diff --git a/lib/iconv.c b/lib/iconv.c
index a6dfed355..c0f1a8352 100644
--- a/lib/iconv.c
+++ b/lib/iconv.c
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 1999-2001, 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2001, 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconv.in.h b/lib/iconv.in.h
index ed95ed719..0864267ef 100644
--- a/lib/iconv.in.h
+++ b/lib/iconv.in.h
@@ -1,6 +1,6 @@
/* A GNU-like .
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconv_close.c b/lib/iconv_close.c
index 6e286734d..823cf452f 100644
--- a/lib/iconv_close.c
+++ b/lib/iconv_close.c
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconv_open.c b/lib/iconv_open.c
index fc19d44e2..48a28dbe4 100644
--- a/lib/iconv_open.c
+++ b/lib/iconv_open.c
@@ -1,5 +1,5 @@
/* Character set conversion.
- Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconveh.h b/lib/iconveh.h
index 43b23eb39..c074a8c25 100644
--- a/lib/iconveh.h
+++ b/lib/iconveh.h
@@ -1,5 +1,5 @@
/* Character set conversion handler type.
- Copyright (C) 2001-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2007, 2009-2017 Free Software Foundation, Inc.
Written by Bruno Haible.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index 462951968..b30a26667 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -1,6 +1,6 @@
/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
- Copyright (C) 2005-2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -40,7 +40,7 @@
/* Use this to suppress gcc's "...may be used before initialized" warnings.
Beware: The Code argument must not contain commas. */
#ifndef IF_LINT
-# ifdef lint
+# if defined GCC_LINT || defined lint
# define IF_LINT(Code) Code
# else
# define IF_LINT(Code) /* empty */
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index 52ae31784..8e8b8c1da 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -1,6 +1,6 @@
/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
- Copyright (C) 2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/intprops.h b/lib/intprops.h
new file mode 100644
index 000000000..eb06b6917
--- /dev/null
+++ b/lib/intprops.h
@@ -0,0 +1,458 @@
+/* intprops.h -- properties of integer types
+
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
+
+/* Written by Paul Eggert. */
+
+#ifndef _GL_INTPROPS_H
+#define _GL_INTPROPS_H
+
+#include
+#include
+
+/* Return a value with the common real type of E and V and the value of V. */
+#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
+
+/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
+ . */
+#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
+
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is an integer type. bool counts as
+ an integer. */
+#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
+
+/* True if the real type T is signed. */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* Return 1 if the real expression E, after promotion, has a
+ signed or floating type. */
+#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
+
+
+/* Minimum and maximum values for integer types and expressions. */
+
+/* The width in bits of the integer type or expression T.
+ Padding bits are not supported; this is checked at compile-time below. */
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
+/* The maximum and minimum values for the integer type T. */
+#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
+#define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
+
+/* The maximum and minimum values for the type of the expression E,
+ after integer promotion. E should not have side effects. */
+#define _GL_INT_MINIMUM(e) \
+ (EXPR_SIGNED (e) \
+ ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
+ : _GL_INT_CONVERT (e, 0))
+#define _GL_INT_MAXIMUM(e) \
+ (EXPR_SIGNED (e) \
+ ? _GL_SIGNED_INT_MAXIMUM (e) \
+ : _GL_INT_NEGATE_CONVERT (e, 1))
+#define _GL_SIGNED_INT_MAXIMUM(e) \
+ (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1)
+
+/* Work around OpenVMS incompatibility with C99. */
+#if !defined LLONG_MAX && defined __INT64_MAX
+# define LLONG_MAX __INT64_MAX
+# define LLONG_MIN __INT64_MIN
+#endif
+
+/* This include file assumes that signed types are two's complement without
+ padding bits; the above macros have undefined behavior otherwise.
+ If this is a problem for you, please let us know how to fix it for your host.
+ As a sanity check, test the assumption for some signed types that
+ bounds. */
+verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
+verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
+verify (TYPE_MINIMUM (short int) == SHRT_MIN);
+verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
+verify (TYPE_MINIMUM (int) == INT_MIN);
+verify (TYPE_MAXIMUM (int) == INT_MAX);
+verify (TYPE_MINIMUM (long int) == LONG_MIN);
+verify (TYPE_MAXIMUM (long int) == LONG_MAX);
+#ifdef LLONG_MAX
+verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
+verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
+#endif
+/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */
+#ifdef UINT_WIDTH
+verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
+#endif
+
+/* Does the __typeof__ keyword work? This could be done by
+ 'configure', but for now it's easier to do it by hand. */
+#if (2 <= __GNUC__ \
+ || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
+ || (0x5110 <= __SUNPRO_C && !__STDC__))
+# define _GL_HAVE___TYPEOF__ 1
+#else
+# define _GL_HAVE___TYPEOF__ 0
+#endif
+
+/* Return 1 if the integer type or expression T might be signed. Return 0
+ if it is definitely unsigned. This macro does not evaluate its argument,
+ and expands to an integer constant expression. */
+#if _GL_HAVE___TYPEOF__
+# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
+#else
+# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
+#endif
+
+/* Bound on length of the string representing an unsigned integer
+ value representable in B bits. log10 (2.0) < 146/485. The
+ smallest value of B where this bound is not tight is 2621. */
+#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
+
+/* Bound on length of the string representing an integer type or expression T.
+ Subtract 1 for the sign bit if T is signed, and then add 1 more for
+ a minus sign if needed.
+
+ Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
+ signed, this macro may overestimate the true bound by one byte when
+ applied to unsigned types of size 2, 4, 16, ... bytes. */
+#define INT_STRLEN_BOUND(t) \
+ (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ + _GL_SIGNED_TYPE_OR_EXPR (t))
+
+/* Bound on buffer size needed to represent an integer type or expression T,
+ including the terminating null. */
+#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+
+
+/* Range overflow checks.
+
+ The INT__RANGE_OVERFLOW macros return 1 if the corresponding C
+ operators might not yield numerically correct answers due to
+ arithmetic overflow. They do not rely on undefined or
+ implementation-defined behavior. Their implementations are simple
+ and straightforward, but they are a bit harder to use than the
+ INT__OVERFLOW macros described below.
+
+ Example usage:
+
+ long int i = ...;
+ long int j = ...;
+ if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
+ printf ("multiply would overflow");
+ else
+ printf ("product is %ld", i * j);
+
+ Restrictions on *_RANGE_OVERFLOW macros:
+
+ These macros do not check for all possible numerical problems or
+ undefined or unspecified behavior: they do not check for division
+ by zero, for bad shift counts, or for shifting negative numbers.
+
+ These macros may evaluate their arguments zero or multiple times,
+ so the arguments should not have side effects. The arithmetic
+ arguments (including the MIN and MAX arguments) must be of the same
+ integer type after the usual arithmetic conversions, and the type
+ must have minimum value MIN and maximum MAX. Unsigned types should
+ use a zero MIN of the proper type.
+
+ These macros are tuned for constant MIN and MAX. For commutative
+ operations such as A + B, they are also tuned for constant B. */
+
+/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. */
+#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
+ ((b) < 0 \
+ ? (a) < (min) - (b) \
+ : (max) - (b) < (a))
+
+/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. */
+#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
+ ((b) < 0 \
+ ? (max) + (b) < (a) \
+ : (a) < (min) + (b))
+
+/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. */
+#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
+ ((min) < 0 \
+ ? (a) < - (max) \
+ : 0 < (a))
+
+/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Avoid && and || as they tickle
+ bugs in Sun C 5.11 2010/08/13 and other compilers; see
+ . */
+#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
+ ((b) < 0 \
+ ? ((a) < 0 \
+ ? (a) < (max) / (b) \
+ : (b) == -1 \
+ ? 0 \
+ : (min) / (b) < (a)) \
+ : (b) == 0 \
+ ? 0 \
+ : ((a) < 0 \
+ ? (a) < (min) / (b) \
+ : (max) / (b) < (a)))
+
+/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Do not check for division by zero. */
+#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
+ ((min) < 0 && (b) == -1 && (a) < - (max))
+
+/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Do not check for division by zero.
+ Mathematically, % should never overflow, but on x86-like hosts
+ INT_MIN % -1 traps, and the C standard permits this, so treat this
+ as an overflow too. */
+#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
+ INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
+
+/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Here, MIN and MAX are for A only, and B need
+ not be of the same type as the other arguments. The C standard says that
+ behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
+ A is negative then A << B has undefined behavior and A >> B has
+ implementation-defined behavior, but do not check these other
+ restrictions. */
+#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
+ ((a) < 0 \
+ ? (a) < (min) >> (b) \
+ : (max) >> (b) < (a))
+
+/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
+#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__)
+
+/* True if __builtin_add_overflow_p (A, B, C) works. */
+#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
+
+/* The _GL*_OVERFLOW macros have the same restrictions as the
+ *_RANGE_OVERFLOW macros, except that they do not assume that operands
+ (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
+ that the result (e.g., A + B) has that type. */
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define _GL_ADD_OVERFLOW(a, b, min, max) \
+ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
+ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
+ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
+#else
+# define _GL_ADD_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
+ : (a) < 0 ? (b) <= (a) + (b) \
+ : (b) < 0 ? (a) <= (a) + (b) \
+ : (a) + (b) < (b))
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
+ : (a) < 0 ? 1 \
+ : (b) < 0 ? (a) - (b) <= (a) \
+ : (a) < (b))
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
+ (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
+ || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#endif
+#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
+ : (a) < 0 ? (b) <= (a) + (b) - 1 \
+ : (b) < 0 && (a) + (b) <= (a))
+#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
+ : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
+ : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
+
+/* Return a nonzero value if A is a mathematical multiple of B, where
+ A is unsigned, B is negative, and MAX is the maximum value of A's
+ type. A's type must be the same as (A % B)'s type. Normally (A %
+ -B == 0) suffices, but things get tricky if -B would overflow. */
+#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
+ (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
+ ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
+ ? (a) \
+ : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
+ : (a) % - (b)) \
+ == 0)
+
+/* Check for integer overflow, and report low order bits of answer.
+
+ The INT__OVERFLOW macros return 1 if the corresponding C operators
+ might not yield numerically correct answers due to arithmetic overflow.
+ The INT__WRAPV macros also store the low-order bits of the answer.
+ These macros work correctly on all known practical hosts, and do not rely
+ on undefined behavior due to signed arithmetic overflow.
+
+ Example usage, assuming A and B are long int:
+
+ if (INT_MULTIPLY_OVERFLOW (a, b))
+ printf ("result would overflow\n");
+ else
+ printf ("result is %ld (no overflow)\n", a * b);
+
+ Example usage with WRAPV flavor:
+
+ long int result;
+ bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
+ printf ("result is %ld (%s)\n", result,
+ overflow ? "after overflow" : "no overflow");
+
+ Restrictions on these macros:
+
+ These macros do not check for all possible numerical problems or
+ undefined or unspecified behavior: they do not check for division
+ by zero, for bad shift counts, or for shifting negative numbers.
+
+ These macros may evaluate their arguments zero or multiple times, so the
+ arguments should not have side effects.
+
+ The WRAPV macros are not constant expressions. They support only
+ +, binary -, and *. The result type must be signed.
+
+ These macros are tuned for their last argument being a constant.
+
+ Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
+ A % B, and A << B would overflow, respectively. */
+
+#define INT_ADD_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
+#define INT_SUBTRACT_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
+#else
+# define INT_NEGATE_OVERFLOW(a) \
+ INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
+#define INT_MULTIPLY_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
+#define INT_DIVIDE_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
+#define INT_REMAINDER_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
+#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
+ INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
+ _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+
+/* Return 1 if the expression A B would overflow,
+ where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
+ assuming MIN and MAX are the minimum and maximum for the result type.
+ Arguments should be free of side effects. */
+#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
+ op_result_overflow (a, b, \
+ _GL_INT_MINIMUM (0 * (b) + (a)), \
+ _GL_INT_MAXIMUM (0 * (b) + (a)))
+
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
+ Return 1 if the result overflows. See above for restrictions. */
+#define INT_ADD_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
+#define INT_SUBTRACT_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
+#define INT_MULTIPLY_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
+
+/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
+ https://llvm.org/bugs/show_bug.cgi?id=25390
+ For now, assume all versions of GCC-like compilers generate bogus
+ warnings for _Generic. This matters only for older compilers that
+ lack __builtin_add_overflow. */
+#if __GNUC__
+# define _GL__GENERIC_BOGUS 1
+#else
+# define _GL__GENERIC_BOGUS 0
+#endif
+
+/* Store the low-order bits of A B into *R, where OP specifies
+ the operation. BUILTIN is the builtin operation, and OVERFLOW the
+ overflow predicate. Return 1 if the result overflows. See above
+ for restrictions. */
+#if _GL_HAS_BUILTIN_OVERFLOW
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
+#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
+ (_Generic \
+ (*(r), \
+ signed char: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+ signed char, SCHAR_MIN, SCHAR_MAX), \
+ short int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+ short int, SHRT_MIN, SHRT_MAX), \
+ int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX), \
+ long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX), \
+ long long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX)))
+#else
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
+ (sizeof *(r) == sizeof (signed char) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+ signed char, SCHAR_MIN, SCHAR_MAX) \
+ : sizeof *(r) == sizeof (short int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+ short int, SHRT_MIN, SHRT_MAX) \
+ : sizeof *(r) == sizeof (int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX) \
+ : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
+# ifdef LLONG_MAX
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ (sizeof *(r) == sizeof (long int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX))
+# else
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX)
+# endif
+#endif
+
+/* Store the low-order bits of A B into *R, where the operation
+ is given by OP. Use the unsigned type UT for calculation to avoid
+ overflow problems. *R's type is T, with extremal values TMIN and
+ TMAX. T must be a signed integer type. Return 1 if the result
+ overflows. */
+#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ (sizeof ((a) op (b)) < sizeof (t) \
+ ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
+ : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
+#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ ((overflow (a, b) \
+ || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
+ || (tmax) < ((a) op (b))) \
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
+
+/* Return A B, where the operation is given by OP. Use the
+ unsigned type UT for calculation to avoid overflow problems.
+ Convert the result to type T without overflow by subtracting TMIN
+ from large values before converting, and adding it afterwards.
+ Compilers can optimize all the operations except OP. */
+#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
+ (((ut) (a) op (ut) (b)) <= (tmax) \
+ ? (t) ((ut) (a) op (ut) (b)) \
+ : ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
+
+#endif /* _GL_INTPROPS_H */
diff --git a/lib/isfinite.c b/lib/isfinite.c
index 18c1d217f..d689bb2b9 100644
--- a/lib/isfinite.c
+++ b/lib/isfinite.c
@@ -1,5 +1,5 @@
/* Test for finite value (zero, subnormal, or normal, and not infinite or NaN).
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isinf.c b/lib/isinf.c
index 217de79df..8dd72a305 100644
--- a/lib/isinf.c
+++ b/lib/isinf.c
@@ -1,5 +1,5 @@
/* Test for positive or negative infinity.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnan.c b/lib/isnan.c
index 1557733bf..519f3dc8a 100644
--- a/lib/isnan.c
+++ b/lib/isnan.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnand-nolibm.h b/lib/isnand-nolibm.h
index b0498ef08..1b1c32943 100644
--- a/lib/isnand-nolibm.h
+++ b/lib/isnand-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnand.c b/lib/isnand.c
index 11efbf8d8..906faf152 100644
--- a/lib/isnand.c
+++ b/lib/isnand.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnanf-nolibm.h b/lib/isnanf-nolibm.h
index 9e2aa2f54..9e55c6c1a 100644
--- a/lib/isnanf-nolibm.h
+++ b/lib/isnanf-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnanf.c b/lib/isnanf.c
index c7a66ca3a..2831654d1 100644
--- a/lib/isnanf.c
+++ b/lib/isnanf.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnanl-nolibm.h b/lib/isnanl-nolibm.h
index 9cf090caa..1667e55c0 100644
--- a/lib/isnanl-nolibm.h
+++ b/lib/isnanl-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnanl.c b/lib/isnanl.c
index dbf9d5dd1..fe733bc86 100644
--- a/lib/isnanl.c
+++ b/lib/isnanl.c
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/itold.c b/lib/itold.c
index 136742eab..facf4ae61 100644
--- a/lib/itold.c
+++ b/lib/itold.c
@@ -1,5 +1,5 @@
/* Replacement for 'int' to 'long double' conversion routine.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/langinfo.in.h b/lib/langinfo.in.h
index f4a281a33..689e82c9a 100644
--- a/lib/langinfo.in.h
+++ b/lib/langinfo.in.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around .
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -49,7 +49,10 @@ typedef int nl_item;
# define CODESET 10000
/* nl_langinfo items of the LC_NUMERIC category */
# define RADIXCHAR 10001
+# define DECIMAL_POINT RADIXCHAR
# define THOUSEP 10002
+# define THOUSANDS_SEP THOUSEP
+# define GROUPING 10114
/* nl_langinfo items of the LC_TIME category */
# define D_T_FMT 10003
# define D_FMT 10004
@@ -102,6 +105,21 @@ typedef int nl_item;
# define ALT_DIGITS 10051
/* nl_langinfo items of the LC_MONETARY category */
# define CRNCYSTR 10052
+# define CURRENCY_SYMBOL CRNCYSTR
+# define INT_CURR_SYMBOL 10100
+# define MON_DECIMAL_POINT 10101
+# define MON_THOUSANDS_SEP 10102
+# define MON_GROUPING 10103
+# define POSITIVE_SIGN 10104
+# define NEGATIVE_SIGN 10105
+# define FRAC_DIGITS 10106
+# define INT_FRAC_DIGITS 10107
+# define P_CS_PRECEDES 10108
+# define N_CS_PRECEDES 10109
+# define P_SEP_BY_SPACE 10110
+# define N_SEP_BY_SPACE 10111
+# define P_SIGN_POSN 10112
+# define N_SIGN_POSN 10113
/* nl_langinfo items of the LC_MESSAGES category */
# define YESEXPR 10053
# define NOEXPR 10054
diff --git a/lib/limits.in.h b/lib/limits.in.h
new file mode 100644
index 000000000..7ff33ab12
--- /dev/null
+++ b/lib/limits.in.h
@@ -0,0 +1,63 @@
+/* A GNU-like .
+
+ Copyright 2016-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, see . */
+
+#ifndef _@GUARD_PREFIX@_LIMITS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
+
+#ifndef _@GUARD_PREFIX@_LIMITS_H
+#define _@GUARD_PREFIX@_LIMITS_H
+
+/* The number of usable bits in an unsigned or signed integer type
+ with minimum value MIN and maximum value MAX, as an int expression
+ suitable in #if. Cover all known practical hosts. This
+ implementation exploits the fact that MAX is 1 less than a power of
+ 2, and merely counts the number of 1 bits in MAX; "COBn" means
+ "count the number of 1 bits in the low-order n bits"). */
+#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
+#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
+#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
+#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
+#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
+#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
+#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (! defined ULLONG_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
+# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
+# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
+# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
+# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
+# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
+# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
+# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
+# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
+# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
+# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
+#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
+
+#endif /* _@GUARD_PREFIX@_LIMITS_H */
+#endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/lib/link.c b/lib/link.c
index 9db1f8cef..625d2e82d 100644
--- a/lib/link.c
+++ b/lib/link.c
@@ -1,6 +1,6 @@
/* Emulate link on platforms that lack it, namely native Windows platforms.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/listen.c b/lib/listen.c
index 912f1b7a7..284415a08 100644
--- a/lib/listen.c
+++ b/lib/listen.c
@@ -1,6 +1,6 @@
/* listen.c --- wrappers for Windows listen function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/localcharset.c b/lib/localcharset.c
index 7f09567ce..4be72d616 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006, 2008-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -34,6 +34,7 @@
#if defined _WIN32 || defined __WIN32__
# define WINDOWS_NATIVE
+# include
#endif
#if defined __EMX__
@@ -127,7 +128,7 @@ get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
-#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__)
+#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2)
const char *dir;
const char *base = "charset.alias";
char *file_name;
@@ -341,6 +342,36 @@ get_charset_aliases (void)
"CP54936" "\0" "GB18030" "\0"
"CP65001" "\0" "UTF-8" "\0";
# endif
+# if defined OS2
+ /* To avoid the troubles of installing a separate file in the same
+ directory as the DLL and of retrieving the DLL's directory at
+ runtime, simply inline the aliases here. */
+
+ /* The list of encodings is taken from "List of OS/2 Codepages"
+ by Alex Taylor:
+ .
+ See also "IBM Globalization - Code page identifiers":
+ . */
+ cp = "CP813" "\0" "ISO-8859-7" "\0"
+ "CP878" "\0" "KOI8-R" "\0"
+ "CP819" "\0" "ISO-8859-1" "\0"
+ "CP912" "\0" "ISO-8859-2" "\0"
+ "CP913" "\0" "ISO-8859-3" "\0"
+ "CP914" "\0" "ISO-8859-4" "\0"
+ "CP915" "\0" "ISO-8859-5" "\0"
+ "CP916" "\0" "ISO-8859-8" "\0"
+ "CP920" "\0" "ISO-8859-9" "\0"
+ "CP921" "\0" "ISO-8859-13" "\0"
+ "CP923" "\0" "ISO-8859-15" "\0"
+ "CP954" "\0" "EUC-JP" "\0"
+ "CP964" "\0" "EUC-TW" "\0"
+ "CP970" "\0" "EUC-KR" "\0"
+ "CP1089" "\0" "ISO-8859-6" "\0"
+ "CP1208" "\0" "UTF-8" "\0"
+ "CP1381" "\0" "GB2312" "\0"
+ "CP1386" "\0" "GBK" "\0"
+ "CP3372" "\0" "EUC-JP" "\0";
+# endif
#endif
charset_aliases = cp;
@@ -461,14 +492,34 @@ locale_charset (void)
static char buf[2 + 10 + 1];
- /* The Windows API has a function returning the locale's codepage as a
- number: GetACP().
- When the output goes to a console window, it needs to be provided in
- GetOEMCP() encoding if the console is using a raster font, or in
- GetConsoleOutputCP() encoding if it is using a TrueType font.
- But in GUI programs and for output sent to files and pipes, GetACP()
- encoding is the best bet. */
- sprintf (buf, "CP%u", GetACP ());
+ /* The Windows API has a function returning the locale's codepage as
+ a number, but the value doesn't change according to what the
+ 'setlocale' call specified. So we use it as a last resort, in
+ case the string returned by 'setlocale' doesn't specify the
+ codepage. */
+ char *current_locale = setlocale (LC_ALL, NULL);
+ char *pdot;
+
+ /* If they set different locales for different categories,
+ 'setlocale' will return a semi-colon separated list of locale
+ values. To make sure we use the correct one, we choose LC_CTYPE. */
+ if (strchr (current_locale, ';'))
+ current_locale = setlocale (LC_CTYPE, NULL);
+
+ pdot = strrchr (current_locale, '.');
+ if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
+ sprintf (buf, "CP%s", pdot + 1);
+ else
+ {
+ /* The Windows API has a function returning the locale's codepage as a
+ number: GetACP().
+ When the output goes to a console window, it needs to be provided in
+ GetOEMCP() encoding if the console is using a raster font, or in
+ GetConsoleOutputCP() encoding if it is using a TrueType font.
+ But in GUI programs and for output sent to files and pipes, GetACP()
+ encoding is the best bet. */
+ sprintf (buf, "CP%u", GetACP ());
+ }
codeset = buf;
#elif defined OS2
@@ -478,6 +529,8 @@ locale_charset (void)
ULONG cp[3];
ULONG cplen;
+ codeset = NULL;
+
/* Allow user to override the codeset, as set in the operating system,
with standard language environment variables. */
locale = getenv ("LC_ALL");
@@ -509,10 +562,12 @@ locale_charset (void)
}
}
- /* Resolve through the charset.alias file. */
- codeset = locale;
+ /* For the POSIX locale, don't use the system's codepage. */
+ if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
+ codeset = "";
}
- else
+
+ if (codeset == NULL)
{
/* OS/2 has a function returning the locale's codepage as a number. */
if (DosQueryCp (sizeof (cp), cp, &cplen))
diff --git a/lib/localcharset.h b/lib/localcharset.h
index 4b104c304..641eceae5 100644
--- a/lib/localcharset.h
+++ b/lib/localcharset.h
@@ -1,5 +1,5 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2003, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2009-2017 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/locale.in.h b/lib/locale.in.h
index a10b129ca..50ccae610 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -1,5 +1,5 @@
/* A POSIX .
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/localeconv.c b/lib/localeconv.c
index ed2767be0..c38035f0d 100644
--- a/lib/localeconv.c
+++ b/lib/localeconv.c
@@ -1,5 +1,5 @@
/* Query locale dependent information for formatting numbers.
- Copyright (C) 2012-2014 Free Software Foundation, Inc.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/log.c b/lib/log.c
index ef8d332f8..2ec8cb9d5 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,5 +1,5 @@
/* Logarithm.
- Copyright (C) 2012-2014 Free Software Foundation, Inc.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/log1p.c b/lib/log1p.c
index d1132d3e4..d266290ac 100644
--- a/lib/log1p.c
+++ b/lib/log1p.c
@@ -1,5 +1,5 @@
/* Natural logarithm of 1 plus argument.
- Copyright (C) 2012-2014 Free Software Foundation, Inc.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/lstat.c b/lib/lstat.c
index cff1188f3..f4cdb2a3e 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -1,6 +1,6 @@
/* Work around a bug of lstat on some systems
- Copyright (C) 1997-2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 1997-2006, 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/malloc.c b/lib/malloc.c
index c6e292a74..6b5e53ee7 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -1,6 +1,6 @@
/* malloc() function that is glibc compatible.
- Copyright (C) 1997-1998, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 1997-1998, 2006-2007, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/malloca.c b/lib/malloca.c
index 3e95f2333..c0ff33568 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003, 2006-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2007, 2009-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2003.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/malloca.h b/lib/malloca.h
index 5810afa54..3b61ca2b9 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2003.
This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,9 @@
#include
#include
#include
+#include
+
+#include "xalloc-oversized.h"
#ifdef __cplusplus
@@ -73,15 +76,7 @@ extern void freea (void *p);
It allocates an array of N objects, each with S bytes of memory,
on the stack. S must be positive and N must be nonnegative.
The array must be freed using freea() before the function returns. */
-#if 1
-/* Cf. the definition of xalloc_oversized. */
-# define nmalloca(n, s) \
- ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
- ? NULL \
- : malloca ((n) * (s)))
-#else
-extern void * nmalloca (size_t n, size_t s);
-#endif
+#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
#ifdef __cplusplus
diff --git a/lib/math.c b/lib/math.c
index ddb2ded53..ba2a6abd6 100644
--- a/lib/math.c
+++ b/lib/math.c
@@ -1,3 +1,4 @@
#include
#define _GL_MATH_INLINE _GL_EXTERN_INLINE
#include "math.h"
+typedef int dummy;
diff --git a/lib/math.in.h b/lib/math.in.h
index 4f2aa862b..53d385e54 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -1,6 +1,6 @@
/* A GNU-like .
- Copyright (C) 2002-2003, 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -63,6 +63,7 @@ _gl_cxx_ ## func ## l (long double l) \
return func (l); \
}
# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \
+_GL_BEGIN_NAMESPACE \
inline int \
func (float f) \
{ \
@@ -77,7 +78,8 @@ inline int \
func (long double l) \
{ \
return _gl_cxx_ ## func ## l (l); \
-}
+} \
+_GL_END_NAMESPACE
#endif
/* Helper macros to define a portability warning for the
@@ -210,11 +212,20 @@ _NaN ()
#if @GNULIB_ACOSF@
-# if !@HAVE_ACOSF@
-# undef acosf
+# if @REPLACE_ACOSF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef acosf
+# define acosf rpl_acosf
+# endif
+_GL_FUNCDECL_RPL (acosf, float, (float x));
+_GL_CXXALIAS_RPL (acosf, float, (float x));
+# else
+# if !@HAVE_ACOSF@
+# undef acosf
_GL_FUNCDECL_SYS (acosf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (acosf, float, (float x));
+# endif
_GL_CXXALIASWARN (acosf);
#elif defined GNULIB_POSIXCHECK
# undef acosf
@@ -241,11 +252,20 @@ _GL_WARN_ON_USE (acosl, "acosl is unportable - "
#if @GNULIB_ASINF@
-# if !@HAVE_ASINF@
-# undef asinf
+# if @REPLACE_ASINF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef asinf
+# define asinf rpl_asinf
+# endif
+_GL_FUNCDECL_RPL (asinf, float, (float x));
+_GL_CXXALIAS_RPL (asinf, float, (float x));
+# else
+# if !@HAVE_ASINF@
+# undef asinf
_GL_FUNCDECL_SYS (asinf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (asinf, float, (float x));
+# endif
_GL_CXXALIASWARN (asinf);
#elif defined GNULIB_POSIXCHECK
# undef asinf
@@ -272,11 +292,20 @@ _GL_WARN_ON_USE (asinl, "asinl is unportable - "
#if @GNULIB_ATANF@
-# if !@HAVE_ATANF@
-# undef atanf
+# if @REPLACE_ATANF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef atanf
+# define atanf rpl_atanf
+# endif
+_GL_FUNCDECL_RPL (atanf, float, (float x));
+_GL_CXXALIAS_RPL (atanf, float, (float x));
+# else
+# if !@HAVE_ATANF@
+# undef atanf
_GL_FUNCDECL_SYS (atanf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (atanf, float, (float x));
+# endif
_GL_CXXALIASWARN (atanf);
#elif defined GNULIB_POSIXCHECK
# undef atanf
@@ -303,11 +332,20 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
#if @GNULIB_ATAN2F@
-# if !@HAVE_ATAN2F@
-# undef atan2f
+# if @REPLACE_ATAN2F@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef atan2f
+# define atan2f rpl_atan2f
+# endif
+_GL_FUNCDECL_RPL (atan2f, float, (float y, float x));
+_GL_CXXALIAS_RPL (atan2f, float, (float y, float x));
+# else
+# if !@HAVE_ATAN2F@
+# undef atan2f
_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
+# endif
_GL_CXXALIASWARN (atan2f);
#elif defined GNULIB_POSIXCHECK
# undef atan2f
@@ -406,6 +444,7 @@ _GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
#if @GNULIB_CEIL@
# if @REPLACE_CEIL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ceil
# define ceil rpl_ceil
# endif
_GL_FUNCDECL_RPL (ceil, double, (double x));
@@ -485,11 +524,20 @@ _GL_WARN_ON_USE (copysign, "copysignl is unportable - "
#if @GNULIB_COSF@
-# if !@HAVE_COSF@
-# undef cosf
+# if @REPLACE_COSF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef cosf
+# define cosf rpl_cosf
+# endif
+_GL_FUNCDECL_RPL (cosf, float, (float x));
+_GL_CXXALIAS_RPL (cosf, float, (float x));
+# else
+# if !@HAVE_COSF@
+# undef cosf
_GL_FUNCDECL_SYS (cosf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (cosf, float, (float x));
+# endif
_GL_CXXALIASWARN (cosf);
#elif defined GNULIB_POSIXCHECK
# undef cosf
@@ -516,11 +564,20 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - "
#if @GNULIB_COSHF@
-# if !@HAVE_COSHF@
-# undef coshf
+# if @REPLACE_COSHF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef coshf
+# define coshf rpl_coshf
+# endif
+_GL_FUNCDECL_RPL (coshf, float, (float x));
+_GL_CXXALIAS_RPL (coshf, float, (float x));
+# else
+# if !@HAVE_COSHF@
+# undef coshf
_GL_FUNCDECL_SYS (coshf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (coshf, float, (float x));
+# endif
_GL_CXXALIASWARN (coshf);
#elif defined GNULIB_POSIXCHECK
# undef coshf
@@ -532,11 +589,20 @@ _GL_WARN_ON_USE (coshf, "coshf is unportable - "
#if @GNULIB_EXPF@
-# if !@HAVE_EXPF@
-# undef expf
+# if @REPLACE_EXPF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef expf
+# define expf rpl_expf
+# endif
+_GL_FUNCDECL_RPL (expf, float, (float x));
+_GL_CXXALIAS_RPL (expf, float, (float x));
+# else
+# if !@HAVE_EXPF@
+# undef expf
_GL_FUNCDECL_SYS (expf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (expf, float, (float x));
+# endif
_GL_CXXALIASWARN (expf);
#elif defined GNULIB_POSIXCHECK
# undef expf
@@ -753,6 +819,7 @@ _GL_WARN_ON_USE (floorf, "floorf is unportable - "
#if @GNULIB_FLOOR@
# if @REPLACE_FLOOR@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef floor
# define floor rpl_floor
# endif
_GL_FUNCDECL_RPL (floor, double, (double x));
@@ -973,6 +1040,7 @@ _GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
#if @GNULIB_FREXP@
# if @REPLACE_FREXP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef frexp
# define frexp rpl_frexp
# endif
_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
@@ -980,7 +1048,7 @@ _GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
# else
_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
# endif
-_GL_CXXALIASWARN (frexp);
+_GL_CXXALIASWARN1 (frexp, double, (double x, int *expptr));
#elif defined GNULIB_POSIXCHECK
# undef frexp
/* Assume frexp is always declared. */
@@ -1822,11 +1890,20 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - "
#if @GNULIB_SINF@
-# if !@HAVE_SINF@
-# undef sinf
+# if @REPLACE_SINF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sinf
+# define sinf rpl_sinf
+# endif
+_GL_FUNCDECL_RPL (sinf, float, (float x));
+_GL_CXXALIAS_RPL (sinf, float, (float x));
+# else
+# if !@HAVE_SINF@
+ # undef sinf
_GL_FUNCDECL_SYS (sinf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (sinf, float, (float x));
+# endif
_GL_CXXALIASWARN (sinf);
#elif defined GNULIB_POSIXCHECK
# undef sinf
@@ -1853,11 +1930,20 @@ _GL_WARN_ON_USE (sinl, "sinl is unportable - "
#if @GNULIB_SINHF@
-# if !@HAVE_SINHF@
-# undef sinhf
+# if @REPLACE_SINHF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sinhf
+# define sinhf rpl_sinhf
+# endif
+_GL_FUNCDECL_RPL (sinhf, float, (float x));
+_GL_CXXALIAS_RPL (sinhf, float, (float x));
+# else
+# if !@HAVE_SINHF@
+# undef sinhf
_GL_FUNCDECL_SYS (sinhf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (sinhf, float, (float x));
+# endif
_GL_CXXALIASWARN (sinhf);
#elif defined GNULIB_POSIXCHECK
# undef sinhf
@@ -1869,11 +1955,20 @@ _GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
#if @GNULIB_SQRTF@
-# if !@HAVE_SQRTF@
-# undef sqrtf
+# if @REPLACE_SQRTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sqrtf
+# define sqrtf rpl_sqrtf
+# endif
+_GL_FUNCDECL_RPL (sqrtf, float, (float x));
+_GL_CXXALIAS_RPL (sqrtf, float, (float x));
+# else
+# if !@HAVE_SQRTF@
+# undef sqrtf
_GL_FUNCDECL_SYS (sqrtf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (sqrtf, float, (float x));
+# endif
_GL_CXXALIASWARN (sqrtf);
#elif defined GNULIB_POSIXCHECK
# undef sqrtf
@@ -1909,11 +2004,20 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
#if @GNULIB_TANF@
-# if !@HAVE_TANF@
-# undef tanf
+# if @REPLACE_TANF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tanf
+# define tanf rpl_tanf
+# endif
+_GL_FUNCDECL_RPL (tanf, float, (float x));
+_GL_CXXALIAS_RPL (tanf, float, (float x));
+# else
+# if !@HAVE_TANF@
+# undef tanf
_GL_FUNCDECL_SYS (tanf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (tanf, float, (float x));
+# endif
_GL_CXXALIASWARN (tanf);
#elif defined GNULIB_POSIXCHECK
# undef tanf
@@ -1940,11 +2044,20 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - "
#if @GNULIB_TANHF@
-# if !@HAVE_TANHF@
-# undef tanhf
+# if @REPLACE_TANHF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tanhf
+# define tanhf rpl_tanhf
+# endif
+_GL_FUNCDECL_RPL (tanhf, float, (float x));
+_GL_CXXALIAS_RPL (tanhf, float, (float x));
+# else
+# if !@HAVE_TANHF@
+# undef tanhf
_GL_FUNCDECL_SYS (tanhf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (tanhf, float, (float x));
+# endif
_GL_CXXALIASWARN (tanhf);
#elif defined GNULIB_POSIXCHECK
# undef tanhf
@@ -1958,6 +2071,7 @@ _GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
#if @GNULIB_TRUNCF@
# if @REPLACE_TRUNCF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef truncf
# define truncf rpl_truncf
# endif
_GL_FUNCDECL_RPL (truncf, float, (float x));
@@ -1980,6 +2094,7 @@ _GL_WARN_ON_USE (truncf, "truncf is unportable - "
#if @GNULIB_TRUNC@
# if @REPLACE_TRUNC@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef trunc
# define trunc rpl_trunc
# endif
_GL_FUNCDECL_RPL (trunc, double, (double x));
@@ -2039,7 +2154,7 @@ _GL_EXTERN_C int gl_isfinitel (long double x);
gl_isfinitef (x))
# endif
# ifdef __cplusplus
-# ifdef isfinite
+# if defined isfinite || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
# undef isfinite
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite)
@@ -2066,7 +2181,7 @@ _GL_EXTERN_C int gl_isinfl (long double x);
gl_isinff (x))
# endif
# ifdef __cplusplus
-# ifdef isinf
+# if defined isinf || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
# undef isinf
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf)
@@ -2184,7 +2299,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
__builtin_isnanf ((float)(x)))
# endif
# ifdef __cplusplus
-# ifdef isnan
+# if defined isnan || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
# undef isnan
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan)
@@ -2205,7 +2320,8 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
#if @GNULIB_SIGNBIT@
-# if @REPLACE_SIGNBIT_USING_GCC@
+# if (@REPLACE_SIGNBIT_USING_GCC@ \
+ && (!defined __cplusplus || __cplusplus < 201103))
# undef signbit
/* GCC 4.0 and newer provides three built-ins for signbit. */
# define signbit(x) \
@@ -2258,7 +2374,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
gl_signbitf (x))
# endif
# ifdef __cplusplus
-# ifdef signbit
+# if defined signbit || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
# undef signbit
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index dff12962d..d19b1a035 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2008.
This program is free software: you can redistribute it and/or modify
@@ -20,6 +20,11 @@
/* Specification. */
#include
+#if C_LOCALE_MAYBE_EILSEQ
+# include "hard-locale.h"
+# include
+#endif
+
#if GNULIB_defined_mbstate_t
/* Implement mbrtowc() on top of mbtowc(). */
@@ -328,7 +333,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
-# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG
+ size_t ret;
+ wchar_t wc;
+
+# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
if (s == NULL)
{
pwc = NULL;
@@ -337,6 +345,14 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
# endif
+# if MBRTOWC_EMPTY_INPUT_BUG
+ if (n == 0)
+ return (size_t) -2;
+# endif
+
+ if (! pwc)
+ pwc = &wc;
+
# if MBRTOWC_RETVAL_BUG
{
static mbstate_t internal_state;
@@ -352,8 +368,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t count = 0;
for (; n > 0; s++, n--)
{
- wchar_t wc;
- size_t ret = mbrtowc (&wc, s, 1, ps);
+ ret = mbrtowc (&wc, s, 1, ps);
if (ret == (size_t)(-1))
return (size_t)(-1);
@@ -361,8 +376,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
if (ret != (size_t)(-2))
{
/* The multibyte character has been completed. */
- if (pwc != NULL)
- *pwc = wc;
+ *pwc = wc;
return (wc == 0 ? 0 : count);
}
}
@@ -371,32 +385,23 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
# endif
+ ret = mbrtowc (pwc, s, n, ps);
+
# if MBRTOWC_NUL_RETVAL_BUG
- {
- wchar_t wc;
- size_t ret = mbrtowc (&wc, s, n, ps);
-
- if (ret != (size_t)(-1) && ret != (size_t)(-2))
- {
- if (pwc != NULL)
- *pwc = wc;
- if (wc == 0)
- ret = 0;
- }
- return ret;
- }
-# else
- {
-# if MBRTOWC_NULL_ARG1_BUG
- wchar_t dummy;
-
- if (pwc == NULL)
- pwc = &dummy;
-# endif
-
- return mbrtowc (pwc, s, n, ps);
- }
+ if (ret < (size_t) -2 && !*pwc)
+ return 0;
# endif
+
+# if C_LOCALE_MAYBE_EILSEQ
+ if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
+ {
+ unsigned char uc = *s;
+ *pwc = uc;
+ return 1;
+ }
+# endif
+
+ return ret;
}
#endif
diff --git a/lib/mbsinit.c b/lib/mbsinit.c
index 71bae341b..4d0b1184a 100644
--- a/lib/mbsinit.c
+++ b/lib/mbsinit.c
@@ -1,5 +1,5 @@
/* Test for initial conversion state.
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc-impl.h b/lib/mbtowc-impl.h
index df11ad2bf..268f0e3da 100644
--- a/lib/mbtowc-impl.h
+++ b/lib/mbtowc-impl.h
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc.c b/lib/mbtowc.c
index bd9d3aa6b..fbed5dc2f 100644
--- a/lib/mbtowc.c
+++ b/lib/mbtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/memchr.c b/lib/memchr.c
index c1caad3a2..91c2b8767 100644
--- a/lib/memchr.c
+++ b/lib/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2014
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2017
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
diff --git a/lib/mkdir.c b/lib/mkdir.c
index f1b802b57..1ac765007 100644
--- a/lib/mkdir.c
+++ b/lib/mkdir.c
@@ -1,7 +1,7 @@
/* On some systems, mkdir ("foo/", 0700) fails because of the trailing
slash. On those systems, this wrapper removes the trailing slash.
- Copyright (C) 2001, 2003, 2006, 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2006, 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/mkstemp.c b/lib/mkostemp.c
similarity index 75%
rename from lib/mkstemp.c
rename to lib/mkostemp.c
index 0af69f9c3..d2190bd6e 100644
--- a/lib/mkstemp.c
+++ b/lib/mkostemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2014 Free Software
+/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2017 Free Software
Foundation, Inc.
This file is derived from the one in the GNU C Library.
@@ -24,7 +24,7 @@
#if !_LIBC
# include "tempname.h"
# define __gen_tempname gen_tempname
-# ifndef __GT_FILE
+# ifndef __GTFILE
# define __GT_FILE GT_FILE
# endif
#endif
@@ -38,13 +38,9 @@
/* Generate a unique temporary file name from XTEMPLATE.
The last six characters of XTEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
- Then open the file and return a fd.
-
- If you are creating temporary files which will later be removed,
- consider using the clean-temp module, which avoids several pitfalls
- of using mkstemp directly. */
+ Then open the file and return a fd. */
int
-mkstemp (char *xtemplate)
+mkostemp (char *xtemplate, int flags)
{
- return __gen_tempname (xtemplate, 0, 0, __GT_FILE);
+ return __gen_tempname (xtemplate, 0, flags, __GT_FILE);
}
diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h
new file mode 100644
index 000000000..bfde06fa2
--- /dev/null
+++ b/lib/mktime-internal.h
@@ -0,0 +1,37 @@
+/* mktime variant that also uses an offset guess
+
+ Copyright 2016-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see
+ . */
+
+#include
+
+/* mktime_offset_t is a signed type wide enough to hold a UTC offset
+ in seconds, and used as part of the type of the offset-guess
+ argument to mktime_internal. Use time_t on platforms where time_t
+ is signed, to be compatible with platforms like BeOS that export
+ this implementation detail of mktime. On platforms where time_t is
+ unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
+ which is wide enough for a UTC offset. */
+
+#if TIME_T_IS_SIGNED
+typedef time_t mktime_offset_t;
+#else
+typedef int mktime_offset_t;
+#endif
+
+time_t mktime_internal (struct tm *,
+ struct tm * (*) (time_t const *, struct tm *),
+ mktime_offset_t *);
diff --git a/lib/mktime.c b/lib/mktime.c
new file mode 100644
index 000000000..2efd44a22
--- /dev/null
+++ b/lib/mktime.c
@@ -0,0 +1,630 @@
+/* Convert a 'struct tm' to a time_t value.
+ Copyright (C) 1993-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Eggert .
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ . */
+
+/* Define this to 1 to have a standalone program to test this implementation of
+ mktime. */
+#ifndef DEBUG_MKTIME
+# define DEBUG_MKTIME 0
+#endif
+
+#if !defined _LIBC && !DEBUG_MKTIME
+# include
+#endif
+
+/* Assume that leap seconds are possible, unless told otherwise.
+ If the host has a 'zic' command with a '-L leapsecondfilename' option,
+ then it supports leap seconds; otherwise it probably doesn't. */
+#ifndef LEAP_SECONDS_POSSIBLE
+# define LEAP_SECONDS_POSSIBLE 1
+#endif
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+#if DEBUG_MKTIME
+# include
+# include
+# include
+/* Make it work even if the system's libc has its own mktime routine. */
+# undef mktime
+# define mktime my_mktime
+#endif
+
+/* A signed type that can represent an integer number of years
+ multiplied by three times the number of seconds in a year. It is
+ needed when converting a tm_year value times the number of seconds
+ in a year. The factor of three comes because these products need
+ to be subtracted from each other, and sometimes with an offset
+ added to them, without worrying about overflow.
+
+ Much of the code uses long_int to represent time_t values, to
+ lessen the hassle of dealing with platforms where time_t is
+ unsigned, and because long_int should suffice to represent all
+ time_t values that mktime can generate even on platforms where
+ time_t is excessively wide. */
+
+#if INT_MAX <= LONG_MAX / 3 / 366 / 24 / 60 / 60
+typedef long int long_int;
+#else
+typedef long long int long_int;
+#endif
+verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 3 / 366 / 24 / 60 / 60);
+
+/* Shift A right by B bits portably, by dividing A by 2**B and
+ truncating towards minus infinity. B should be in the range 0 <= B
+ <= LONG_INT_BITS - 2, where LONG_INT_BITS is the number of useful
+ bits in a long_int. LONG_INT_BITS is at least 32.
+
+ ISO C99 says that A >> B is implementation-defined if A < 0. Some
+ implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
+ right in the usual way when A < 0, so SHR falls back on division if
+ ordinary A >> B doesn't seem to be the usual signed shift. */
+
+static long_int
+shr (long_int a, int b)
+{
+ long_int one = 1;
+ return (-one >> 1 == -1
+ ? a >> b
+ : a / (one << b) - (a % (one << b) < 0));
+}
+
+/* Bounds for the intersection of time_t and long_int. */
+
+static long_int const mktime_min
+ = ((TYPE_SIGNED (time_t) && TYPE_MINIMUM (time_t) < TYPE_MINIMUM (long_int))
+ ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (time_t));
+static long_int const mktime_max
+ = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (time_t)
+ ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (time_t));
+
+verify (TYPE_IS_INTEGER (time_t));
+
+#define EPOCH_YEAR 1970
+#define TM_YEAR_BASE 1900
+verify (TM_YEAR_BASE % 100 == 0);
+
+/* Is YEAR + TM_YEAR_BASE a leap year? */
+static bool
+leapyear (long_int year)
+{
+ /* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
+ Also, work even if YEAR is negative. */
+ return
+ ((year & 3) == 0
+ && (year % 100 != 0
+ || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3)));
+}
+
+/* How many days come before each month (0-12). */
+#ifndef _LIBC
+static
+#endif
+const unsigned short int __mon_yday[2][13] =
+ {
+ /* Normal years. */
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ /* Leap years. */
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+ };
+
+
+#ifdef _LIBC
+typedef time_t mktime_offset_t;
+#else
+/* Portable standalone applications should supply a that
+ declares a POSIX-compliant localtime_r, for the benefit of older
+ implementations that lack localtime_r or have a nonstandard one.
+ See the gnulib time_r module for one way to implement this. */
+# undef __localtime_r
+# define __localtime_r localtime_r
+# define __mktime_internal mktime_internal
+# include "mktime-internal.h"
+#endif
+
+/* Do the values A and B differ according to the rules for tm_isdst?
+ A and B differ if one is zero and the other positive. */
+static bool
+isdst_differ (int a, int b)
+{
+ return (!a != !b) && (0 <= a) && (0 <= b);
+}
+
+/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
+ (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
+ were not adjusted between the timestamps.
+
+ The YEAR values uses the same numbering as TP->tm_year. Values
+ need not be in the usual range. However, YEAR1 must not overflow
+ when multiplied by three times the number of seconds in a year, and
+ likewise for YDAY1 and three times the number of seconds in a day. */
+
+static long_int
+ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
+ int year0, int yday0, int hour0, int min0, int sec0)
+{
+ verify (-1 / 2 == 0);
+
+ /* Compute intervening leap days correctly even if year is negative.
+ Take care to avoid integer overflow here. */
+ int a4 = shr (year1, 2) + shr (TM_YEAR_BASE, 2) - ! (year1 & 3);
+ int b4 = shr (year0, 2) + shr (TM_YEAR_BASE, 2) - ! (year0 & 3);
+ int a100 = a4 / 25 - (a4 % 25 < 0);
+ int b100 = b4 / 25 - (b4 % 25 < 0);
+ int a400 = shr (a100, 2);
+ int b400 = shr (b100, 2);
+ int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
+
+ /* Compute the desired time without overflowing. */
+ long_int years = year1 - year0;
+ long_int days = 365 * years + yday1 - yday0 + intervening_leap_days;
+ long_int hours = 24 * days + hour1 - hour0;
+ long_int minutes = 60 * hours + min1 - min0;
+ long_int seconds = 60 * minutes + sec1 - sec0;
+ return seconds;
+}
+
+/* Return the average of A and B, even if A + B would overflow.
+ Round toward positive infinity. */
+static long_int
+long_int_avg (long_int a, long_int b)
+{
+ return shr (a, 1) + shr (b, 1) + ((a | b) & 1);
+}
+
+/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC),
+ assuming that T corresponds to *TP and that no clock adjustments
+ occurred between *TP and the desired time.
+ Although T and the returned value are of type long_int,
+ they represent time_t values and must be in time_t range.
+ If TP is null, return a value not equal to T; this avoids false matches.
+ YEAR and YDAY must not be so large that multiplying them by three times the
+ number of seconds in a year (or day, respectively) would overflow long_int.
+ If the returned value would be out of range, yield the minimal or
+ maximal in-range value, except do not yield a value equal to T. */
+static long_int
+guess_time_tm (long_int year, long_int yday, int hour, int min, int sec,
+ long_int t, const struct tm *tp)
+{
+ if (tp)
+ {
+ long_int result;
+ long_int d = ydhms_diff (year, yday, hour, min, sec,
+ tp->tm_year, tp->tm_yday,
+ tp->tm_hour, tp->tm_min, tp->tm_sec);
+ if (! INT_ADD_WRAPV (t, d, &result))
+ return result;
+ }
+
+ /* Overflow occurred one way or another. Return the nearest result
+ that is actually in range, except don't report a zero difference
+ if the actual difference is nonzero, as that would cause a false
+ match; and don't oscillate between two values, as that would
+ confuse the spring-forward gap detector. */
+ return (t < long_int_avg (mktime_min, mktime_max)
+ ? (t <= mktime_min + 1 ? t + 1 : mktime_min)
+ : (mktime_max - 1 <= t ? t - 1 : mktime_max));
+}
+
+/* Use CONVERT to convert T to a struct tm value in *TM. T must be in
+ range for time_t. Return TM if successful, NULL if T is out of
+ range for CONVERT. */
+static struct tm *
+convert_time (struct tm *(*convert) (const time_t *, struct tm *),
+ long_int t, struct tm *tm)
+{
+ time_t x = t;
+ return convert (&x, tm);
+}
+
+/* Use CONVERT to convert *T to a broken down time in *TP.
+ If *T is out of range for conversion, adjust it so that
+ it is the nearest in-range value and then convert that.
+ A value is in range if it fits in both time_t and long_int. */
+static struct tm *
+ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
+ long_int *t, struct tm *tp)
+{
+ struct tm *r;
+ if (*t < mktime_min)
+ *t = mktime_min;
+ else if (mktime_max < *t)
+ *t = mktime_max;
+ r = convert_time (convert, *t, tp);
+
+ if (!r && *t)
+ {
+ long_int bad = *t;
+ long_int ok = 0;
+
+ /* BAD is a known unconvertible value, and OK is a known good one.
+ Use binary search to narrow the range between BAD and OK until
+ they differ by 1. */
+ while (true)
+ {
+ long_int mid = long_int_avg (ok, bad);
+ if (mid != ok && mid != bad)
+ break;
+ r = convert_time (convert, mid, tp);
+ if (r)
+ ok = mid;
+ else
+ bad = mid;
+ }
+
+ if (!r && ok)
+ {
+ /* The last conversion attempt failed;
+ revert to the most recent successful attempt. */
+ r = convert_time (convert, ok, tp);
+ }
+ }
+
+ return r;
+}
+
+/* Convert *TP to a time_t value, inverting
+ the monotonic and mostly-unit-linear conversion function CONVERT.
+ Use *OFFSET to keep track of a guess at the offset of the result,
+ compared to what the result would be for UTC without leap seconds.
+ If *OFFSET's guess is correct, only one CONVERT call is needed.
+ This function is external because it is used also by timegm.c. */
+time_t
+__mktime_internal (struct tm *tp,
+ struct tm *(*convert) (const time_t *, struct tm *),
+ mktime_offset_t *offset)
+{
+ long_int t, gt, t0, t1, t2, dt;
+ struct tm tm;
+
+ /* The maximum number of probes (calls to CONVERT) should be enough
+ to handle any combinations of time zone rule changes, solar time,
+ leap seconds, and oscillations around a spring-forward gap.
+ POSIX.1 prohibits leap seconds, but some hosts have them anyway. */
+ int remaining_probes = 6;
+
+ /* Time requested. Copy it in case CONVERT modifies *TP; this can
+ occur if TP is localtime's returned value and CONVERT is localtime. */
+ int sec = tp->tm_sec;
+ int min = tp->tm_min;
+ int hour = tp->tm_hour;
+ int mday = tp->tm_mday;
+ int mon = tp->tm_mon;
+ int year_requested = tp->tm_year;
+ int isdst = tp->tm_isdst;
+
+ /* 1 if the previous probe was DST. */
+ int dst2;
+
+ /* Ensure that mon is in range, and set year accordingly. */
+ int mon_remainder = mon % 12;
+ int negative_mon_remainder = mon_remainder < 0;
+ int mon_years = mon / 12 - negative_mon_remainder;
+ long_int lyear_requested = year_requested;
+ long_int year = lyear_requested + mon_years;
+
+ /* The other values need not be in range:
+ the remaining code handles overflows correctly. */
+
+ /* Calculate day of year from year, month, and day of month.
+ The result need not be in range. */
+ int mon_yday = ((__mon_yday[leapyear (year)]
+ [mon_remainder + 12 * negative_mon_remainder])
+ - 1);
+ long_int lmday = mday;
+ long_int yday = mon_yday + lmday;
+
+ int negative_offset_guess;
+
+ int sec_requested = sec;
+
+ if (LEAP_SECONDS_POSSIBLE)
+ {
+ /* Handle out-of-range seconds specially,
+ since ydhms_tm_diff assumes every minute has 60 seconds. */
+ if (sec < 0)
+ sec = 0;
+ if (59 < sec)
+ sec = 59;
+ }
+
+ /* Invert CONVERT by probing. First assume the same offset as last
+ time. */
+
+ INT_SUBTRACT_WRAPV (0, *offset, &negative_offset_guess);
+ t0 = ydhms_diff (year, yday, hour, min, sec,
+ EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, negative_offset_guess);
+
+ /* Repeatedly use the error to improve the guess. */
+
+ for (t = t1 = t2 = t0, dst2 = 0;
+ (gt = guess_time_tm (year, yday, hour, min, sec, t,
+ ranged_convert (convert, &t, &tm)),
+ t != gt);
+ t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
+ if (t == t1 && t != t2
+ && (tm.tm_isdst < 0
+ || (isdst < 0
+ ? dst2 <= (tm.tm_isdst != 0)
+ : (isdst != 0) != (tm.tm_isdst != 0))))
+ /* We can't possibly find a match, as we are oscillating
+ between two values. The requested time probably falls
+ within a spring-forward gap of size GT - T. Follow the common
+ practice in this case, which is to return a time that is GT - T
+ away from the requested time, preferring a time whose
+ tm_isdst differs from the requested value. (If no tm_isdst
+ was requested and only one of the two values has a nonzero
+ tm_isdst, prefer that value.) In practice, this is more
+ useful than returning -1. */
+ goto offset_found;
+ else if (--remaining_probes == 0)
+ return -1;
+
+ /* We have a match. Check whether tm.tm_isdst has the requested
+ value, if any. */
+ if (isdst_differ (isdst, tm.tm_isdst))
+ {
+ /* tm.tm_isdst has the wrong value. Look for a neighboring
+ time with the right value, and use its UTC offset.
+
+ Heuristic: probe the adjacent timestamps in both directions,
+ looking for the desired isdst. This should work for all real
+ time zone histories in the tz database. */
+
+ /* Distance between probes when looking for a DST boundary. In
+ tzdata2003a, the shortest period of DST is 601200 seconds
+ (e.g., America/Recife starting 2000-10-08 01:00), and the
+ shortest period of non-DST surrounded by DST is 694800
+ seconds (Africa/Tunis starting 1943-04-17 01:00). Use the
+ minimum of these two values, so we don't miss these short
+ periods when probing. */
+ int stride = 601200;
+
+ /* The longest period of DST in tzdata2003a is 536454000 seconds
+ (e.g., America/Jujuy starting 1946-10-01 01:00). The longest
+ period of non-DST is much longer, but it makes no real sense
+ to search for more than a year of non-DST, so use the DST
+ max. */
+ int duration_max = 536454000;
+
+ /* Search in both directions, so the maximum distance is half
+ the duration; add the stride to avoid off-by-1 problems. */
+ int delta_bound = duration_max / 2 + stride;
+
+ int delta, direction;
+
+ for (delta = stride; delta < delta_bound; delta += stride)
+ for (direction = -1; direction <= 1; direction += 2)
+ {
+ long_int ot;
+ if (! INT_ADD_WRAPV (t, delta * direction, &ot))
+ {
+ struct tm otm;
+ ranged_convert (convert, &ot, &otm);
+ if (! isdst_differ (isdst, otm.tm_isdst))
+ {
+ /* We found the desired tm_isdst.
+ Extrapolate back to the desired time. */
+ t = guess_time_tm (year, yday, hour, min, sec, ot, &otm);
+ ranged_convert (convert, &t, &tm);
+ goto offset_found;
+ }
+ }
+ }
+ }
+
+ offset_found:
+ /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS.
+ This is just a heuristic to speed up the next mktime call, and
+ correctness is unaffected if integer overflow occurs here. */
+ INT_SUBTRACT_WRAPV (t, t0, &dt);
+ INT_SUBTRACT_WRAPV (dt, negative_offset_guess, offset);
+
+ if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
+ {
+ /* Adjust time to reflect the tm_sec requested, not the normalized value.
+ Also, repair any damage from a false match due to a leap second. */
+ long_int sec_adjustment = sec == 0 && tm.tm_sec == 60;
+ sec_adjustment -= sec;
+ sec_adjustment += sec_requested;
+ if (INT_ADD_WRAPV (t, sec_adjustment, &t)
+ || ! (mktime_min <= t && t <= mktime_max)
+ || ! convert_time (convert, t, &tm))
+ return -1;
+ }
+
+ *tp = tm;
+ return t;
+}
+
+
+static mktime_offset_t localtime_offset;
+
+/* Convert *TP to a time_t value. */
+time_t
+mktime (struct tm *tp)
+{
+#ifdef _LIBC
+ /* POSIX.1 8.1.1 requires that whenever mktime() is called, the
+ time zone names contained in the external variable 'tzname' shall
+ be set as if the tzset() function had been called. */
+ __tzset ();
+#elif HAVE_TZSET
+ tzset ();
+#endif
+
+ return __mktime_internal (tp, __localtime_r, &localtime_offset);
+}
+
+#ifdef weak_alias
+weak_alias (mktime, timelocal)
+#endif
+
+#ifdef _LIBC
+libc_hidden_def (mktime)
+libc_hidden_weak (timelocal)
+#endif
+
+#if DEBUG_MKTIME
+
+static int
+not_equal_tm (const struct tm *a, const struct tm *b)
+{
+ return ((a->tm_sec ^ b->tm_sec)
+ | (a->tm_min ^ b->tm_min)
+ | (a->tm_hour ^ b->tm_hour)
+ | (a->tm_mday ^ b->tm_mday)
+ | (a->tm_mon ^ b->tm_mon)
+ | (a->tm_year ^ b->tm_year)
+ | (a->tm_yday ^ b->tm_yday)
+ | isdst_differ (a->tm_isdst, b->tm_isdst));
+}
+
+static void
+print_tm (const struct tm *tp)
+{
+ if (tp)
+ printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
+ tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
+ tp->tm_hour, tp->tm_min, tp->tm_sec,
+ tp->tm_yday, tp->tm_wday, tp->tm_isdst);
+ else
+ printf ("0");
+}
+
+static int
+check_result (time_t tk, struct tm tmk, time_t tl, const struct tm *lt)
+{
+ if (tk != tl || !lt || not_equal_tm (&tmk, lt))
+ {
+ printf ("mktime (");
+ print_tm (lt);
+ printf (")\nyields (");
+ print_tm (&tmk);
+ printf (") == %ld, should be %ld\n", (long int) tk, (long int) tl);
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ int status = 0;
+ struct tm tm, tmk, tml;
+ struct tm *lt;
+ time_t tk, tl, tl1;
+ char trailer;
+
+ /* Sanity check, plus call tzset. */
+ tl = 0;
+ if (! localtime (&tl))
+ {
+ printf ("localtime (0) fails\n");
+ status = 1;
+ }
+
+ if ((argc == 3 || argc == 4)
+ && (sscanf (argv[1], "%d-%d-%d%c",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
+ == 3)
+ && (sscanf (argv[2], "%d:%d:%d%c",
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
+ == 3))
+ {
+ tm.tm_year -= TM_YEAR_BASE;
+ tm.tm_mon--;
+ tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
+ tmk = tm;
+ tl = mktime (&tmk);
+ lt = localtime_r (&tl, &tml);
+ printf ("mktime returns %ld == ", (long int) tl);
+ print_tm (&tmk);
+ printf ("\n");
+ status = check_result (tl, tmk, tl, lt);
+ }
+ else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0))
+ {
+ time_t from = atol (argv[1]);
+ time_t by = atol (argv[2]);
+ time_t to = atol (argv[3]);
+
+ if (argc == 4)
+ for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
+ {
+ lt = localtime_r (&tl, &tml);
+ if (lt)
+ {
+ tmk = tml;
+ tk = mktime (&tmk);
+ status |= check_result (tk, tmk, tl, &tml);
+ }
+ else
+ {
+ printf ("localtime_r (%ld) yields 0\n", (long int) tl);
+ status = 1;
+ }
+ tl1 = tl + by;
+ if ((tl1 < tl) != (by < 0))
+ break;
+ }
+ else
+ for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
+ {
+ /* Null benchmark. */
+ lt = localtime_r (&tl, &tml);
+ if (lt)
+ {
+ tmk = tml;
+ tk = tl;
+ status |= check_result (tk, tmk, tl, &tml);
+ }
+ else
+ {
+ printf ("localtime_r (%ld) yields 0\n", (long int) tl);
+ status = 1;
+ }
+ tl1 = tl + by;
+ if ((tl1 < tl) != (by < 0))
+ break;
+ }
+ }
+ else
+ printf ("Usage:\
+\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
+\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
+\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
+ argv[0], argv[0], argv[0]);
+
+ return status;
+}
+
+#endif /* DEBUG_MKTIME */
+
+/*
+Local Variables:
+compile-command: "gcc -DDEBUG_MKTIME -I. -Wall -W -O2 -g mktime.c -o mktime"
+End:
+*/
diff --git a/lib/msvc-inval.c b/lib/msvc-inval.c
index 84190d097..32818f7da 100644
--- a/lib/msvc-inval.c
+++ b/lib/msvc-inval.c
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/msvc-inval.h b/lib/msvc-inval.h
index c6df57e93..8147f09ab 100644
--- a/lib/msvc-inval.h
+++ b/lib/msvc-inval.h
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/msvc-nothrow.c b/lib/msvc-nothrow.c
index 9b1eb598e..c8e483b7f 100644
--- a/lib/msvc-nothrow.c
+++ b/lib/msvc-nothrow.c
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/msvc-nothrow.h b/lib/msvc-nothrow.h
index 1917325b3..52dbeb1f2 100644
--- a/lib/msvc-nothrow.h
+++ b/lib/msvc-nothrow.h
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index 3613fb5a5..d14d57bad 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -1,5 +1,5 @@
/* Provide a netdb.h header file for systems lacking it (read: MinGW).
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/netinet_in.in.h b/lib/netinet_in.in.h
index 8ab66a1df..51dc48bfd 100644
--- a/lib/netinet_in.in.h
+++ b/lib/netinet_in.in.h
@@ -1,5 +1,5 @@
/* Substitute for .
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
index 83d2c77af..441e75cd2 100644
--- a/lib/nl_langinfo.c
+++ b/lib/nl_langinfo.c
@@ -1,6 +1,6 @@
/* nl_langinfo() replacement: query locale dependent information.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -20,13 +20,71 @@
/* Specification. */
#include
+#include
+#include
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include
+# include
+#endif
+
+/* Return the codeset of the current locale, if this is easily deducible.
+ Otherwise, return "". */
+static char *
+ctype_codeset (void)
+{
+ static char buf[2 + 10 + 1];
+ char const *locale = setlocale (LC_CTYPE, NULL);
+ char *codeset = buf;
+ size_t codesetlen;
+ codeset[0] = '\0';
+
+ if (locale && locale[0])
+ {
+ /* If the locale name contains an encoding after the dot, return it. */
+ char *dot = strchr (locale, '.');
+
+ if (dot)
+ {
+ /* Look for the possible @... trailer and remove it, if any. */
+ char *codeset_start = dot + 1;
+ char const *modifier = strchr (codeset_start, '@');
+
+ if (! modifier)
+ codeset = codeset_start;
+ else
+ {
+ codesetlen = modifier - codeset_start;
+ if (codesetlen < sizeof buf)
+ {
+ codeset = memcpy (buf, codeset_start, codesetlen);
+ codeset[codesetlen] = '\0';
+ }
+ }
+ }
+ }
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* If setlocale is successful, it returns the number of the
+ codepage, as a string. Otherwise, fall back on Windows API
+ GetACP, which returns the locale's codepage as a number (although
+ this doesn't change according to what the 'setlocale' call specified).
+ Either way, prepend "CP" to make it a valid codeset name. */
+ codesetlen = strlen (codeset);
+ if (0 < codesetlen && codesetlen < sizeof buf - 2)
+ memmove (buf + 2, codeset, codesetlen + 1);
+ else
+ sprintf (buf + 2, "%u", GetACP ());
+ codeset = memcpy (buf, "CP", 2);
+#endif
+ return codeset;
+}
+
+
#if REPLACE_NL_LANGINFO
/* Override nl_langinfo with support for added nl_item values. */
-# include
-# include
-
# undef nl_langinfo
char *
@@ -36,47 +94,18 @@ rpl_nl_langinfo (nl_item item)
{
# if GNULIB_defined_CODESET
case CODESET:
- {
- const char *locale;
- static char buf[2 + 10 + 1];
-
- locale = setlocale (LC_CTYPE, NULL);
- if (locale != NULL && locale[0] != '\0')
- {
- /* If the locale name contains an encoding after the dot, return
- it. */
- const char *dot = strchr (locale, '.');
-
- if (dot != NULL)
- {
- const char *modifier;
-
- dot++;
- /* Look for the possible @... trailer and remove it, if any. */
- modifier = strchr (dot, '@');
- if (modifier == NULL)
- return dot;
- if (modifier - dot < sizeof (buf))
- {
- memcpy (buf, dot, modifier - dot);
- buf [modifier - dot] = '\0';
- return buf;
- }
- }
- }
- return "";
- }
+ return ctype_codeset ();
# endif
# if GNULIB_defined_T_FMT_AMPM
case T_FMT_AMPM:
- return "%I:%M:%S %p";
+ return (char *) "%I:%M:%S %p";
# endif
# if GNULIB_defined_ERA
case ERA:
/* The format is not standardized. In glibc it is a sequence of strings
of the form "direction:offset:start_date:end_date:era_name:era_format"
with an empty string at the end. */
- return "";
+ return (char *) "";
case ERA_D_FMT:
/* The %Ex conversion in strftime behaves like %x if the locale does not
have an alternative time format. */
@@ -95,13 +124,13 @@ rpl_nl_langinfo (nl_item item)
case ALT_DIGITS:
/* The format is not standardized. In glibc it is a sequence of 10
strings, appended in memory. */
- return "\0\0\0\0\0\0\0\0\0\0";
+ return (char *) "\0\0\0\0\0\0\0\0\0\0";
# endif
# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
case YESEXPR:
- return "^[yY]";
+ return (char *) "^[yY]";
case NOEXPR:
- return "^[nN]";
+ return (char *) "^[nN]";
# endif
default:
break;
@@ -111,160 +140,181 @@ rpl_nl_langinfo (nl_item item)
#else
-/* Provide nl_langinfo from scratch. */
+/* Provide nl_langinfo from scratch, either for native MS-Windows, or
+ for old Unix platforms without locales, such as Linux libc5 or
+ BeOS. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-
-/* Native Windows platforms. */
-
-# define WIN32_LEAN_AND_MEAN /* avoid including junk */
-# include
-
-# include
-
-# else
-
-/* An old Unix platform without locales, such as Linux libc5 or BeOS. */
-
-# endif
-
-# include
+# include
char *
nl_langinfo (nl_item item)
{
+ static char nlbuf[100];
+ struct tm tmm = { 0 };
+
switch (item)
{
/* nl_langinfo items of the LC_CTYPE category */
case CODESET:
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
{
- static char buf[2 + 10 + 1];
-
- /* The Windows API has a function returning the locale's codepage as
- a number. */
- sprintf (buf, "CP%u", GetACP ());
- return buf;
+ char *codeset = ctype_codeset ();
+ if (*codeset)
+ return codeset;
}
-# elif defined __BEOS__
- return "UTF-8";
+# ifdef __BEOS__
+ return (char *) "UTF-8";
# else
- return "ISO-8859-1";
+ return (char *) "ISO-8859-1";
# endif
/* nl_langinfo items of the LC_NUMERIC category */
case RADIXCHAR:
return localeconv () ->decimal_point;
case THOUSEP:
return localeconv () ->thousands_sep;
+ case GROUPING:
+ return localeconv () ->grouping;
/* nl_langinfo items of the LC_TIME category.
TODO: Really use the locale. */
case D_T_FMT:
case ERA_D_T_FMT:
- return "%a %b %e %H:%M:%S %Y";
+ return (char *) "%a %b %e %H:%M:%S %Y";
case D_FMT:
case ERA_D_FMT:
- return "%m/%d/%y";
+ return (char *) "%m/%d/%y";
case T_FMT:
case ERA_T_FMT:
- return "%H:%M:%S";
+ return (char *) "%H:%M:%S";
case T_FMT_AMPM:
- return "%I:%M:%S %p";
+ return (char *) "%I:%M:%S %p";
case AM_STR:
- return "AM";
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return (char *) "AM";
+ return nlbuf;
case PM_STR:
- return "PM";
+ tmm.tm_hour = 12;
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return (char *) "PM";
+ return nlbuf;
case DAY_1:
- return "Sunday";
case DAY_2:
- return "Monday";
case DAY_3:
- return "Tuesday";
case DAY_4:
- return "Wednesday";
case DAY_5:
- return "Thursday";
case DAY_6:
- return "Friday";
case DAY_7:
- return "Saturday";
+ {
+ static char const days[][sizeof "Wednesday"] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday"
+ };
+ tmm.tm_wday = item - DAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%A", &tmm))
+ return (char *) days[item - DAY_1];
+ return nlbuf;
+ }
case ABDAY_1:
- return "Sun";
case ABDAY_2:
- return "Mon";
case ABDAY_3:
- return "Tue";
case ABDAY_4:
- return "Wed";
case ABDAY_5:
- return "Thu";
case ABDAY_6:
- return "Fri";
case ABDAY_7:
- return "Sat";
+ {
+ static char const abdays[][sizeof "Sun"] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ tmm.tm_wday = item - ABDAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%a", &tmm))
+ return (char *) abdays[item - ABDAY_1];
+ return nlbuf;
+ }
case MON_1:
- return "January";
case MON_2:
- return "February";
case MON_3:
- return "March";
case MON_4:
- return "April";
case MON_5:
- return "May";
case MON_6:
- return "June";
case MON_7:
- return "July";
case MON_8:
- return "August";
case MON_9:
- return "September";
case MON_10:
- return "October";
case MON_11:
- return "November";
case MON_12:
- return "December";
+ {
+ static char const months[][sizeof "September"] = {
+ "January", "February", "March", "April", "May", "June", "July",
+ "September", "October", "November", "December"
+ };
+ tmm.tm_mon = item - MON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%B", &tmm))
+ return (char *) months[item - MON_1];
+ return nlbuf;
+ }
case ABMON_1:
- return "Jan";
case ABMON_2:
- return "Feb";
case ABMON_3:
- return "Mar";
case ABMON_4:
- return "Apr";
case ABMON_5:
- return "May";
case ABMON_6:
- return "Jun";
case ABMON_7:
- return "Jul";
case ABMON_8:
- return "Aug";
case ABMON_9:
- return "Sep";
case ABMON_10:
- return "Oct";
case ABMON_11:
- return "Nov";
case ABMON_12:
- return "Dec";
+ {
+ static char const abmonths[][sizeof "Jan"] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Sep", "Oct", "Nov", "Dec"
+ };
+ tmm.tm_mon = item - ABMON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%b", &tmm))
+ return (char *) abmonths[item - ABMON_1];
+ return nlbuf;
+ }
case ERA:
- return "";
+ return (char *) "";
case ALT_DIGITS:
- return "\0\0\0\0\0\0\0\0\0\0";
- /* nl_langinfo items of the LC_MONETARY category
- TODO: Really use the locale. */
+ return (char *) "\0\0\0\0\0\0\0\0\0\0";
+ /* nl_langinfo items of the LC_MONETARY category. */
case CRNCYSTR:
- return "-";
+ return localeconv () ->currency_symbol;
+ case INT_CURR_SYMBOL:
+ return localeconv () ->int_curr_symbol;
+ case MON_DECIMAL_POINT:
+ return localeconv () ->mon_decimal_point;
+ case MON_THOUSANDS_SEP:
+ return localeconv () ->mon_thousands_sep;
+ case MON_GROUPING:
+ return localeconv () ->mon_grouping;
+ case POSITIVE_SIGN:
+ return localeconv () ->positive_sign;
+ case NEGATIVE_SIGN:
+ return localeconv () ->negative_sign;
+ case FRAC_DIGITS:
+ return & localeconv () ->frac_digits;
+ case INT_FRAC_DIGITS:
+ return & localeconv () ->int_frac_digits;
+ case P_CS_PRECEDES:
+ return & localeconv () ->p_cs_precedes;
+ case N_CS_PRECEDES:
+ return & localeconv () ->n_cs_precedes;
+ case P_SEP_BY_SPACE:
+ return & localeconv () ->p_sep_by_space;
+ case N_SEP_BY_SPACE:
+ return & localeconv () ->n_sep_by_space;
+ case P_SIGN_POSN:
+ return & localeconv () ->p_sign_posn;
+ case N_SIGN_POSN:
+ return & localeconv () ->n_sign_posn;
/* nl_langinfo items of the LC_MESSAGES category
TODO: Really use the locale. */
case YESEXPR:
- return "^[yY]";
+ return (char *) "^[yY]";
case NOEXPR:
- return "^[nN]";
+ return (char *) "^[nN]";
default:
- return "";
+ return (char *) "";
}
}
diff --git a/lib/nproc.c b/lib/nproc.c
index 293c65169..78e13e3bf 100644
--- a/lib/nproc.c
+++ b/lib/nproc.c
@@ -1,6 +1,6 @@
/* Detect the number of processors.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/nproc.h b/lib/nproc.h
index dbc315707..4f60219d2 100644
--- a/lib/nproc.h
+++ b/lib/nproc.h
@@ -1,6 +1,6 @@
/* Detect the number of processors.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/open.c b/lib/open.c
index f6fd06e4c..4dd5e2be7 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -1,5 +1,5 @@
/* Open a descriptor to a file.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/pathmax.h b/lib/pathmax.h
index 15ed6c28e..0ebce818f 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -1,5 +1,5 @@
/* Define PATH_MAX somehow. Requires sys/types.h.
- Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 Free Software
+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2017 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/pipe.c b/lib/pipe.c
index 03aed5ef9..349a85950 100644
--- a/lib/pipe.c
+++ b/lib/pipe.c
@@ -1,5 +1,5 @@
/* Create a pipe.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/pipe2.c b/lib/pipe2.c
index 4e4e894e7..13e3dcf28 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -1,5 +1,5 @@
/* Create a pipe, with specific opening flags.
- Copyright (C) 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/poll.c b/lib/poll.c
index 7b1e58266..e700ac358 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -1,7 +1,7 @@
/* Emulation for poll(2)
Contributed by Paolo Bonzini.
- Copyright 2001-2003, 2006-2014 Free Software Foundation, Inc.
+ Copyright 2001-2003, 2006-2017 Free Software Foundation, Inc.
This file is part of gnulib.
@@ -33,7 +33,6 @@
#include
#include
-#include
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
# define WINDOWS_NATIVE
@@ -45,11 +44,12 @@
# include "msvc-nothrow.h"
#else
# include
-# include
-# include
# include
#endif
+#include
+#include
+
#ifdef HAVE_SYS_IOCTL_H
# include
#endif
@@ -59,6 +59,8 @@
#include
+#include "assure.h"
+
#ifndef INFTIM
# define INFTIM (-1)
#endif
@@ -70,9 +72,11 @@
#ifdef WINDOWS_NATIVE
-/* Optimized test whether a HANDLE refers to a console.
- See . */
-#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
+static BOOL IsConsoleHandle (HANDLE h)
+{
+ DWORD mode;
+ return GetConsoleMode (h, &mode) != 0;
+}
static BOOL
IsSocketHandle (HANDLE h)
@@ -331,26 +335,15 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
int maxfd, rc;
nfds_t i;
-# ifdef _SC_OPEN_MAX
- static int sc_open_max = -1;
-
- if (nfd < 0
- || (nfd > sc_open_max
- && (sc_open_max != -1
- || nfd > (sc_open_max = sysconf (_SC_OPEN_MAX)))))
+ if (nfd < 0)
{
errno = EINVAL;
return -1;
}
-# else /* !_SC_OPEN_MAX */
-# ifdef OPEN_MAX
- if (nfd < 0 || nfd > OPEN_MAX)
- {
- errno = EINVAL;
- return -1;
- }
-# endif /* OPEN_MAX -- else, no check is needed */
-# endif /* !_SC_OPEN_MAX */
+ /* Don't check directly for NFD too large. Any practical use of a
+ too-large NFD is caught by one of the other checks below, and
+ checking directly for getdtablesize is too much of a portability
+ and/or performance and/or correctness hassle. */
/* EFAULT is not necessary to implement, but let's do it in the
simplest case. */
@@ -391,10 +384,17 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
{
if (pfd[i].fd < 0)
continue;
-
+ if (maxfd < pfd[i].fd)
+ {
+ maxfd = pfd[i].fd;
+ if (FD_SETSIZE <= maxfd)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ }
if (pfd[i].events & (POLLIN | POLLRDNORM))
FD_SET (pfd[i].fd, &rfds);
-
/* see select(2): "the only exceptional condition detectable
is out-of-band data received on a socket", hence we push
POLLWRBAND events onto wfds instead of efds. */
@@ -402,18 +402,6 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
FD_SET (pfd[i].fd, &wfds);
if (pfd[i].events & (POLLPRI | POLLRDBAND))
FD_SET (pfd[i].fd, &efds);
- if (pfd[i].fd >= maxfd
- && (pfd[i].events & (POLLIN | POLLOUT | POLLPRI
- | POLLRDNORM | POLLRDBAND
- | POLLWRNORM | POLLWRBAND)))
- {
- maxfd = pfd[i].fd;
- if (maxfd > FD_SETSIZE)
- {
- errno = EOVERFLOW;
- return -1;
- }
- }
}
/* examine fd sets */
@@ -424,18 +412,13 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
/* establish results */
rc = 0;
for (i = 0; i < nfd; i++)
- if (pfd[i].fd < 0)
- pfd[i].revents = 0;
- else
- {
- int happened = compute_revents (pfd[i].fd, pfd[i].events,
- &rfds, &wfds, &efds);
- if (happened)
- {
- pfd[i].revents = happened;
- rc++;
- }
- }
+ {
+ pfd[i].revents = (pfd[i].fd < 0
+ ? 0
+ : compute_revents (pfd[i].fd, pfd[i].events,
+ &rfds, &wfds, &efds));
+ rc += pfd[i].revents != 0;
+ }
return rc;
#else
@@ -478,7 +461,7 @@ restart:
continue;
h = (HANDLE) _get_osfhandle (pfd[i].fd);
- assert (h != NULL);
+ assure (h != NULL);
if (IsSocketHandle (h))
{
int requested = FD_CLOSE;
diff --git a/lib/poll.in.h b/lib/poll.in.h
index bde98064f..e9b141d8f 100644
--- a/lib/poll.in.h
+++ b/lib/poll.in.h
@@ -1,7 +1,7 @@
/* Header for poll(2) emulation
Contributed by Paolo Bonzini.
- Copyright 2001-2003, 2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright 2001-2003, 2007, 2009-2017 Free Software Foundation, Inc.
This file is part of gnulib.
diff --git a/lib/printf-args.c b/lib/printf-args.c
index 9673e6ddc..42975fa22 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2014 Free Software
+ Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2017 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/printf-args.h b/lib/printf-args.h
index 831c14738..a7df28636 100644
--- a/lib/printf-args.h
+++ b/lib/printf-args.h
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2014 Free Software
+ Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2017 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/printf-parse.c b/lib/printf-parse.c
index e6a09a8de..a3b2c9da1 100644
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2003, 2006-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002-2003, 2006-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/printf-parse.h b/lib/printf-parse.h
index 44d6f5513..571571914 100644
--- a/lib/printf-parse.h
+++ b/lib/printf-parse.h
@@ -1,5 +1,5 @@
/* Parse printf format string.
- Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2014 Free Software
+ Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2017 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/putenv.c b/lib/putenv.c
index de8caa712..ba1cc07dd 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2014 Free Software
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2017 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
diff --git a/lib/raise.c b/lib/raise.c
index 2f04eea9b..223c1528c 100644
--- a/lib/raise.c
+++ b/lib/raise.c
@@ -1,6 +1,6 @@
/* Provide a non-threads replacement for the POSIX raise function.
- Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2006, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/read.c b/lib/read.c
index 4efe8ce23..5385cfd5a 100644
--- a/lib/read.c
+++ b/lib/read.c
@@ -1,5 +1,5 @@
/* POSIX compatible read() function.
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
Written by Bruno Haible , 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/readlink.c b/lib/readlink.c
index ef502f57b..d624fec89 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
/* Stub for readlink().
- Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/recv.c b/lib/recv.c
index fc7e12406..d5b115d3f 100644
--- a/lib/recv.c
+++ b/lib/recv.c
@@ -1,6 +1,6 @@
/* recv.c --- wrappers for Windows recv function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/recvfrom.c b/lib/recvfrom.c
index 0d4fba076..bf4b87310 100644
--- a/lib/recvfrom.c
+++ b/lib/recvfrom.c
@@ -1,6 +1,6 @@
/* recvfrom.c --- wrappers for Windows recvfrom function
- Copyright (C) 2008-2014 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/ref-add.sin b/lib/ref-add.sin
index 9adfb0df0..bfd5b80c8 100644
--- a/lib/ref-add.sin
+++ b/lib/ref-add.sin
@@ -1,6 +1,6 @@
# Add this package to a list of references stored in a text file.
#
-# Copyright (C) 2000, 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2009-2017 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/ref-del.sin b/lib/ref-del.sin
index 45449cbba..f281f21d1 100644
--- a/lib/ref-del.sin
+++ b/lib/ref-del.sin
@@ -1,6 +1,6 @@
# Remove this package from a list of references stored in a text file.
#
-# Copyright (C) 2000, 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2009-2017 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 56faf11c4..9fd4fed99 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa .
@@ -17,6 +17,10 @@
License along with the GNU C Library; if not, see