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 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/check-errors|the CHICKEN 5 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-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == check-errors Argument checks & errors. [[toc:]] == Documentation === Argument Conventions {{LOC}} is a {{symbol}}, or {{#f}}. The symbolic naming of the ''location'' detecting the problem. As in the {{error}} form. {{OBJ}} is any Scheme {{object}}. {{ARGNAM}} is a {{string}} or {{symbol}} naming the argument list element corresponding to the {{OBJ}}. The default is the type-name. === Type Checks Performs the minimal constraint check and raises an error condition upon failure. The ''mimimal constraint'' proviso is important for understanding the behavior of the checking routines. Unless otherwise specified no additional constraints are verified. So the {{check-...-interval}} routines, for example, do not verify the types of the arguments, only the interval constraint. When the {{unsafe}} feature is defined the check procedures are no-ops. ''Note'' that the full-numeric-tower is '''not''' supported. All {{check-...}} routines return the checked object; unless a type-error exception is raised, obviously. ==== Usage <enscript language=scheme> (require-extension type-checks) </enscript> ==== check-defined-value <procedure>(check-defined-value LOC OBJ [ARGNAM]) -> *</procedure> Ensures the {{OBJ}} is non-void, i.e. not an undefined-value. ==== check-bound-value <procedure>(check-bound-value LOC OBJ [ARGNAM]) -> *</procedure> Ensures the {{OBJ}} is the value of a bound variable. ''Only'' for use in rather unsafe calling environments where some explicit checking is necessary. ==== check-fixnum <procedure>(check-fixnum LOC OBJ [ARGNAM]) -> *</procedure> ==== check-positive-fixnum <procedure>(check-positive-fixnum LOC OBJ [ARGNAM]) -> *</procedure> ==== check-natural-fixnum <procedure>(check-natural-fixnum LOC OBJ [ARGNAM]) -> *</procedure> ==== check-flonum <procedure>(check-flonum LOC OBJ [ARGNAM]) -> *</procedure> ==== check-integer <procedure>(check-integer LOC OBJ [ARGNAM]) -> *</procedure> ==== check-positive-integer <procedure>(check-positive-integer LOC OBJ [ARGNAM]) -> *</procedure> ==== check-natural-integer <procedure>(check-natural-integer LOC OBJ [ARGNAM]) -> *</procedure> ==== check-number <procedure>(check-number LOC OBJ [ARGNAM]) -> *</procedure> ==== check-positive-number <procedure>(check-positive-number LOC OBJ [ARGNAM]) -> *</procedure> ==== check-natural-number <procedure>(check-natural-number LOC OBJ [ARGNAM]) -> *</procedure> ==== check-procedure <procedure>(check-procedure LOC OBJ [ARGNAM]) -> *</procedure> ==== check-input-port <procedure>(check-input-port LOC OBJ [ARGNAM]) -> *</procedure> ==== check-output-port <procedure>(check-output-port LOC OBJ [ARGNAM]) -> *</procedure> ==== check-list <procedure>(check-list LOC OBJ [ARGNAM]) -> *</procedure> ==== check-pair <procedure>(check-pair LOC OBJ [ARGNAM]) -> *</procedure> ==== check-blob <procedure>(check-blob LOC OBJ [ARGNAM]) -> *</procedure> ==== check-vector <procedure>(check-vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-structure <procedure>(check-structure LOC OBJ TAG [ARGNAM]) -> *</procedure> <procedure>(check-record LOC OBJ TAG [ARGNAM]) -> *</procedure> <procedure>(check-record-type LOC OBJ TAG [ARGNAM]) -> *</procedure> {{check-record}} and {{check-record-type}} are essentially synonyms. ==== check-symbol <procedure>(check-symbol LOC OBJ [ARGNAM]) -> *</procedure> ==== check-keyword <procedure>(check-keyword LOC OBJ [ARGNAM]) -> *</procedure> ==== check-string <procedure>(check-string LOC OBJ [ARGNAM]) -> *</procedure> ==== check-char <procedure>(check-char LOC OBJ [ARGNAM]) -> *</procedure> ==== check-boolean <procedure>(check-boolean LOC OBJ [ARGNAM]) -> *</procedure> ==== check-alist <procedure>(check-alist LOC OBJ [ARGNAM]) -> *</procedure> ==== check-minimum-argument-count <procedure>(check-minimum-argument-count LOC ARGC MINARGC) -> *</procedure> Does not verify the type of {{ARGC}}, and {{MINARGC}}. ==== check-argument-count <procedure>(check-argument-count LOC ARGC MAXARGC) -> *</procedure> Does not verify the type of {{ARGC}}, and {{MAXARGC}}. ==== check-open-interval <procedure>(check-open-interval LOC NUM MINNUM MAXNUM [ARGNAM]) -> *</procedure> {{NUM}} in {{]MINNUM MAXNUM[}}. Does not verify the type of {{NUM}}, {{MINNUM}}, and {{MAXNUM}}. ==== check-closed-interval <procedure>(check-closed-interval LOC NUM MINNUM MAXNUM [ARGNAM]) -> *</procedure> {{NUM}} in {{[MINNUM MAXNUM]}}. Does not verify the type of {{NUM}}, {{MINNUM}}, and {{MAXNUM}}. ==== check-half-open-interval <procedure>(check-half-open-interval LOC NUM MINNUM MAXNUM [ARGNAM]) -> *</procedure> {{NUM}} in {{]MINNUM MAXNUM]}}. Does not verify the type of {{NUM}}, {{MINNUM}}, and {{MAXNUM}}. ==== check-half-closed-interval <procedure>(check-half-closed-interval LOC NUM MINNUM MAXNUM [ARGNAM]) -> *</procedure> {{NUM}} in {{[MINNUM MAXNUM[}}. Does not verify the type of {{NUM}}, {{MINNUM}}, and {{MAXNUM}}. ==== check-range <procedure>(check-range LOC START END [ARGNAM]) -> number number</procedure> Verify {{(<= START END)}} & return {{(values START END)}}. Does not verify the type of {{START}} and {{END}}, but assumes {{(or fixnum flonum)}}. ==== define-check-type <macro>(define-check-type TYPNAM [TYPE-PRED])</macro> Creates a procedure definition for {{check-TYPNAM}} with the signature of the above check procedures. The type-predicate is either {{TYPE-PRED}}, when present, or {{TYPNAM?}}. {{TYPNAM}} is an unquoted {{symbol}}. <enscript language=scheme> (define-check-type hash-table) ;=> ;(define (check-hash-table loc obj #!optional argnam) ; (unless (hash-table? obj) ; (error-hash-table loc obj argnam)) ; obj ) </enscript> ==== define-check+error-type <macro>(define-check+error-type TYPNAM [TYPE-PRED [TYPMSG]])</macro> Creates a procedure definition for {{check-TYPNAM}} with the signature of the above check procedures. The type-predicate is either {{TYPE-PRED}}, when present, or {{TYPE?}}. The error message type-name is either the {{TYPMSG}}, when present, or {{"TYPNAM"}}". {{TYPNAM}} is an unquoted {{symbol}}. <enscript language=scheme> (define-check+error-type hash-table) ;=> ;(define-error-type loc obj 'hash-table) ;(define (check-hash-table loc obj #!optional argnam) ; (unless (hash-table? obj) ; (error-hash-table loc obj argnam)) ; obj ) </enscript> === Type Errors ==== Argument Conventions {{TYPNAM}} is a {{symbol}} or {{string}}, unless otherwise indicated. {{ARGNAM}} is a {{symbol}}, {{string}}, or {{#f}}. Default is {{#f}}. ==== Usage <enscript language=scheme> (require-extension type-errors) </enscript> ==== make-bad-argument-message <procedure>(make-bad-argument-message [ARGNAM]) -> string</procedure> Returns an argument type error message for the, optional, {{ARGNAM}}. Example: <enscript language=scheme> (make-bad-argument-message "count") ;=> "bad `count' argument" (make-bad-argument-message) ;=> "bad argument" </enscript> ==== make-type-name-message <procedure>(make-type-name-message TYPNAM) -> string</procedure> Returns an argument type message for the {{TYPNAM}} by supplying an article. Example: <enscript language=scheme> (make-type-name-message integer) ;=> an integer" (make-type-name-message "symbol in {foo bar baz}") ;=> "a symbol in {foo bar baz}" </enscript> ==== make-error-type-message <procedure>(make-error-type-message TYPNAM [ARGNAM]) -> string</procedure> Returns a type error message from the {{TYPNAM}} and optional {{ARGNAM}}. Uses {{make-bad-argument-message}} and {{make-type-name-message}} to build the message components. Example: <enscript language=scheme> (make-error-type-message 'integer "count") ;=> "bad `count' argument type - not an integer" </enscript> ==== signal-bounds-error <procedure>(signal-bounds-error LOC MSG OBJ...)</procedure> Raises a non-continuable type error - (({exn bounds)}}. ==== signal-type-error <procedure>(signal-type-error LOC MSG OBJ...)</procedure> Raises a non-continuable type error - (({exn type)}}. ==== error-argument-type <procedure>(error-argument-type LOC OBJ TYPNAM [ARGNAM])</procedure> Raises a {{type-error}} where is message is constructed from the {{TYPNAM}} and {{ARGNAM}}. Uses {{signal-type-error}} and {{make-error-type-message}}. ==== warning-argument-type <procedure>(warning-argument-type LOC OBJ TYPNAM [ARGNAM])</procedure> A warning is issued with a message similar to that of {{error-argument-type}}. ==== error-defined-value <procedure>(error-defined-value LOC OBJ [ARGNAM])</procedure> ==== error-bound-value <procedure>(error-bound-value LOC OBJ [ARGNAM])</procedure> ==== error-fixnum <procedure>(error-fixnum LOC OBJ [ARGNAM])</procedure> ==== error-positive-fixnum <procedure>(error-positive-fixnum LOC OBJ [ARGNAM])</procedure> ==== error-natural-fixnum <procedure>(error-natural-fixnum LOC OBJ [ARGNAM])</procedure> ==== error-flonum <procedure>(error-flonum LOC OBJ [ARGNAM])</procedure> ==== error-integer <procedure>(error-integer LOC OBJ [ARGNAM])</procedure> ==== error-positive-integer <procedure>(error-positive-integer LOC OBJ [ARGNAM])</procedure> ==== error-natural-integer <procedure>(error-natural-integer LOC OBJ [ARGNAM])</procedure> ==== error-number <procedure>(error-number LOC OBJ [ARGNAM])</procedure> ==== error-positive-number <procedure>(error-positive-number LOC OBJ [ARGNAM])</procedure> ==== error-natural-number <procedure>(error-natural-number LOC OBJ [ARGNAM])</procedure> ==== error-procedure <procedure>(error-procedure LOC OBJ [ARGNAM])</procedure> ==== error-input-port <procedure>(error-input-port LOC OBJ [ARGNAM])</procedure> ==== error-output-port <procedure>(error-output-port LOC OBJ [ARGNAM])</procedure> ==== error-list <procedure>(error-list LOC OBJ [ARGNAM])</procedure> ==== error-pair <procedure>(error-pair LOC OBJ [ARGNAM])</procedure> ==== error-blob <procedure>(error-blob LOC OBJ [ARGNAM])</procedure> ==== error-vector <procedure>(error-vector LOC OBJ [ARGNAM])</procedure> ==== error-structure <procedure>(error-structure LOC OBJ TAG [ARGNAM])</procedure> {{error-record}} and {{error-record-type}} are essentially synonyms. ==== error-symbol <procedure>(error-symbol LOC OBJ [ARGNAM])</procedure> ==== error-keyword <procedure>(error-keyword LOC OBJ [ARGNAM])</procedure> ==== error-string <procedure>(error-string LOC OBJ [ARGNAM])</procedure> ==== error-char <procedure>(error-char LOC OBJ [ARGNAM])</procedure> ==== error-boolean <procedure>(error-boolean LOC OBJ [ARGNAM])</procedure> ==== error-alist <procedure>(error-alist LOC OBJ [ARGNAM])</procedure> ==== error-minimum-argument-count <procedure>(error-minimum-argument-count LOC ARGC MINARGC)</procedure> ==== error-argument-count <procedure>(error-argument-count LOC ARGC MAXARGC)</procedure> ==== error-open-interval <procedure>(error-open-interval LOC NUM MINNUM MAXNUM [ARGNAM])</procedure> ==== error-closed-interval <procedure>(error-closed-interval LOC NUM MINNUM MAXNUM [ARGNAM])</procedure> ==== error-half-open-interval <procedure>(error-half-open-interval LOC NUM MINNUM MAXNUM [ARGNAM])</procedure> ==== error-half-closed-interval <procedure>(error-half-closed-interval LOC NUM MINNUM MAXNUM [ARGNAM])</procedure> ==== error-range <procedure>(error-range LOC START END [ARGNAM])</procedure> ==== error-interval <procedure>(error-interval LOC NUM LEFT MINNUM MAXNUM RIGHT [ARGNAM])</procedure> {{LEFT}} is a {{character}}, {{symbol}}, or {{string}} that denotes the symbolic opening of an interval. {{RIGHT}} is a {{character}}, {{symbol}}, or {{string}} that denotes the symbolic closing of an interval. ==== define-error-type <macro>(define-error-type TYPNAM [TYPMSG])</macro> {{TYPNAM}} is a {{symbol}}. {{TYPMSG}} is a {{symbol}} or {{string}}. Creates a procedure definition for {{error-TYPNAM}} with the signature of the above error procedures. The type-name is either {{TYPMSG}}, when present, or {{"TYPNAM"}}. <enscript language=scheme> (define-error-type hash-table) ;=> ;(define (error-hash-table loc obj #!optional argnam) ; (error-argument-type loc obj "hash-table" argnam) ) (define-error-type byte-order "symbol in {big-endian little-endian}") ;=> ;(define (error-byte-order loc obj #!optional argnam) ; (error-argument-type loc obj "symbol in {big-endian little-endian}" argnam) ) </enscript> === SRFI 4 Checks ==== Usage <enscript language=scheme> (require-extension srfi-4-checks) </enscript> ==== check-s8vector <procedure>(check-s8vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-u8vector <procedure>(check-u8vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-s16vector <procedure>(check-s16vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-u16vector <procedure>(check-u16vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-s32vector <procedure>(check-s32vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-u32vector <procedure>(check-u32vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-s64vector <procedure>(check-s64vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-u64vector <procedure>(check-u64vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-f32vector <procedure>(check-f32vector LOC OBJ [ARGNAM]) -> *</procedure> ==== check-f64vector <procedure>(check-f64vector LOC OBJ [ARGNAM]) -> *</procedure> === SRFI 4 Errors ==== Usage <enscript language=scheme> (require-extension srfi-4-errors) </enscript> ==== error-s8vector <procedure>(error-s8vector LOC OBJ [ARGNAM])</procedure> ==== error-u8vector <procedure>(error-u8vector LOC OBJ [ARGNAM])</procedure> ==== error-s16vector <procedure>(error-s16vector LOC OBJ [ARGNAM])</procedure> ==== error-u16vector <procedure>(error-u16vector LOC OBJ [ARGNAM])</procedure> ==== error-s32vector <procedure>(error-s32vector LOC OBJ [ARGNAM])</procedure> ==== error-u32vector <procedure>(error-u32vector LOC OBJ [ARGNAM])</procedure> ==== error-s64vector <procedure>(error-s64vector LOC OBJ [ARGNAM])</procedure> ==== error-u64vector <procedure>(error-u64vector LOC OBJ [ARGNAM])</procedure> ==== error-f32vector <procedure>(error-f32vector LOC OBJ [ARGNAM])</procedure> ==== error-f64vector <procedure>(error-f64vector LOC OBJ [ARGNAM])</procedure> == Bugs & Limitations * CHICKEN_INCLUDE_PATH must at least state the value of the {{(repository-path)}} to include ''inline-type-checks.scm''. * The {{make-*-message}} functions are English only. * No {{check-negative-*}} or {{error-negative-*}} functions. == Notes * {{s64vector}} and {{u64vector}} are unsupported by the Chicken Unit srfi-4. == Author [[/users/kon-lovett|Kon Lovett]] == Version history ; 2.2.0 ; Fix {{check-range}} return. ; 2.1.0 ; Add {{check-range}}, {{error-range}}, {{signal-bounds-error}}. ; 2.0.1 ; Fix interval boundary symbols. ; 2.0.0 ; Removed copy of ''inline-type-checks.scm'' to {{(chicken-home)}}. Ticket #1327 ; 1.13.0 ; Added egg module. ; 1.12.6 ; ''inline-type-checks.scm'' copied to Chicken Repository. Produces shared+static object files. ; 1.12.5 ; {{define-inline-check-type}} generates name with "%" prefix. ; 1.12.4 ; Moved optional argument name checks until after error detected. ; 1.12.3 ; Fix for {{error-minimum-argument-coun}} and {{error-argument-count}}. ; 1.12.2 ; Better ''no-install'' support. ; 1.12.1 ; Deprecated {{...-cardinal-...}} in favor of {{...-natural-...}}. ; 1.12.0 ; Removed ''error-utils'' & ''conditions''. ; 1.11.0 ; Added ''error-utils''. ; 1.10.0 ; The {{check-...}} routines return the checked value. ; 1.8.0 : Added srfi-4 support. ; 1.7.0 : ; 1.6.0 : Added interval support. ; 1.5.0 : Added alist and argument count support. ; 1.4.0 : ; 1.3.0 : Added {{warning-argument-type}}. ; 1.2.0 : Added {{make-error-type-message}} & fixed {{define-check+error-type}}. ; 1.1.0 : Added {{make-condition+}}, {{condition-property-accessor*}} and {{make-condition-property-accessor}}. ; 1.0.0 : Initial release. == License Copyright (C) 2009-2017 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.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 15 to 2?