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/variable-item|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]] == variable-item [[toc:]] == Documentation Various useful forms. ==== make-variable <procedure>(make-variable INIT [GUARD]) => (procedure _ *)</procedure> Returns a {{procedure}} whose behavior is that of a {{parameter}}, except for the fact that it is '''not''' a {{parameter}}. The closed-over value is not thread-local. {{INIT}} is some Scheme {{object}} that meets the constraint enforced by the {{GUARD}}. {{GUARD}} is a {{(procedure (*) *)}} returning an acceptable value for the variable. Default is {{identity}}. Supports SRFI 17. ==== warning-guard <macro>(warning-guard GETTER-NAME TYPENAME [BODY...])</macro> Constructs a variable or parameter guard procedure that generates a warning and returns the current value when the type predicate fails, otherwise the submitted value is returned. {{TYPENAME}} is an {{identifier}} and {{TYPENAME?}} is a {{(procedure (*) boolean)}}. {{GETTER-NAME}} is an {{identifier}} and the name of a {{procedure _ *}}. {{BODY}} is zero or more expressions that are performed after a successful typecheck. ''Note'' that since the guard is invoked by a {{variable}} or {{parameter}} during initialization, so will be the body code. <enscript highlight="scheme"> (use variable-item) (warning-guard some-var integer) </enscript> ==== checked-guard <macro>(checked-guard GETTER-NAME TYPENAME [BODY...])</macro> Constructs a variable or parameter guard procedure that uses a type check procedure to verify the submitted value is returned. {{TYPENAME}} is an {{identifier}} and {{check-TYPENAME}} is a {{(procedure ((or #f symbol) * #!optional (or symbol string)) *)}}. See [[check-errors]] for a suite of these procedures. {{GETTER-NAME}} is an {{identifier}} and the name of a {{procedure _ *}}. {{BODY}} is zero or more expressions that are performed after a successful typecheck. ''Note'' that since the guard is invoked by a {{variable}} or {{parameter}} during initialization, so will be the body code. <enscript highlight="scheme"> (use variable-item type-checks) (checked-guard some-var integer) </enscript> ==== define-variable <macro>(define-variable NAME INIT [GUARD])</macro> Wrapper around {{make-variable}} that defines the variable {{NAME}} to the ''variable''. {{NAME}} is an {{identifier}}. {{INIT}} and {{GUARD}} as for {{make-variable}}. <enscript highlight="scheme"> (use variable-item) (define-variable scale * (warning-guard scale procedure)) (scale) ;=> #<procedure ...> (scale /) </enscript> ==== define-warning-variable <macro>(define-warning-variable NAME INIT TYPENAME [BODY...])</macro> Wrapper around {{make-variable}} and {{warning-guard}} that defines the variable {{NAME}} to the ''variable''. {{NAME}} is an {{identifier}}. {{INIT}} is some Scheme {{object}}. {{TYPENAME}} is an {{identifier}}. The basename of a type predicate; see [[#warning-guard|warning-guard]]. {{BODY...}} as for {{warning-guard}}. <enscript highlight="scheme"> (use variable-item) (define-warning-variable scale * procedure) (scale 23) ;=> Warning: (foo) "bad argument type - not a procedure" 23 </enscript> ==== define-checked-variable <macro>(define-checked-variable NAME INIT TYPENAME [BODY...])</macro> Wrapper around {{make-variable}} and {{checked-guard}} that defines the variable {{NAME}} to the ''variable''. {{NAME}} is an {{identifier}}. {{INIT}} is some Scheme {{object}}. {{TYPENAME}} is an {{identifier}}. The basename of a type predicate; see [[#checked-guard|checked-guard]]. {{BODY...}} as for {{checked-guard}}. <enscript highlight="scheme"> (use variable-item) (define-checked-variable scale * procedure) (scale 23) ;=> Error: (foo) "bad argument type - not a procedure" 23 </enscript> ==== define-parameter <macro>(define-parameter NAME INIT [GUARD])</macro> Wrapper around {{make-parameter}} that defines the parameter {{NAME}} to the ''parameter''. {{NAME}} is an {{identifier}}. {{INIT}} and {{GUARD}} as for {{make-parameter}}. Duplicate of macro found in the {{miscmacros}} extension. ==== define-warning-parameter <macro>(define-warning-parameter NAME INIT TYPENAME [BODY...])</macro> Wrapper around {{make-parameter}} and {{warning-guard}} that defines the parameter {{NAME}} to the ''parameter''. {{NAME}} is an {{identifier}}. {{INIT}} is some Scheme {{object}}. {{TYPENAME}} is an {{identifier}}. The basename of a type predicate; see [[#warning-guard|warning-guard]]. {{BODY...}} as for {{warning-guard}}. <enscript highlight="scheme"> (use parameter-item) (define-warning-variable scale * procedure) (scale 23) ;=> Warning: (foo) "bad argument type - not a procedure" 23 </enscript> ==== define-checked-parameter <macro>(define-checked-parameter NAME INIT TYPENAME [BODY...])</macro> Wrapper around {{make-parameter}} and {{checked-guard}} that defines the variable {{NAME}} to the ''parameter''. {{NAME}} is an {{identifier}}. {{INIT}} is some Scheme {{object}}. {{TYPENAME}} is an {{identifier}}. The basename of a type predicate; see [[#checked-guard|checked-guard]]. {{BODY...}} as for {{checked-guard}}. <enscript highlight="scheme"> (use parameter-item) (define-checked-parameter scale * procedure) (scale 23) ;=> Error: (foo) "bad argument type - not a procedure" 23 </enscript> ==== Usage <enscript language=scheme> (require-extension variable-item) </enscript> == Requirements [[check-errors]] == Author [[/users/kon-lovett|Kon Lovett]] == Version history ; 1.3.0 : Moved from {{moremacros}} extension. Added {{parameter}} macros. == License Copyright (C) 2010 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 multiply 5 by 1?