Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == box [[toc:]] == Documentation Implements the {{box}} data type. A box is a cell containing a single, mutable or immutable, field. The boxed value maybe any Scheme type, including a variable or a location. Two APIs are provided. A box API with CHICKEN concepts ({{box-core}}), and a [[https://srfi.schemers.org/srfi-111/srfi-111.html|SRFI 111]] API, via {{box}}. However, if '''only''' ''SRFI 111'' is desired, {{import}} the [[http://wiki.call-cc.org/eggref/5/srfi-111|srfi-111]] egg. === Usage <enscript language=scheme> (import box-core) </enscript> === Box syntax The lexical syntax of a box ''containing'' the scheme-object {{S*}} is {{#&S*}}. Only mutable boxes can be recovered. An immutable, variable, or location box will lose identity when printed. === make-box <procedure>(make-box [INITIAL [IMMUTABLE? #f]]) -> box</procedure> Returns a {{BOX}} with, optional, initial value {{INITIAL}}. The {{BOX}} is mutable unless the {{IMMUTABLE?}} argument is {{#t}}. An attempt to mutate an immutable box will signal an exception. === make-box-mutable <procedure>(make-box-mutable [INITIAL]) -> box</procedure> Returns a {{BOX}} with, optional, initial value {{INITIAL}}. === make-box-immutable <procedure>(make-box-immutable INITIAL) -> box</procedure> Returns a {{BOX}} with an initial value {{INITIAL}}. An attempt to mutate an immutable box will signal an exception. === make-box-variable <syntax>(make-box-variable VARIABLE [IMMUTABLE? #f]) -> box</syntax> Returns a boxed reference to the {{VARIABLE}}, which must be in lexical-scope. The {{BOX}} is mutable unless the {{IMMUTABLE?}} argument is {{#t}}. An attempt to mutate an immutable box will signal an exception. === make-box-location <syntax>(make-box-location TYPE INITIAL-VALUE [IMMUTABLE? #f]) -> box</syntax> Returns a boxed reference to a location of {{TYPE}} and {{INITIAL-VALUE}}. The {{BOX}} is mutable unless the {{IMMUTABLE?}} argument is {{#t}}. An attempt to mutate an immutable box will signal an exception. Unavailable in EVALuated source. === box? <procedure>(box? OBJECT) --> boolean</procedure> Is {{OBJECT}} a {{BOX}}? === box-mutable? <procedure>(box-mutable? OBJECT) --> boolean</procedure> Is {{OBJECT}} a mutable {{BOX}}? === box-immutable? <procedure>(box-immutable? OBJECT) --> boolean</procedure> Is {{OBJECT}} an immutable {{BOX}}? === box-variable? <procedure>(box-variable? OBJECT) --> boolean</procedure> Is {{OBJECT}} a boxed variable? === box-location? <procedure>(box-location? OBJECT) --> boolean</procedure> Is {{OBJECT}} a boxed location? === box-set! <procedure>(box-set! BOX OBJECT)</procedure> Changes the boxed value of {{BOX}} to {{OBJECT}}. Will signal an exception for an immutable {{BOX}. === box-ref <procedure>(box-ref BOX) -> *</procedure> Returns the boxed value of {{BOX}}. === box-location <procedure>(box-location BOX [WEAK? #f]) -> location</procedure> Returns a {{LOCATION}} object for a boxed variable, location or locatable box. Signals an exception otherwise. The locative is "strong" unless the {{WEAK?}} argument is {{#t}}. The {{WEAK?}} argument is ignored for boxed variables and locations. The location of a boxed value or boxed location is the box. The location of a boxed variable is the same as {{(location (box-ref BOX))}}; currently the location of a symbol may not be taken. See [[Locations]]. === box-swap! <procedure>(box-swap! BOX FUNC [OBJECT...])</procedure> Changes the boxed value of {{BOX}} to {{(FUNC <BOX-VALUE> OBJECT...)}}. Will signal an exception for an immutable {{BOX}}. Returns the new value of {{BOX}}. === make-box-variable-closure <procedure>(make-box-variable-closure IMMUTABLE? REF SET) -> box</procedure> ; {{IMMUTABLE?}} : {{boolean}} ; {{REF}} : {{(-> *)}} ; {{SET}} : {{(* -> void)}} === make-box-location-closure <procedure>(make-box-location-closure IMMUTABLE? REF SET REFLOC) -> box</procedure> ; {{IMMUTABLE?}} : {{boolean}} ; {{REF}} : {{(-> *)}} ; {{SET}} : {{(* -> void)}} ; {{REFLOC}} : {{(-> location)}} === SRFI-111 ==== Usage <enscript language=scheme> (import box) </enscript> ==== box <procedure>(box OBJECT) -> box</procedure> Returns a mutable {{BOX}} with initial value {{OBJECT}}. ==== immutable-box <procedure>(immutable-box OBJECT) -> box</procedure> Returns a mutable {{BOX}} with value {{OBJECT}}. === box? <procedure>(box? OBJECT) --> boolean</procedure> Is {{OBJECT}} a {{BOX}}? ==== unbox <procedure>(unbox BOX) -> *</procedure> Returns the boxed value of {{BOX}}. ==== set-box! <procedure>(set-box! BOX OBJECT)</procedure> Changes the boxed value of {{BOX}} to {{OBJECT}}. Will signal an exception for an immutable {{BOX}. == Examples <enscript language=scheme> #;1> (import box) #;2> (define b (box 0)) #;3> b #&0 #;4> (define (inc-box! bx) (set! (box-ref bx) (add1 (unbox bx)))) #;5> (inc-box! b) #;6> (unbox b) 1 #;7> (box-swap! b add1) 2 #;8> (box-swap! b * 3) 6 #;9> (box-ref b) 6 </enscript> == Usage <enscript language=scheme> (import box) </enscript> == Requirements [[test]] == Bugs and Limitations * The location of a boxed variable is rather useless. == Author [[/users/kon-lovett|Kon Lovett]] == Repository This egg is hosted on the CHICKEN Subversion repository: [[https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/box|https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/box]] If you want to check out the source code repository of this egg and you are not familiar with Subversion, see [[/egg-svn-checkout|this page]]. == Version history ; 3.6.0 : Remove {{check-errors}} dependency. ; 3.5.0 : Use less of {{check-errors}}. ; 3.4.0 : Remove {{srfi-111}} feature & test. ; 3.3.0 : Remove {{srfi-111}} module. ; 3.2.4 : {{srfi-111}} bindings are {{procedure}}. ; 3.2.3 : Fix type predicates. ; 3.2.2 : {{srfi-111}} provides {{box?}}. ; 3.2.1 : Provide {{box-core}} module, {{box}} w/o {{srfi-111}} bindings. ; 3.2.0 : Provide {{srfi-111}} module. Add {{make-box-mutable}} & {{make-box-immutable}}. ; 3.1.0 : Add {{immutable-box}}. ; 3.0.0 : CHICKEN 5 release. == License Copyright (C) 2009-2022 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 6 by 8?