Convert an object to another representation
(require-extension coerce)
A Chicken specific version of the SLIB "coerce.scm" module, with extensions.
Implements object type conversion
Returns a symbol name for the type of object.
Converts and returns object to result-type.
- result-type is a symbol.
- default-proc is
(-> object-type-symbol object result-type-symbol object)
and is invoked when coercion fails.- Builtin types are
char
,number
,string
,symbol
,list
, andvector
.
Returns a list of every element of list-of-object coerced to the corresponding element of list-of-result-type.
- default-proc and result-type are as for
coerce
.
Extends the domain of coerce with the type definition {identifier predicate convertor}.
- identifier is a symbol.
- predicate is a procedure,
(-> object boolean)
, testing whether the argument is a type.- convertor is a procedure,
(-> object symbol on-error object)
, converting from the type to a result type.- The convertor must invoke (on-error) when conversion not possible. Usually
case-coerce
would be used to create the convertor, which automatically handles calling of the on-error parameter.
Extends the domain of an existing coerce extension.
- identifier, predicate, and convertor are as for
extend-coerce
.- The new convertor is try'ed before the existing procedure, then the existing procedure is try'ed "on-error".
- Should the new predicate and existing predicate be
eq?
the predicates are not "composited" usingor
.
Delete any existing coerce extension for identifier.
Returns a coercion procedure for use with
extend-coerce
- convertor is a coercion procedure,
(-> object symbol on-error object)
.- alist is a list of
(symbol . (-> object object))
.
Returns a coercion procedure for use with
extend-coerce
.
- case is of the form
((symbol ...) expression ...)
, or(else expression ...)
- The variable object is bound to the object to coerce within the case-body, case ....
- The variable on-error is bound to a thunk within the case-body, case ..., to invoke on error.