Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for [[/eggref/4/coerce|the CHICKEN 4 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-4.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == coerce [[toc:]] === Description Convert an object to another representation === Author Ported to Chicken: [[Kon Lovett]] === Requirements * [[miscmacros]] * [[misc-extn]] === Download [[http://code.call-cc.org/legacy-eggs/3/coerce.egg|coerce.egg]] === Documentation A Chicken specific version of the SLIB "coerce.scm" module, with extensions, which implements object type conversion. ==== type-of <procedure>(type-of OBJECT)</procedure> Returns a symbolic name for the type of {{OBJECT}}. ==== coerce <procedure>(coerce OBJECT RESULT-TYPE [DEFAULT])</procedure> Converts {{OBJECT}} to a {{RESULT-TYPE}} value. {{RESULT-TYPE}} is a symbol. {{DEFAULT}} is {{(object-type-symbol object result-type-symbol -> object)}} and is invoked when coercion fails. Built-in types are {{char}}, {{number}}, {{string}}, {{symbol}}, {{list}}, and {{vector}}. ==== coerce-all <procedure>(coerce-all LIST-OF-OBJECT LIST-OF-RESULT-TYPE [DEFAULT])</procedure> Returns a list of every element of {{LIST-OF-OBJECT}} coerced to the corresponding element of {{LIST-OF-RESULT-TYPE}}. {{DEFAULT}} and {{RESULT-TYPE}} are as for {{coerce}}. ==== extend-coerce <procedure>(extend-coerce IDENTIFIER PREDICATE CONVERTOR)</procedure> 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}} argument. ==== composite-coerce-extension <procedure>(composite-coerce-extension IDENTIFIER PREDICATE CONVERTOR)</procedure> 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" using {{or}}. ==== remove-coerce-extension <procedure>(remove-coerce-extension IDENTIFIER)</procedure> Delete any existing coerce extension for {{IDENTIFIER}}. ==== make-case-coerce <procedure>(make-case-coerce CONVERTOR [ALIST])</procedure> 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)}}. ==== case-coerce <macro>(case-coerce CASE ...)</macro> 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. === Changelog * 3.001 Added composite-coerce-extension & remove-coerce-extension. * 3.0 Added test. Removed coerce-procedure. Added case-coerce. Added hygienic macro support. * 2.0 Split into syntax & support files. * 1.3 Added coerce-all, changed signature of default-procedure parameter. * 1.2 Added default-procedure parameter to coerce. * 1.1 Added extend. === License Copyright (c) 2006, Kon Lovett All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 6 to 8?