From fcaedf993699c59a2127c92e331ec7a363c17882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grabm=C3=BCller?= Date: Fri, 16 Mar 2001 17:00:21 +0000 Subject: [PATCH] * scheme-data.texi (Arithmetic): Documented the arithmetic procedures. (Integer Operations): Added documentation. (Comparison): Added documentation. (Complex): Added documentation. (Symbols and Variables): Comment out `builtin-bindings', which is removed according to NEWS. (Pairs): Added documentation. * scheme-io.texi: Added R5RS index entries for all R5RS procedures. (File Ports): New docs for `call-with-input-file', `call-with-output-file', `with-input-from-file', `with-output-to-file', `with-error-to-file'. * scheme-control.texi, scheme-utility.texi, * scheme-procedures.texi: Added R5RS index entries for all R5RS procedures. * scheme-evaluation.texi (Fly Evaluation): Added documentation for `apply'. Added R5RS index entries for all R5RS procedures. * scheme-data.texi: Added R5RS index entries for all R5RS procedures. Removed R5RS index entries for `ass{q,v,occ}-set!'. Removed explicit entries into the function entries. They are automagic. (Vectors): Added documentation for `make-vector', `vector-ref' and `vector-set!'. --- doc/ChangeLog | 31 +++++ doc/scheme-control.texi | 7 + doc/scheme-data.texi | 276 +++++++++++++++++++++++++++++++------ doc/scheme-evaluation.texi | 20 +++ doc/scheme-io.texi | 83 +++++++++++ doc/scheme-procedures.texi | 1 + doc/scheme-utility.texi | 3 + 7 files changed, 382 insertions(+), 39 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index b377533dd..64761ee80 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,34 @@ +2001-03-16 Martin Grabmueller + + * scheme-data.texi (Arithmetic): Documented the arithmetic + procedures. + (Integer Operations): Added documentation. + (Comparison): Added documentation. + (Complex): Added documentation. + (Symbols and Variables): Comment out `builtin-bindings', which is + removed according to NEWS. + (Pairs): Added documentation. + + * scheme-io.texi: Added R5RS index entries for all R5RS + procedures. + (File Ports): New docs for `call-with-input-file', + `call-with-output-file', `with-input-from-file', + `with-output-to-file', `with-error-to-file'. + + * scheme-control.texi, scheme-utility.texi, + * scheme-procedures.texi: Added R5RS index entries for all R5RS + procedures. + + * scheme-evaluation.texi (Fly Evaluation): Added documentation for + `apply'. Added R5RS index entries for all R5RS procedures. + + * scheme-data.texi: Added R5RS index entries for all R5RS + procedures. Removed R5RS index entries for `ass{q,v,occ}-set!'. + Removed explicit entries into the function entries. They are + automagic. + (Vectors): Added documentation for `make-vector', `vector-ref' and + `vector-set!'. + 2001-03-12 Marius Vollmer * intro.texi: Changed to reflect current practice better. Added diff --git a/doc/scheme-control.texi b/doc/scheme-control.texi index cd3cbc1bd..5098fe4cd 100644 --- a/doc/scheme-control.texi +++ b/doc/scheme-control.texi @@ -34,10 +34,15 @@ @node Continuations @section Continuations +@r5index call-with-current-continuation +@c FIXME::martin: Document me! +@deffn primitive call-with-current-continuation +@end deffn @node Multiple Values @section Returning and Accepting Multiple Values +@r5index values @deffn primitive values . args Delivers all of its arguments to its continuation. Except for continuations created by the @code{call-with-values} procedure, @@ -46,6 +51,7 @@ passing no value or more than one value to continuations that were not created by @code{call-with-values} is unspecified. @end deffn +@r5index call-with-values @deffn primitive call-with-values producer consumer Calls its @var{producer} argument with no values and a continuation that, when passed some values, calls the @@ -174,6 +180,7 @@ if an exception occurs then @code{#f} is returned instead. [FIXME: this is pasted in from Tom Lord's original guile.texi and should be reviewed] +@r5index dynamic-wind @c ARGFIXME in-guard/thunk1 thunk/thunk2 out-guard/thunk3 @c docstring begin (texi-doc-string "guile" "dynamic-wind") @deffn primitive dynamic-wind thunk1 thunk2 thunk3 diff --git a/doc/scheme-data.texi b/doc/scheme-data.texi index 0d5ea363c..c69a5431c 100755 --- a/doc/scheme-data.texi +++ b/doc/scheme-data.texi @@ -63,6 +63,8 @@ sections of this manual that cover them. @node Booleans @section Booleans +@r5index not +@r5index boolean? The two boolean values are @code{#t} for true and @code{#f} for false. @@ -167,6 +169,7 @@ in Scheme, which is particularly clear and accessible: see @node Numerical Tower @subsection Scheme's Numerical ``Tower'' +@r5index number? Scheme's numerical ``tower'' consists of the following categories of numbers: @@ -229,6 +232,7 @@ in detail. @node Integers @subsection Integers +@r5index integer? Integers are whole numbers, that is numbers with no fractional part, such as 2, 83 and -3789. @@ -287,6 +291,8 @@ Return @code{#t} if @var{obj} is an integer number, @code{#f} else. @node Reals and Rationals @subsection Real and Rational Numbers +@r5index real? +@r5index rational? Mathematically, the real numbers are the set of numbers that describe all possible points along a continuous, infinite, one-dimensional line. @@ -347,6 +353,7 @@ is an integer number. @node Complex Numbers @subsection Complex Numbers +@r5index complex? Complex numbers are the set of numbers that describe all possible points in a two-dimensional space. The two coordinates of a particular point @@ -382,6 +389,10 @@ the set of complex numbers, so the predicate will also be fulfilled if @node Exactness @subsection Exact and Inexact Numbers +@r5index exact? +@r5index inexact? +@r5index exact->inexact +@r5index inexact->exact R5RS requires that a calculation involving inexact numbers always produces an inexact result. To meet this requirement, Guile @@ -403,11 +414,12 @@ Return #t if X is an inexact number, #f else. @c docstring begin (texi-doc-string "guile" "inexact->exact") @deffn primitive inexact->exact z -Returns an exact number that is numerically closest to Z. +Returns an exact number that is numerically closest to @var{z}. @end deffn @c begin (texi-doc-string "guile" "exact->inexact") -@deffn primitive exact->inexact +@deffn primitive exact->inexact z +Convert the number @var{z} to its inexact representation. @end deffn @@ -480,6 +492,13 @@ multiplying by 10^N. @node Integer Operations @subsection Operations on Integer Values +@r5index odd? +@r5index even? +@r5index quotient +@r5index remainder +@r5index modulo +@r5index gcd +@r5index lcm @c docstring begin (texi-doc-string "guile" "odd?") @deffn primitive odd? n @@ -493,63 +512,98 @@ Return #t if N is an even number, #f otherwise. @c begin (texi-doc-string "guile" "quotient") @deffn primitive quotient +Return the quotient of the numbers @var{x} and @var{y}. @end deffn @c begin (texi-doc-string "guile" "remainder") @deffn primitive remainder +Return the remainder of the numbers @var{x} and @var{y}. +@lisp +(remainder 13 4) @result{} 1 +(remainder -13 4) @result{} -1 +@end lisp @end deffn @c begin (texi-doc-string "guile" "modulo") @deffn primitive modulo +Return the modulo of the numbers @var{x} and @var{y}. +@lisp +(modulo 13 4) @result{} 1 +(modulo -13 4) @result{} 3 +@end lisp @end deffn @c begin (texi-doc-string "guile" "gcd") @deffn primitive gcd +Return the greatest common divisor of all arguments. +If called without arguments, 0 is returned. @end deffn @c begin (texi-doc-string "guile" "lcm") @deffn primitive lcm +Return the least common multiple of the arguments. +If called without arguments, 1 is returned. @end deffn @node Comparison @subsection Comparison Predicates +@r5index zero? +@r5index positive? +@r5index negative? @c begin (texi-doc-string "guile" "=") @deffn primitive = +Return @code{#t} if all parameters are numerically equal. @end deffn @c begin (texi-doc-string "guile" "<") @deffn primitive < +Return @code{#t} if the list of parameters is monotonically +increasing. @end deffn @c begin (texi-doc-string "guile" ">") @deffn primitive > +Return @code{#t} if the list of parameters is monotonically +decreasing. @end deffn @c begin (texi-doc-string "guile" "<=") @deffn primitive <= +Return @code{#t} if the list of parameters is monotonically +non-decreasing. @end deffn @c begin (texi-doc-string "guile" ">=") @deffn primitive >= +Return @code{#t} if the list of parameters is monotonically +non-increasing. @end deffn @c begin (texi-doc-string "guile" "zero?") @deffn primitive zero? +Return @code{#t} if @var{z} is an exact or inexact number equal to +zero. @end deffn @c begin (texi-doc-string "guile" "positive?") @deffn primitive positive? +Return @code{#t} if @var{x} is an exact or inexact number greater than +zero. @end deffn @c begin (texi-doc-string "guile" "negative?") @deffn primitive negative? +Return @code{#t} if @var{x} is an exact or inexact number less than +zero. @end deffn @node Conversion @subsection Converting Numbers To and From Strings +@r5index number->string +@r5index string->number @c docstring begin (texi-doc-string "guile" "number->string") @deffn primitive number->string n [radix] @@ -572,6 +626,12 @@ for a number, then `string->number' returns #f. (r5rs) @node Complex @subsection Complex Number Operations +@r5index make-rectangular +@r5index make-polar +@r5index real-part +@r5index imag-part +@r5index magnitude +@r5index angle @c docstring begin (texi-doc-string "guile" "make-rectangular") @deffn primitive make-rectangular real imaginary @@ -586,71 +646,111 @@ Return the complex number X * e^(i * Y). @c begin (texi-doc-string "guile" "real-part") @deffn primitive real-part +Return the real part of the number @var{z}. @end deffn @c begin (texi-doc-string "guile" "imag-part") @deffn primitive imag-part +Return the imaginary part of the number @var{z}. @end deffn @c begin (texi-doc-string "guile" "magnitude") @deffn primitive magnitude +Return the magnitude of the number @var{z}. This is the same as +@code{abs} for real arguments, but also allows complex numbers. @end deffn @c begin (texi-doc-string "guile" "angle") @deffn primitive angle +Return the angle of the complex number @var{z}. @end deffn @node Arithmetic @subsection Arithmetic Functions +@r5index max +@r5index min +@r5index + +@r5index * +@r5index - +@r5index / +@r5index abs +@r5index floor +@r5index ceiling +@r5index truncate +@r5index round @c begin (texi-doc-string "guile" "+") -@deffn primitive + +@deffn primitive + z1 @dots{} +Return the sum of all parameter values. Return 0 if called without any +parameters. @end deffn @c begin (texi-doc-string "guile" "-") -@deffn primitive - +@deffn primitive - z1 z2 @dots{} +If called without arguments, 0 is returned. Otherwise the sum of all but +the first argument are subtracted from the first argument. @end deffn @c begin (texi-doc-string "guile" "*") -@deffn primitive * +@deffn primitive * z1 @dots{} +Return the product of all arguments. If called without arguments, 1 is +returned. @end deffn @c begin (texi-doc-string "guile" "/") -@deffn primitive / +@deffn primitive / z1 z2 @dots{} +Divide the first argument by the product of the remaining arguments. @end deffn @c begin (texi-doc-string "guile" "abs") -@deffn primitive abs +@deffn primitive abs x +Return the absolute value of @var{x}. @end deffn @c begin (texi-doc-string "guile" "max") -@deffn primitive max +@deffn primitive max x1 x2 @dots{} +Return the maximum of all parameter values. @end deffn @c begin (texi-doc-string "guile" "min") -@deffn primitive min +@deffn primitive min x1 x2 @dots{} +Return the minium of all parameter values. @end deffn @c begin (texi-doc-string "guile" "truncate") @deffn primitive truncate +Round the inexact number @var{x} towards zero. @end deffn @c begin (texi-doc-string "guile" "round") -@deffn primitive round +@deffn primitive round x +Round the inexact number @var{x} towards zero. @end deffn @c begin (texi-doc-string "guile" "floor") -@deffn primitive floor +@deffn primitive floor x +Round the number @var{x} towards minus infinity. @end deffn @c begin (texi-doc-string "guile" "ceiling") -@deffn primitive ceiling +@deffn primitive ceiling x +Round the number @var{x} towards infinity. @end deffn @node Scientific @subsection Scientific Functions +@r5index exp +@r5index log +@r5index sin +@r5index cos +@r5index tan +@r5index asin +@r5index acos +@r5index atan +@r5index sqrt +@r5index expt The following procedures accept any kind of number as arguments, including complex numbers. @@ -1083,6 +1183,22 @@ Return a new random state using @var{seed}. @node Characters @section Characters +@r5index char? +@r5index char=? +@r5index char? +@r5index char<=? +@r5index char>=? +@r5index char-alphabetic? +@r5index char-numeric? +@r5index char-whitespace? +@r5index char-upper-case? +@r5index char-lower-case? +@r5index char->integer +@r5index integer->char +@r5index char-upcase +@r5index char-downcase + Most of the characters in the ASCII character set may be referred to by name: for example, @code{#\tab}, @code{#\esc}, @code{#\stx}, and so on. @@ -1290,6 +1406,8 @@ eventually, and it will be helpful to know how they work. @node String Fun @subsection String Fun +@r5index string +@r5index list->string @c docstring begin (texi-doc-string "guile" "string") @c docstring begin (texi-doc-string "guile" "list->string") @deffn primitive string . chrs @@ -1298,6 +1416,7 @@ Returns a newly allocated string composed of the arguments, @var{chrs}. @end deffn +@r5index make-string @c docstring begin (texi-doc-string "guile" "make-string") @deffn primitive make-string k [chr] Return a newly allocated string of @@ -1306,23 +1425,27 @@ the string are initialized to @var{chr}, otherwise the contents of the @var{string} are unspecified. @end deffn +@r5index string-append @c docstring begin (texi-doc-string "guile" "string-append") @deffn primitive string-append . args Return a newly allocated string whose characters form the concatenation of the given strings, @var{args}. @end deffn +@r5index string-length @c docstring begin (texi-doc-string "guile" "string-length") @deffn primitive string-length string Return the number of characters in @var{string}. @end deffn +@r5index string-ref @c docstring begin (texi-doc-string "guile" "string-ref") @deffn primitive 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 +@r5index string-set! @c docstring begin (texi-doc-string "guile" "string-set!") @deffn primitive string-set! str k chr Store @var{chr} in element @var{k} of @var{str} and return @@ -1330,12 +1453,14 @@ an unspecified value. @var{k} must be a valid index of @var{str}. @end deffn +@r5index string? @c docstring begin (texi-doc-string "guile" "string?") @deffn primitive string? obj Returns @code{#t} iff @var{obj} is a string, else returns @code{#f}. @end deffn +@r5index substring @c docstring begin (texi-doc-string "guile" "substring") @deffn primitive substring str start [end] Return a newly allocated string formed from the characters @@ -1566,6 +1691,7 @@ Destructively capitalize every character in @code{str}. Capitalize every character in @code{str}. @end deffn +@r5index string<=? @c docstring begin (texi-doc-string "guile" "string-ci<=?") @deffn primitive string-ci<=? s1 s2 Case insensitive lexicographic ordering predicate; @@ -1573,6 +1699,7 @@ returns @t{#t} if @var{s1} is lexicographically less than or equal to @var{s2} regardless of case. (r5rs) @end deffn +@r5index string-ci< @c docstring begin (texi-doc-string "guile" "string-ci=? @c docstring begin (texi-doc-string "guile" "string-ci>=?") @deffn primitive string-ci>=? s1 s2 Case insensitive lexicographic ordering predicate; @@ -1594,6 +1723,7 @@ returns @t{#t} if @var{s1} is lexicographically greater than or equal to @var{s2} regardless of case. (r5rs) @end deffn +@r5index string-ci>? @c docstring begin (texi-doc-string "guile" "string-ci>?") @deffn primitive string-ci>? s1 s2 Case insensitive lexicographic ordering predicate; @@ -1601,18 +1731,21 @@ returns @t{#t} if @var{s1} is lexicographically greater than @var{s2} regardless of case. (r5rs) @end deffn +@r5index string<=? @c docstring begin (texi-doc-string "guile" "string<=?") @deffn primitive string<=? s1 s2 Lexicographic ordering predicate; returns @t{#t} if @var{s1} is lexicographically less than or equal to @var{s2}. (r5rs) @end deffn +@r5index string=? @c docstring begin (texi-doc-string "guile" "string>=?") @deffn primitive string>=? s1 s2 Lexicographic ordering predicate; returns @t{#t} if @var{s1} is lexicographically greater than or equal to @var{s2}. (r5rs) @end deffn +@r5index string>? @c docstring begin (texi-doc-string "guile" "string>?") @deffn primitive string>? s1 s2 Lexicographic ordering predicate; returns @t{#t} if @var{s1} is lexicographically greater than @var{s2}. (r5rs) @end deffn +@r5index string->list @c docstring begin (texi-doc-string "guile" "string->list") @deffn primitive string->list str @samp{String->list} returns a newly allocated list of the @@ -1651,11 +1787,13 @@ inverses so far as @samp{equal?} is concerned. (r5rs) Return the symbol whose name is @var{str}, downcased in necessary(???). @end deffn +@r5index string-copy @c docstring begin (texi-doc-string "guile" "string-copy") @deffn primitive string-copy str Returns a newly allocated copy of the given @var{string}. (r5rs) @end deffn +@r5index string-fill! @c docstring begin (texi-doc-string "guile" "string-fill!") @deffn primitive string-fill! str chr Stores @var{char} in every element of the given @var{string} and returns an @@ -2244,6 +2382,10 @@ Test whether obj is a compiled regular expression. @node Symbols and Variables @section Symbols and Variables +@r5index symbol? +@r5index symbol->string +@r5index string->symbol + Guile symbol tables are hash tables. Each hash table, also called an @dfn{obarray} (for `object array'), is a vector of association lists. @@ -2252,11 +2394,13 @@ Each entry in the alists is a pair (@var{SYMBOL} . @var{VALUE}). To (@var{SYMBOL} . @var{VALUE}) pair, adding a new entry to the symbol table (with an undefined value) if none is yet present. -@c docstring begin (texi-doc-string "guile" "builtin-bindings") -@deffn primitive builtin-bindings -Create and return a copy of the global symbol table, removing all -unbound symbols. -@end deffn +@c FIXME::martin: According to NEWS, removed. Remove here too, or +@c leave for compatibility? +@c @c docstring begin (texi-doc-string "guile" "builtin-bindings") +@c @deffn primitive builtin-bindings +@c Create and return a copy of the global symbol table, removing all +@c unbound symbols. +@c @end deffn @c docstring begin (texi-doc-string "guile" "gensym") @deffn primitive gensym [prefix] @@ -2695,6 +2839,10 @@ This is the inverse of @code{make-keyword-from-dash-symbol}. @node Pairs @section Pairs +@r5index pair? +@r5index cons +@r5index set-car! +@r5index set-cdr! @c docstring begin (texi-doc-string "guile" "cons") @deffn primitive cons x y @@ -2708,6 +2856,25 @@ Returns a newly allocated pair whose car is @var{x} and whose cdr is Returns @code{#t} if @var{x} is a pair; otherwise returns @code{#f}. @end deffn +@r5index car +@r5index cdr +@deffn primitive car pair +@deffnx primitive cdr pair +Return the car or the cdr of @var{pair}, respectively. +@end deffn + +@deffn primitive caar pair +@deffnx primitive cadr pair @dots{} +@deffnx primitive cdddar pair +@deffnx primitive cddddr 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 +@end deffn + @c docstring begin (texi-doc-string "guile" "set-car!") @deffn primitive set-car! pair value Stores @var{value} in the car field of @var{pair}. The value returned @@ -2723,6 +2890,18 @@ by @code{set-cdr!} is unspecified. @node Lists @section Lists +@r5index null? +@r5index list? +@r5index list +@r5index length +@r5index append +@r5index reverse +@r5index list-tail +@r5index list-ref +@r5index memq +@r5index memv +@r5index member + @c docstring begin (texi-doc-string "guile" "list") @deffn primitive list . objs @@ -2958,12 +3137,14 @@ Its use is recommended only in writing Guile internals, not for high-level Scheme programs. @end deffn +@r5index map @c begin (texi-doc-string "guile" "map") @c docstring begin (texi-doc-string "guile" "map-in-order") @deffn primitive map proc arg1 . args @deffnx primitive map-in-order proc arg1 . args @end deffn +@r5index for-each @c begin (texi-doc-string "guile" "for-each") @deffn primitive for-each proc arg1 . args @end deffn @@ -3990,13 +4171,6 @@ lists which do not require their entries' keys to be unique. @node Adding or Setting Alist Entries @subsubsection Adding or Setting Alist Entries -@findex acons -@findex assq-set! -@findex assv-set! -@findex assoc-set! -@r5index assq-set! -@r5index assv-set! -@r5index assoc-set! @code{acons} adds a new entry to an association list and returns the combined association list. The combined alist is formed by consing the @@ -4124,18 +4298,9 @@ association list. @node Retrieving Alist Entries @subsubsection Retrieving Alist Entries -@findex assq -@findex assv -@findex assoc -@findex assq-ref -@findex assv-ref -@findex assoc-ref @r5index assq @r5index assv @r5index assoc -@r5index assq-ref -@r5index assv-ref -@r5index assoc-ref @code{assq}, @code{assv} and @code{assoc} take an alist and a key as arguments and return the entry for that key if an entry exists, or @@ -4190,9 +4355,6 @@ where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}. @node Removing Alist Entries @subsubsection Removing Alist Entries -@findex assq-remove! -@findex assv-remove! -@findex assoc-remove! To remove the element from an association list whose key matches a specified key, use @code{assq-remove!}, @code{assv-remove!} or @@ -4261,9 +4423,6 @@ the resulting alist. @node Sloppy Alist Functions @subsubsection Sloppy Alist Functions -@findex sloppy-assq -@findex sloppy-assv -@findex sloppy-assoc @code{sloppy-assq}, @code{sloppy-assv} and @code{sloppy-assoc} behave like the corresponding non-@code{sloppy-} procedures, except that they @@ -4611,6 +4770,7 @@ table into an a-list of key-value pairs. @node Vectors @section Vectors +@r5index make-vector @c docstring begin (texi-doc-string "guile" "make-vector") @deffn primitive make-vector k [fill] Returns a newly allocated vector of @var{k} elements. If a second @@ -4618,6 +4778,8 @@ argument is given, then each element is initialized to @var{fill}. Otherwise the initial contents of each element is unspecified. (r5rs) @end deffn +@r5index vector +@r5index list->vector @c docstring begin (texi-doc-string "guile" "vector") @c docstring begin (texi-doc-string "guile" "list->vector") @deffn primitive vector . l @@ -4630,6 +4792,7 @@ arguments. Analogous to @samp{list}. (r5rs) @end format @end deffn +@r5index vector->list @c docstring begin (texi-doc-string "guile" "vector->list") @deffn primitive vector->list v @samp{Vector->list} returns a newly allocated list of the objects contained @@ -4644,17 +4807,52 @@ list->vector '(dididit dah)) @end format @end deffn +@r5index vector-fill! +@c FIXME::martin: Argument names @c docstring begin (texi-doc-string "guile" "vector-fill!") @deffn primitive vector-fill! v fill_x Stores @var{fill} in every element of @var{vector}. The value returned by @samp{vector-fill!} is unspecified. (r5rs) @end deffn +@r5index vector? @c docstring begin (texi-doc-string "guile" "vector?") @deffn primitive vector? obj Returns @t{#t} if @var{obj} is a vector, otherwise returns @t{#f}. (r5rs) @end deffn +@r5index vector-length +@deffn primitive vector-length vector +Returns the number of elements in @var{vector} as an exact integer. +@end deffn + +@r5index vector-ref +@deffn primitive vector-ref vector k +@var{k} must be a valid index of @var{vector}. +@samp{Vector-ref} returns the contents of element @var{k} of +@var{vector}. +@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 + +@r5index vector-set! +@deffn primitive vector-set! vector k obj +@var{k} must be a valid index of @var{vector}. +@code{Vector-set!} stores @var{obj} in element @var{k} of @var{vector}. +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") +(vector-set! '#(0 1 2) 1 "doe") @result{} @emph{error} ; constant vector +@end lisp +@end deffn @node Hooks @section Hooks diff --git a/doc/scheme-evaluation.texi b/doc/scheme-evaluation.texi index 95c4910f8..31e99ad7a 100644 --- a/doc/scheme-evaluation.texi +++ b/doc/scheme-evaluation.texi @@ -72,6 +72,7 @@ this procedure directly, use the procedures @code{read-enable}, @code{read-disable}, @code{read-set!} and @var{read-options}. @end deffn +@r5index read @c docstring begin (texi-doc-string "guile" "read") @deffn primitive read [port] Read an s-expression from the input port @var{port}, or from @@ -83,6 +84,7 @@ Any whitespace before the next token is discarded. @node Fly Evaluation @section Procedures for On the Fly Evaluation +@r5index eval @c ARGFIXME environment/environment specifier @c docstring begin (texi-doc-string "guile" "eval") @deffn primitive eval exp environment @@ -90,6 +92,7 @@ Evaluate @var{exp}, a list representing a Scheme expression, in the environment given by @var{environment specifier}. @end deffn +@r5index interaction-environment @c docstring begin (texi-doc-string "guile" "interaction-environment") @deffn primitive interaction-environment This procedure returns a specifier for the environment that contains @@ -117,6 +120,13 @@ Note: Rather than do new consing, @code{apply:nconc2last} destroys its argument, so use with care. @end deffn +@r5index apply +@deffn primitive apply proc arg1 @dots{} args +@var{proc} must be a procedure and @var{args} must be a list. Call +@var{proc} with the elements of the list @code{(append (list @var{arg1} +@dots{}) @var{args})} as the actual arguments. +@end deffn + @deffn primitive primitive-eval exp Evaluate @var{exp} in the top-level environment specified by the current module. @@ -141,6 +151,15 @@ signalled. @node Loading @section Loading Scheme Code from File +@r5index load +@deffn procedure load filename +Load @var{file} and evaluate its contents in the top-level environment. +The load paths are searched. 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 documentation for @code{%load-hook} later in +this section. +@end deffn + @c ARGFIXME file/filename @c docstring begin (texi-doc-string "guile" "primitive-load") @deffn primitive primitive-load filename @@ -213,6 +232,7 @@ Return true if @var{obj} is a promise, i.e. a delayed computation (@pxref{Delayed evaluation,,,r4rs.info,The Revised^4 Report on Scheme}). @end deffn +@r5index force @c docstring begin (texi-doc-string "guile" "force") @deffn primitive force x If the promise X has not been computed yet, compute and return diff --git a/doc/scheme-io.texi b/doc/scheme-io.texi index a3de2f1a8..a98e96eb7 100644 --- a/doc/scheme-io.texi +++ b/doc/scheme-io.texi @@ -32,6 +32,7 @@ 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. +@r5index input-port? @c docstring begin (texi-doc-string "guile" "input-port?") @deffn primitive input-port? x Returns @code{#t} if @var{x} is an input port, otherwise returns @@ -39,6 +40,7 @@ Returns @code{#t} if @var{x} is an input port, otherwise returns @code{port?}. @end deffn +@r5index output-port? @c docstring begin (texi-doc-string "guile" "output-port?") @deffn primitive output-port? x Returns @code{#t} if @var{x} is an output port, otherwise returns @@ -58,12 +60,14 @@ Equivalent to @code{(or (input-port? X) (output-port? X))}. [Generic procedures for reading from ports.] +@r5index eof-object? @c docstring begin (texi-doc-string "guile" "eof-object?") @deffn primitive eof-object? x Returns @code{#t} if @var{x} is an end-of-file object; otherwise returns @code{#f}. @end deffn +@r5index char-ready? @c docstring begin (texi-doc-string "guile" "char-ready?") @deffn primitive char-ready? [port] Returns @code{#t} if a character is ready on input @var{port} and @@ -81,6 +85,7 @@ indistinguishable from an interactive port that has no ready characters.} @end deffn +@r5index read-char? @c docstring begin (texi-doc-string "guile" "read-char") @deffn primitive read-char [port] Returns the next character available from @var{port}, updating @@ -88,6 +93,7 @@ Returns the next character available from @var{port}, updating characters are available, an end-of-file object is returned. @end deffn +@r5index peek-char? @c docstring begin (texi-doc-string "guile" "peek-char") @deffn primitive peek-char [port] Returns the next character available from @var{port}, @@ -195,6 +201,7 @@ Return the print state of the port @var{port}. If @var{port} has no associated print state, @code{#f} is returned. @end deffn +@r5index newline @c docstring begin (texi-doc-string "guile" "newline") @deffn primitive newline [port] Send a newline to @var{port}. @@ -228,6 +235,7 @@ port, if @var{destination} is @code{#f}, then return a string containing the formatted text. Does not add a trailing newline. @end deffn +@r5index write-char @c docstring begin (texi-doc-string "guile" "write-char") @deffn primitive write-char chr [port] Send character @var{chr} to @var{port}. @@ -265,6 +273,7 @@ See also @ref{Ports and File Descriptors, close}, for a procedure which can close file descriptors. @end deffn +@r5index close-input-port @c docstring begin (texi-doc-string "guile" "close-input-port") @deffn primitive close-input-port port Close the specified input port object. The routine has no effect if @@ -275,6 +284,7 @@ See also @ref{Ports and File Descriptors, close}, for a procedure which can close file descriptors. @end deffn +@r5index close-output-port @c docstring begin (texi-doc-string "guile" "close-output-port") @deffn primitive close-output-port port Close the specified output port object. The routine has no effect if @@ -492,6 +502,7 @@ If omitted, @var{port} defaults to the current output port. @node Default Ports @section Default Ports for Input, Output and Errors +@r5index current-input-port @c docstring begin (texi-doc-string "guile" "current-input-port") @deffn primitive current-input-port Return the current input port. This is the default port used @@ -499,6 +510,7 @@ by many input procedures. Initially, @code{current-input-port} returns the @dfn{standard input} in Unix and C terminology. @end deffn +@r5index current-output-port @c docstring begin (texi-doc-string "guile" "current-output-port") @deffn primitive current-output-port Return the current output port. This is the default port used @@ -600,6 +612,7 @@ If a file cannot be opened with the access requested, @code{open-file} throws an exception. @end deffn +@r5index open-input-file @c begin (scm-doc-string "r4rs.scm" "open-input-file") @deffn procedure open-input-file filename Open @var{filename} for input. Equivalent to @@ -608,6 +621,7 @@ Open @var{filename} for input. Equivalent to @end smalllisp @end deffn +@r5index open-output-file @c begin (scm-doc-string "r4rs.scm" "open-output-file") @deffn procedure open-output-file filename Open @var{filename} for output. Equivalent to @@ -616,6 +630,75 @@ Open @var{filename} for output. Equivalent to @end smalllisp @end deffn +@r5index call-with-input-file +@c begin (scm-doc-string "r4rs.scm" "call-with-input-file") +@deffn procedure call-with-input-file file proc +@var{proc} should be a procedure of one argument, and @var{file} should +be a string naming a file. The file must already exist. These +procedures call @var{proc} with one argument: the port obtained by +opening the named file for input or output. If the file cannot be +opened, an error is signalled. If the procedure returns, then the port +is closed automatically and the value yielded by the procedure is +returned. If the procedure does not return, then the port will not be +closed automatically unless it is possible to prove that the port will +never again be used for a read or write operation. +@end deffn + +@r5index call-with-output-file +@c begin (scm-doc-string "r4rs.scm" "call-with-output-file") +@deffn procedure call-with-output-file file proc +@var{proc} should be a procedure of one argument, and @var{file} should +be a string naming a file. The behaviour is unspecified if the file +already exists. These procedures call @var{proc} with one argument: the +port obtained by opening the named file for input or output. If the +file cannot be opened, an error is signalled. If the procedure returns, +then the port is closed automatically and the value yielded by the +procedure is returned. If the procedure does not return, then the port +will not be closed automatically unless it is possible to prove that the +port will never again be used for a read or write operation. +@end deffn + +@r5index with-input-from-file +@c begin (scm-doc-string "r4rs.scm" "with-input-from-file") +@deffn procedure with-input-from-file file thunk +@var{thunk} must be a procedure of no arguments, and @var{file} must be +a string naming a file. The file must already exist. The file is opened +for input, an input port connected to it is made the default value +returned by @code{current-input-port}, and the @var{thunk} is called +with no arguments. When the @var{thunk} returns, the port is closed and +the previous default is restored. Returns the value yielded by +@var{thunk}. If an escape procedure is used to escape from the +continuation of these procedures, their behavior is implementation +dependent. +@end deffn + +@r5index with-output-to-file +@c begin (scm-doc-string "r4rs.scm" "with-output-to-file") +@deffn procedure with-output-to-file file thunk +@var{thunk} must be a procedure of no arguments, and @var{file} must be +a string naming a file. The effect is unspecified if the file already +exists. The file is opened for output, an output port connected to it +is made the default value returned by @code{current-output-port}, and +the @var{thunk} is called with no arguments. When the @var{thunk} +returns, the port is closed and the previous default is restored. +Returns the value yielded by @var{thunk}. If an escape procedure is +used to escape from the continuation of these procedures, their behavior +is implementation dependent. +@end deffn + +@c begin (scm-doc-string "r4rs.scm" "with-error-to-file") +@deffn procedure with-error-to-file file thunk +@var{thunk} must be a procedure of no arguments, and @var{file} must be +a string naming a file. The effect is unspecified if the file already +exists. The file is opened for output, an output port connected to it +is made the default value returned by @code{current-error-port}, and the +@var{thunk} is called with no arguments. When the @var{thunk} returns, +the port is closed and the previous default is restored. Returns the +value yielded by @var{thunk}. If an escape procedure is used to escape +from the continuation of these procedures, their behavior is +implementation dependent. +@end deffn + @c docstring begin (texi-doc-string "guile" "port-mode") @deffn primitive port-mode port Returns the port modes associated with the open port @var{port}. These diff --git a/doc/scheme-procedures.texi b/doc/scheme-procedures.texi index 64ba417e6..38ef59256 100644 --- a/doc/scheme-procedures.texi +++ b/doc/scheme-procedures.texi @@ -56,6 +56,7 @@ documentation for that procedure. Return @code{#t} if @var{obj} is a closure. @end deffn +@r5index procedure? @c docstring begin (texi-doc-string "guile" "procedure?") @deffn primitive procedure? obj Return @code{#t} if @var{obj} is a procedure. diff --git a/doc/scheme-utility.texi b/doc/scheme-utility.texi index c57a63aac..2bf1dfd0d 100644 --- a/doc/scheme-utility.texi +++ b/doc/scheme-utility.texi @@ -13,6 +13,9 @@ @node Equality @section Equality +@r5index eq? +@r5index eqv? +@r5index equal? @c docstring begin (texi-doc-string "guile" "eq?") @deffn primitive eq? x y