Arguments Structures (original) (raw)
8.15
This library defines arguments structures, values containing a set of positional and keyword argument values. Various utility procedures for constructing and manipulating these structures are provided.
Source code for this library is avaible on Github and is provided under the terms of the MIT License.
Returns all arguments given, in the form of an arguments structure. Accepts both positional and keyword arguments.
Example:
> (arguments 1 2 3 #:foo "bar") (arguments 1 2 3 #:foo "bar")
(make-arguments positional keyword) → arguments? positional : list? keyword : keyword-hash?
Returns an arguments structure with positional andkeyword as its arguments.
Example:
> (make-arguments '(1 2 3) (hash '#:foo "bar")) (arguments 1 2 3 #:foo "bar")
(arguments-positional arguments) → list? arguments : arguments? (arguments-keyword arguments) → keyword-hash? arguments : arguments?
Predicate and accessors for arguments structures.
Calls f with args and returns whatever values are returned byf.
Added in version 1.1 of package arguments.
Changed in version 1.2.1: caused nondeterministic contract exceptions
(arguments-merge args ...) → arguments? args : arguments?
Returns a combination of the given args. The returned arguments structure contains all the positional and keyword arguments of eachargs structure. Positional arguments are ordered left to right, and if two args structures have duplicate keyword arguments the rightmostargs takes precedence. When called with no arguments, returnsempty-arguments.
Examples:
> (arguments-merge (arguments 1 #:foo 2 #:bar 3) (arguments 'a 'b #:foo 'c)) (arguments 1 'a 'b #:bar 3 #:foo 'c) > (arguments-merge) (arguments)
Added in version 1.3 of package arguments.
(lambda/arguments args-id body ...+)
Constructs an anonymous function that accepts any number of arguments, collects them into an arguments structure, and binds that structure toargs-id in the body forms.
Examples:
> (pos-sum 1 2 3) 6 > (pos-sum 1 2 3 #:foo 'bar) 6
Added in version 1.2 of package arguments.
(define/arguments (id args-id) body ...+)
Defines id as a function that accepts any number of arguments, collects them into an arguments structure, and binds that structure to args-id in the body forms.
Examples:
> (keywords-product #:foo 2 #:bar 3) 6 > (keywords-product 'ignored #:baz 6 #:blah 4) 24
Added in version 1.2 of package arguments.
The empty arguments structure. Equivalent to (arguments).
A flat contract that recognizes immutable hashes whose keys are keywords. Equivalent to (hash/c keyword? any/c #:flat? #t #:immutable #t). Used for the keyword arguments of an arguments structure.