From bd9733926076885e3417b74de76e4c9c7bc56254 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:28 -0800 Subject: Import Upstream version 2c7 --- slib.texi | 1154 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 561 insertions(+), 593 deletions(-) (limited to 'slib.texi') diff --git a/slib.texi b/slib.texi index 7aed0b5..e1fa7b2 100644 --- a/slib.texi +++ b/slib.texi @@ -2,6 +2,7 @@ @c %**start of header @setfilename slib.info @settitle SLIB +@include version.txi @setchapternewpage on @c Choices for setchapternewpage are {on,off,odd}. @paragraphindent 2 @@ -26,7 +27,7 @@ This file documents SLIB, the portable Scheme library. Copyright (C) 1993 Todd R. Eigenschink@* -Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998 Aubrey Jaffer +Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999 Aubrey Jaffer Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -50,16 +51,43 @@ except that this permission notice may be stated in a translation approved by the author. @end ifinfo +@node Top, The Library System, (dir), (dir) + @titlepage @title SLIB @subtitle The Portable Scheme Library -@subtitle Version 2c3 +@subtitle Version @value{SLIBVERSION} @author by Aubrey Jaffer - @page + +@noindent +@dfn{SLIB} is a portable library for the programming language +@dfn{Scheme}. It provides a platform independent framework for using +@dfn{packages} of Scheme procedures and syntax. As distributed, SLIB +contains useful packages for all Scheme implementations. Its catalog +can be transparently extended to accomodate packages specific to a site, +implementation, user, or directory. + +@noindent +More people than I can name have contributed to SLIB. Thanks to all of +you! +@sp 1 +@quotation +SLIB @value{SLIBVERSION}, released @value{SLIBDATE}.@* +Aubrey Jaffer @* +@ifset html + +@end ifset +@url{http://swissnet.ai.mit.edu/~jaffer/SLIB.html} +@ifset html + +@end ifset +@end quotation + +@ifclear html @vskip 0pt plus 1filll Copyright @copyright{} 1993 Todd R. Eigenschink@* -Copyright @copyright{} 1993, 1994, 1995, 1996, 1997, 1998 Aubrey Jaffer +Copyright @copyright{} 1993, 1994, 1995, 1996, 1997, 1998, 1999 Aubrey Jaffer Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -74,28 +102,17 @@ Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the author. +@end ifclear @end titlepage - -@node Top, The Library System, (dir), (dir) - @ifinfo -@cindex SLIB +@noindent @dfn{SLIB} is a portable library for the programming language -@cindex Scheme @dfn{Scheme}. It provides a platform independent framework for using -@dfn{packages} of Scheme procedures and syntax. -@cindex packages -@cindex package -As distributed, SLIB contains useful packages for all implementations. -Its catalog can be transparently extended to accomodate packages -specific to a site, implementation, user, or directory. - -@quotation -Aubrey Jaffer @* -@i{Hyperactive Software} -- The Maniac Inside!@* -@url{http://swissnet.ai.mit.edu/~jaffer/SLIB.html} -@end quotation +@dfn{packages} of Scheme procedures and syntax. As distributed, SLIB +contains useful packages for all Scheme implementations. Its catalog +can be transparently extended to accomodate packages specific to a site, +implementation, user, or directory. @end ifinfo @menu @@ -112,28 +129,6 @@ Aubrey Jaffer @* @node The Library System, Scheme Syntax Extension Packages, Top, Top @chapter The Library System -@iftex -@section Introduction - -@noindent -@cindex SLIB -@dfn{SLIB} is a portable library for the programming language -@cindex Scheme -@dfn{Scheme}. It provides a platform independent framework for using -@dfn{packages} of Scheme procedures and syntax. -@cindex packages -@cindex package -As distributed, SLIB contains useful packages for all implementations. -Its catalog can be transparently extended to accomodate packages -specific to a site, implementation, user, or directory. - -@quotation -Aubrey Jaffer @* -@i{Hyperactive Software} -- The Maniac Inside!@* -@url{http://swissnet.ai.mit.edu/~jaffer/SLIB.html} -@end quotation -@end iftex - @menu * Feature:: SLIB names. * Requesting Features:: @@ -608,7 +603,14 @@ An integer 1 larger that the largest value which can be returned by @end defvr @defvr Constant most-positive-fixnum -The immediate integer closest to positive infinity. +In implementations which support integers of practically unlimited size, +@var{most-positive-fixnum} is a large exact integer within the range of +exact integers that may result from computing the length of a list, +vector, or string. + +In implementations which do not support integers of practically +unlimited size, @var{most-positive-fixnum} is the largest exact integer +that may result from computing the length of a list, vector, or string. @end defvr @defvr Constant slib:tab @@ -630,7 +632,7 @@ Displays the versions of SLIB and the underlying Scheme implementation and the name of the operating system. An unspecified value is returned. @example -(slib:report-version) @result{} slib "2c3" on scm "5b1" on unix +(slib:report-version) @result{} slib "@value{SLIBVERSION}" on scm "5b1" on unix @end example @end defun @@ -648,7 +650,7 @@ Writes the report to file @file{filename}. @example (slib:report) @result{} -slib "2c3" on scm "5b1" on unix +slib "@value{SLIBVERSION}" on scm "5b1" on unix (implementation-vicinity) is "/home/jaffer/scm/" (library-vicinity) is "/home/jaffer/slib/" (scheme-file-suffix) is ".scm" @@ -1763,7 +1765,7 @@ In order to use syntax-case from an interactive top level, execute: @ftindex repl (repl:top-level macro:eval) @end lisp -See the section Repl (@xref{Repl}) for more information. +See the section Repl (@pxref{Repl}) for more information. To check operation of syntax-case get @file{cs.indiana.edu:/pub/scheme/syntax-case}, and type @@ -1951,7 +1953,7 @@ identity. Also known as ``send-to-super''.@refill @deffn Procedure print obj port A default @code{print} operation is provided which is just @code{(format -@var{port} @var{obj})} (@xref{Format}) for non-instances and prints +@var{port} @var{obj})} (@pxref{Format}) for non-instances and prints @var{obj} preceded by @samp{#} for instances. @end deffn @@ -1959,7 +1961,7 @@ A default @code{print} operation is provided which is just @code{(format The default method returns the number of elements in @var{obj} if it is a vector, string or list, @code{2} for a pair, @code{1} for a character and by default id an error otherwise. Objects such as collections -(@xref{Collections}) may override the default in an obvious way.@refill +(@pxref{Collections}) may override the default in an obvious way.@refill @end defun @@ -1975,7 +1977,7 @@ retrieves a value from a generalized location and the corresponding setter operation stores a value into the location. Only the getter is named -- the setter is specified by a procedure call as below. (Dylan uses special syntax.) Typically, but not necessarily, getters are -access operations to extract values from Yasos objects (@xref{Yasos}). +access operations to extract values from Yasos objects (@pxref{Yasos}). Several setters are predefined, corresponding to getters @code{car}, @code{cdr}, @code{string-ref} and @code{vector-ref} e.g., @code{(setter car)} is equivalent to @code{set-car!}. @@ -2038,7 +2040,8 @@ value is unspecified. @subsection Examples @lisp -;;; These definitions for PRINT and SIZE are already supplied by +;;; These definitions for PRINT and SIZE are +;;; already supplied by (require 'yasos) (define-operation (print obj port) @@ -2075,11 +2078,12 @@ value is unspecified. (format #t "Discarding ~s~%" value)) (define (make-filtered-cell value filter) - (object-with-ancestors ((cell (make-cell value))) - ((store! self newValue) - (if (filter newValue) - (store! cell newValue) - (discard self newValue))))) + (object-with-ancestors + ((cell (make-cell value))) + ((store! self newValue) + (if (filter newValue) + (store! cell newValue) + (discard self newValue))))) (define-predicate array?) (define-operation (array-ref array index)) @@ -2090,9 +2094,12 @@ value is unspecified. (object ((array? self) #t) ((size self) num-slots) - ((array-ref self index) (vector-ref anArray index)) - ((array-set! self index newValue) (vector-set! anArray index newValue)) - ((print self port) (format port "#" (size self)))))) + ((array-ref self index) + (vector-ref anArray index)) + ((array-set! self index newValue) + (vector-set! anArray index newValue)) + ((print self port) + (format port "#" (size self)))))) (define-operation (position obj)) (define-operation (discarded-value obj)) @@ -2112,7 +2119,8 @@ value is unspecified. (set! most-recent-discard value)) ((discarded-value self) most-recent-discard) ((print self port) - (format port "#" (fetch self)))))) + (format port "#" + (fetch self)))))) (define-access-operation fetch) (add-setter fetch store!) @@ -2199,7 +2207,7 @@ missing input. @noindent Here are the higher-level syntax types and an example of each. -Precedence considerations are omitted for clarity. @xref{Grammar +Precedence considerations are omitted for clarity. See @ref{Grammar Rule Definition} for full details. @deftp Grammar nofix bye exit @example @@ -2885,7 +2893,7 @@ Print a floating-point number in exponential notation. @samp{%e} prints between mantissa and exponont. @item @samp{g}, @samp{G} -Print a floating-point number in either normal or exponential notation, +Print a floating-point number in either fixed or exponential notation, whichever is more appropriate for its magnitude. Unless an @samp{#} flag has been supplied trailing zeros after a decimal point will be stripped off. @samp{%g} prints @samp{e} between mantissa and exponont. @@ -2917,7 +2925,7 @@ are output. @c Print the value of a pointer. @c @item @samp{n} -@c Get the number of characters printed so far. @xref{Other Output Conversions}. +@c Get the number of characters printed so far. See @ref{Other Output Conversions}. @c Note that this conversion specification never produces any output. @c @item @samp{m} @@ -3526,8 +3534,9 @@ ERROR: getopt->parameter-list "unrecognized option" "-?" @defun filename:match?? pattern @defunx filename:match-ci?? pattern -Returns a predicate which returns true if its string argument matches -(the string) @var{pattern}, false otherwise. Filename matching is like +Returns a predicate which returns a non-false value if its string argument +matches (the string) @var{pattern}, false otherwise. Filename matching +is like @cindex glob @dfn{glob} expansion described the bash manpage, except that names beginning with @samp{.} are matched and @samp{/} characters are not @@ -3551,8 +3560,39 @@ matched by including it as the first or last character in the set. @example @end example +@end defun +@defun filename:substitute?? pattern template +@defunx filename:substitute-ci?? pattern template +Returns a function transforming a single string argument according to +glob patterns @var{pattern} and @var{template}. @var{pattern} and +@var{template} must have the same number of wildcard specifications, +which need not be identical. @var{pattern} and @var{template} may have +a different number of literal sections. If an argument to the function +matches @var{pattern} in the sense of @code{filename:match??} then it +returns a copy of @var{template} in which each wildcard specification is +replaced by the part of the argument matched by the corresponding +wildcard specification in @var{pattern}. A @code{*} wildcard matches +the longest leftmost string possible. If the argument does not match +@var{pattern} then false is returned. + +@var{template} may be a function accepting the same number of string +arguments as there are wildcard specifications in @var{pattern}. In +the case of a match the result of applying @var{template} to a list +of the substrings matched by wildcard specifications will be returned, +otherwise @var{template} will not be called and @code{#f} will be returned. +@example +((filename:substitute?? "scm_[0-9]*.html" "scm5c4_??.htm") + "scm_10.html") +@result{} "scm5c4_10.htm" +((filename:substitute?? "??" "beg?mid?end") "AZ") +@result{} "begAmidZend" +((filename:substitute?? "*na*" "?NA?") "banana") +@result{} "banaNA" +((filename:substitute?? "?*?" (lambda (s1 s2 s3) (string-append s3 s1))) "ABZ") +@result{} "ZA" +@end example @end defun @defun replace-suffix str old new @@ -3594,6 +3634,8 @@ dos @item vms @item +amigados +@item system @item *unknown* @@ -3630,16 +3672,6 @@ only argument. If @var{file} is a string, result of @code{(current-output-port)} as its third argument. @end defun -@defun batch:apply-chop-to-fit proc arg1 arg2 @dots{} list -The procedure @var{proc} must accept at least one argument and return -@code{#t} if successful, @code{#f} if not. -@code{batch:apply-chop-to-fit} calls @var{proc} with @var{arg1}, -@var{arg2}, @dots{}, and @var{chunk}, where @var{chunk} is a subset of -@var{list}. @code{batch:apply-chop-to-fit} tries @var{proc} with -successively smaller subsets of @var{list} until either @var{proc} -returns non-false, or the @var{chunk}s become empty. -@end defun - @noindent The rest of the @code{batch:} procedures write (or execute if @code{batch-dialect} is @code{system}) commands to the batch port which @@ -3650,9 +3682,9 @@ code: (adjoin-parameters! @var{parms} (list 'batch-port @var{port})) @end example -@defun batch:system parms string1 string2 @dots{} -Calls @code{batch:try-system} (below) with arguments, but signals an -error if @code{batch:try-system} returns @code{#f}. +@defun batch:command parms string1 string2 @dots{} +Calls @code{batch:try-command} (below) with arguments, but signals an +error if @code{batch:try-command} returns @code{#f}. @end defun @noindent @@ -3661,17 +3693,32 @@ translated into the batch dialect and @code{#f} if not. In the case of the @code{system} dialect, the value is non-false if the operation suceeded. -@defun batch:try-system parms string1 string2 @dots{} +@defun batch:try-command parms string1 string2 @dots{} Writes a command to the @code{batch-port} in @var{parms} which executes the program named @var{string1} with arguments @var{string2} @dots{}. @end defun +@defun batch:try-chopped-command parms arg1 arg2 @dots{} list +breaks the last argument @var{list} into chunks small enough so that the +command: + +@example +@var{arg1} @var{arg2} @dots{} @var{chunk} +@end example + +fits withing the platform's maximum command-line length. + +@code{batch:try-chopped-command} calls @code{batch:try-command} with the +command and returns non-false only if the commands all fit and +@code{batch:try-command} of each command line returned non-false. +@end defun + @defun batch:run-script parms string1 string2 @dots{} Writes a command to the @code{batch-port} in @var{parms} which executes the batch script named @var{string1} with arguments @var{string2} @dots{}. -@emph{Note:} @code{batch:run-script} and @code{batch:try-system} are not the +@emph{Note:} @code{batch:run-script} and @code{batch:try-command} are not the same for some operating systems (VMS). @end defun @@ -3775,10 +3822,10 @@ Here is an example of the use of most of batch's procedures: " printf(\"hello world\\n\");" " return 0;" "@}" ) - (batch:system my-parameters "cc" "-c" "hello.c") - (batch:system my-parameters "cc" "-o" "hello" + (batch:command my-parameters "cc" "-c" "hello.c") + (batch:command my-parameters "cc" "-o" "hello" (replace-suffix "hello.c" ".c" ".o")) - (batch:system my-parameters "hello") + (batch:command my-parameters "hello") (batch:delete-file my-parameters "hello") (batch:delete-file my-parameters "hello.c") (batch:delete-file my-parameters "hello.o") @@ -3791,7 +3838,7 @@ Produces the file @file{my-batch}: @example #!/bin/sh -# "my-batch" build script created Sat Jun 10 21:20:37 1995 +# "my-batch" script created by SLIB/batch Sun Oct 31 18:24:10 1999 # ================ Write file with C program. mv -f hello.c hello.c~ rm -f hello.c @@ -3964,12 +4011,168 @@ thus can reduce loading time. The following will write into @section Time and Date @menu +* Time Zone:: * Posix Time:: 'posix-time * Common-Lisp Time:: 'common-lisp-time @end menu +@noindent +If @code{(provided? 'current-time)}: + +@noindent +The procedures @code{current-time}, @code{difftime}, and +@code{offset-time} deal with a @dfn{calendar time} datatype +@cindex time +@cindex calendar time +which may or may not be disjoint from other Scheme datatypes. + +@defun current-time +Returns the time since 00:00:00 GMT, January 1, 1970, measured in +seconds. Note that the reference time is different from the reference +time for @code{get-universal-time} in @ref{Common-Lisp Time}. +@end defun + +@defun difftime caltime1 caltime0 +Returns the difference (number of seconds) between twe calendar times: +@var{caltime1} - @var{caltime0}. @var{caltime0} may also be a number. +@end defun + +@defun offset-time caltime offset +Returns the calendar time of @var{caltime} offset by @var{offset} number +of seconds @code{(+ caltime offset)}. +@end defun + +@node Time Zone, Posix Time, Time and Date, Time and Date +@subsection Time Zone + +(require 'time-zone) + +@deftp {Data Format} TZ-string + +POSIX standards specify several formats for encoding time-zone rules. + +@table @t +@item :@i{} +If the first character of @i{} is @samp{/}, then +@i{} specifies the absolute pathname of a tzfile(5) format +time-zone file. Otherwise, @i{} is interpreted as a pathname +within @var{tzfile:vicinity} (/usr/lib/zoneinfo/) naming a tzfile(5) +format time-zone file. +@item @i{}@i{} +The string @i{} consists of 3 or more alphabetic characters. +@i{} specifies the time difference from GMT. The @i{} +is positive if the local time zone is west of the Prime Meridian and +negative if it is east. @i{} can be the number of hours or +hours and minutes (and optionally seconds) separated by @samp{:}. For +example, @code{-4:30}. +@item @i{}@i{}@i{} +@i{} is the at least 3 alphabetic characters naming the local +daylight-savings-time. +@item @i{}@i{}@i{}@i{} +@i{} specifies the offset from the Prime Meridian when +daylight-savings-time is in effect. +@end table + +The non-tzfile formats can optionally be followed by transition times +specifying the day and time when a zone changes from standard to +daylight-savings and back again. + +@table @t +@item ,@i{}/@i{