Provides miscellaneous useful stuff.
SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', except no checks are made for correct record type before slot access, the record type symbol is not defined, procedures are inline, and unsafe system procedures are used.
For use when slot access is attempted only after determining the correct record type explicitly.
SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', except no checks are made for correct record type before slot access, the record type symbol is not defined, and procedures are inline.
For use when slot access is attempted only after determining the correct record type explicitly.
Expands into a cond
form where every case test is a type test.
A TYPE-TEST is either a symbol, which must be the base symbol of a type predicate, a non-null list, which must be a list of the base symbols of type predicates, or the symbol else
. An example of a base symbol of a type predicate is symbol
and the procedure (symbol? OBJECT)
is used for the test.
The BODY is not processed. It must be legal as the body of a cond
case.
Like typecase
but binds local variable it
to the value of EXPRESSION.
Synonym for unless
.
Swap settings of VAR1 & VAR2.
Set each variable VAR to the value VAL in parallel.
Set each variable VAR to the value VAL in series.
Decompose HASH-TABLE entries into variable bindings. Should the KEY not be symbol, or the desired variable name VAR should not be the key, the '(VAR KEY)' form can be used. The BODY ... is evaluated with the specified bindings.
Sets VAR to the value of (OP ARG ...)
, where the first occurrence of <>
in ARG ... is replaced with VAR.
When there is no occurrence of <>
in ARG ...the template (OP <> ARG ...) is used.
When EXPRESSION yields #f
invoke (error ERROR-ARGUMENT ...)
, otherwise return value.
Prints a message like (error ...) to (current-error-port) but does not throw an exception.
Same as '(error [ID] (sprintf FORMAT-STRING ARGS ...))'.
The actual argument for the returned procedure is to be a procedure which will be applied with the evaluated expressions as the actual argument list.
The following macros are also availabe as procedures.
List of length zero?
List of length one?
List of length two?
List of length greater than one?
Like shift!
in the utils unit but assigns the VARIABLE '()
after shifting from a list of length 1.
WHEN-EMPTY, which defaults to #f
is returned when the list bound to VARIABLE is empty.
Returns a list, either the list OBJECT or (list OBJECT)
.
Returns #f
if the given LIST is empty, and LIST otherwise.
Returns the first key associated with VALUE in the ALIST using the TEST? predicate, else NOT-FOUND.
TEST? is eqv?
and NOT-FOUND is #f
.
Deletes the first (tt COUNT) associations from alist ALISTwith the given key KEY, using key-comparison procedure TEST?. The dynamic order in which the various applications of equality are made is from the alist head to the tail.
Returns a new alist. The alist is not disordered - elements that appear in the result alist occur in the same order as they occur in the argument alist.
The equality procedure is used to compare the element keys, 'key[i: 0 <= i < (length ALIST)]', of the alist's entries to the key parameter in this way: '(TEST? KEY key[i])'.
COUNT defaults to essentially, infinity, and EQUALITY? defaults to eqv?
.
Destructive version of alist-delete/count
.
alist-delete-first
and alist-delete-first!
are also available as procedures.
Returns (alist-delete/count KEY ALIST 1 [TEST?])
.
Destructive version of alist-delete-first
.
Returns 2 values, a list of the keys & a list of the values from the ALIST.
Returns an association list with elements from the corresponding items of KEYS and VALUES.
Error signaling versions of the standard association lookup functions. When the KEY is not found and a NOT-FOUND value is not supplied an error
is invoked.
The assoc procedure with an optional test and default value.
The assv procedure with a default value.
The assq procedure with a default value.
Returns a list from REST-LIST with all key'ed pairs from LIST-OF-KEYWORD removed.
Returns N+1 values from OPTIONAL ..., where N is the number of optionals, with all key'ed pairs from LIST-OF-KEYWORD removed. The first return value is the 'skip?' flag, the remaining are the "fixed" optional values.
OPTIONAL is a list of the form (VALUE DEFAULT)
.
The optionals run left-to-right, and the key/value pairs are assumed to bind left-to-right.
Returns N+1 values where the 1st value is the "fixed" REST-LIST and the remaining values are the "fixed" OPTIONAL ....
Expands the BODY ... in a new lexical scope with the optional and rest variables bound to the "fixed" values.
LIST-OF-OPTIONAL is a list of elements of the form (VARIABLE DEFAULT)
where VARIABLE is the optional variable name and DEFAULT is the optional variable default value.
Read-only increment.
Read-only decrement.
Read-only increment.
Read-only decrement.
Read-only fixnum increment.
Read-only fixnum decrement.
Read-only flonum increment.
Read-only flonum decrement.
Mutable increment.
Mutable decrement.
Mutable fixnum increment.
Mutable fixnum decrement.
Mutable flonum increment.
Mutable flonum decrement.
Push the current directory and change to the DIRECTORY.
Pop the last directory and change to it.
Pop the earliest directory and change to it.
Ensures the directory pathname DIRECTORY exists.
Like the *NIX `"mkdir -p DIRECTORY" command.
Ensures the directory component of PATHNAME exist.
Like the *NIX `"mkdir -p `dirname PATHNAME`" command.
Returns the platform specific form of an executable command filename.
On Windows the exe
extension is added unless an extension is already present. Does nothing on other platforms.
Returns the platform specific form of a shell command filename.
On Windows the bat
extension is added unless an extension is already present. On *NIX platforms adds .sh
.
Returns the pathname when FILENAME exists in the DIRECTORY, otherwise #f
.
DIRECTORY-LIST is as for make-pathname
.
When only the FILENAME parameter supplied then the same as file-exists?
.
Returns a list of all pathnames found for FILENAME in the supplied directory/directories, or #f
when not found.
The list of pathnames is in the same relative order as that of the directory parameter(s).
Returns a list of all pathnames found for COMMAND-NAME in the supplied directory/directories, or #f
when not found.
Uses make-program-filename
to make a filename.
On Windows also uses make-shell-filename
to make a filename.
Does not ensure that the file is executable!
Returns the pathnames of COMMAND-NAME in the ENVIRONMENT-VARIABLE where the file exists, or #f
when nothing found.
The default ENVIRONMENT-VARIABLE is "PATH"
.
Uses the platform specific "PATH" environment variable element separator - a ';' for Windows, & a ':' otherwise.
Same as which-command-pathnames
but returns the first pathname only.
Like the *NIX "which COMMAND-NAME" command.
Remove dot files from a directory list. Useful with glob
.
Replaces the meaning of KNOWN-FILENO with NEW-FILENO. I/O Redirection.
Parameter Descriptions
priority/process | Process WHICH - WHO is 0 for current process or a process identifier. |
priority/process-group | Process Group WHICH - WHO is 0 for current process group or a process group identifier. |
priority/user | User WHICH - WHO is 0 for current user or a user identifier. |
PRIORITY | An integer [-20 20]. |
Returns the priority of WHO of kind WHICH.
Sets the priority of WHO of kind WHICH to PRIORITY.
Currently a thin wrapper around the C interface. Scheme bindings for the necessary C constants are not provided.
Returns the pointer to a new C struct winsize.
Releases a C struct winsize.
Accessors for a struct winsize
winsize-col | Returns ws_col |
winsize-col-set! | Sets ws_col |
winsize-row | Returns ws_row |
winsize-row-set! | Sets ws_row |
winsize-xpixel | Returns ws_xpixel |
winsize-xpixel-set! | Sets ws_xpixel |
winsize-ypixel | Returns ws_ypixel |
winsize-ypixel-set! | Sets ws_ypixel |
Returns the pointer to a new C struct termios.
Releases a C struct termios.
Accessors for a struct termios
termios-cc | Returns c_cc[idx] |
termios-cc-set! | Sets c_cc[idx] |
termios-cflag | Returns c_cflag |
termios-cflag-set! | Sets c_cflag |
termios-iflag | Returns c_iflag |
termios-iflag-set! | Sets c_iflag |
termios-lflag | Returns c_lflag |
termios-lflag-set! | Sets c_lflag |
termios-oflag | Returns c_oflag |
termios-oflag-set! | Sets c_oflag |
termios-ispeed | Returns c_ispeed |
termios-ispeed-set! | Sets c_ispeed |
termios-ospeed | Returns c_ospeed |
termios-ospeed-set! | Sets c_ospeed |
The C procedure.
The C procedure.
Returns the value representing "unbound".
Is the OBJECT the unbound value?
Is the SYMBOL unbound?
SYMBOL is not treated as a literal, be sure to quote if a literal desired.
Returns the SYMBOL binding when bound, otherwise the NOT-FOUND.
SYMBOL is not treated as a literal, be sure to quote if a literal desired.
Returns the value representing "undefined".
Is the OBJECT the undefined value?
Is the OBJECT the undefined value?
Returns the Chicken namespace qualified SYMBOL for the NAMESPACE.
An exception is generated when the NAMESPACE length exceeds the system limit.
Returns the Chicken namespace qualified SYMBOL for the NAMESPACE.
Is the SYMBOL a Chicken namespace qualified symbol.
Returns the printname of a Chicken namespace qualified SYMBOL.
Is the SYMBOL interned?
The build condition API macros are currently unavailable when using hygienic macros.
Expands into one or more macros that expand into a condition specification form, suitable for use with build-property-condition-api
and build-composite-condition-api
.
Example: (build-condition-naming (exn location message arguments) foo (bar rope))
Creates the following:
(define-macro (exn-condition) '(exn location message arguments))
(define-macro (foo-condition) 'foo)
(define-macro (bar-condition) '(bar rope))
Expands into a suite of procedures to construct and test SRFI-12 property condition objects.
When only one FORM is supplied a single property condition API is built. When more than one FORM are supplied then all the property condition APIs are built.
When FORM is a symbol it is a condition KIND-KEY and identifies a condition without properties. When FORM is a list the first element is the condition KIND-KEY and the following elements are property keys.
A condition constructor is named as make-KIND-KEY-condition and has 0 or more formal parameters, which are the property keys.
A condition predicate is named as KIND-KEY-condition? and has 1 formal parameter, the object to test.
Property condition constructors without properties always return the same condition object!
Example: (build-property-condition-api (exn location message arguments) foo (bar rope))
Creates the following:
(make-exn-condition location message arguments)
(exn-condition? object)
(make-foo-condition)
(foo-condition? object)
(make-bar-condition rope)
(bar-condition? object)
Expands into a suite of procedures to construct and test SRFI-12 a composite condition object.
FORM is the same as FORM in the build-property-condition-api
definition.
When zero or one FORM are supplied nothing is built. When more than one FORM are supplied then a composite API is built.
A composite condition constructor is like a property condition constructor, except that the KIND-KEY is a concatenation of every condition KEY, interspersed with a hyphen.
A composite condition predicate is like a property condition predicate, except that the KIND-KEY is a concatenation of every condition KEY, interspersed with a hyphen.
Example: (build-composite-condition-api (exn location message arguments) foo (bar rope))
Creates the following:
(make-exn-foo-bar-condition location message arguments rope)
(exn-foo-bar-condition? object)
Simplified with-exception-handler
where the HANDLER result is always returned to the caller.
HANDLER is (-> condition object).
Is the OBJECT a SRFI-12 composite condition?
When one or more KIND-KEY are supplied then the composite condition must compose at least those kind keys.
Returns a list of the kind-keys of the SRFI-12 CONDITION.
Returns a list of the property-keys for KIND-KEY of the SRFI-12 CONDITION, or #f
when no property keys or the CONDITION is not of the kind KIND-KEY.
When KIND-KEY is missing some kind-key of the CONDITION is used.
Returns an association list of the property keys & values for KIND-KEY of the SRFI-12 CONDITION, or #f
when no property keys or the CONDITION is not of the kind KIND-KEY.
When KIND-KEY is missing some kind-key of the CONDITION is used.
Returns an association list of every kind-key of the SRFI-12 CONDITION. The value of each entry is the result of (condition-properties CONDITION KIND-KEY
for that KIND-KEY.
Returns a new condition.
KIND-LIST is a list of kind-key.
PROPERTY-LIST is a property list, where the key element is a pair, (<kind-key> . <property-key>).
Like cout << arguments << args where argument can be any Scheme object. If it's a procedure (without args) it's executed rather than printed (like newline).
Like cerr << arguments << args where argument can be any Scheme object. If it's a procedure (without args) it's executed rather than printed (like newline).
String form of the newline character.
William Annis - hash-let.
Oleg Kiselyov's Standard Scheme "Prelude" - ++, ...
(use misc-extn-control misc-extn-dsssl) (hash-let ([name (foo "wow")] some-hashtable) (print name " " foo #\newline)) (stiff-set! x 1 y 2) ; x = 1 y = 2 (fluid-set! x y y x) ; x = 2 y = 1 (swap-set! x y) ; x = 1 y = 2 ; Silly example (typecase* (foo bar) [(procedure macro) #f] [symbol #t] [(vector list) #f] [else (error "not what I want" it)]) ; (define (a1 a2 #!optional o1 o2 #!rest rest #!key k1 k2) (dsssl-fixup '(#:k1 #:k2) ((o1 'x) (o2 'y)) rest (list o1 o2 rest) ) ) ; expands into something similar to #; (define (a1 a2 #!optional o1 o2 #!rest rest #!key k1 k2) (let-values ([(rest o1 o2) (fixup-extended-lambda-list '(#:k1 #:k2) rest (list o1 'x) (list o2 'y))]) (list o1 o2 rest) ) )
"Copyright (c) 2006-2007, Kon Lovett. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.