Changeset 13462 in project


Ignore:
Timestamp:
03/03/09 05:28:54 (11 years ago)
Author:
Kon Lovett
Message:

Added rel4 box

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/box

    r12266 r13462  
    22
    33== box
    4 
    5 Implements the "box" data type. A box is a cell containing a single, mutable or
    6 immutable, field. The boxed value maybe any Scheme type, including a variable or
    7 a location.
    84
    95[[toc:]]
     
    128== Documentation
    139
     10Implements the "box" data type. A box is a cell containing a single, mutable or
     11immutable, field. The boxed value maybe any Scheme type, including a variable or
     12a location.
     13
    1414Two APIs are provided, the original Chicken box API and a MzScheme/Gambit compatible API.
    1515
    16 === box syntax
     16=== Box syntax
    1717
    1818The lexical syntax of a box containing the object {{OBJECT}} is `#&OBJECT'.
     
    2323=== make-box
    2424
    25 <procedure>(make-box OBJECT [#:immutable #f] [#:location #f]) => BOX</procedure>
     25<procedure>(make-box OBJECT [#:immutable #f]) => BOX</procedure>
    2626
    2727Returns a {{BOX}} with initial value {{OBJECT}}.
     
    2929The {{BOX}} is mutable unless the {{immutable}} keyword argument is {{#t}}.
    3030An attempt to mutate the boxed value will signal an exception.
    31 
    32 A {{location}} object cannot be recovered unless the {{location}} keyword
    33 argument is {{#t}}. Otherwise an attempt to acquire a location will signal an
    34 exception.
    3531
    3632=== make-box-variable
     
    10298Signals an exception otherwise.
    10399
     100The location of a boxed value or boxed location is the box. The location of a boxed
     101variable is the same as {{(location (box-ref BOX))}}; currently the location of a
     102symbol may not be taken.
     103
    104104See [[Locations]].
    105105
     
    108108<procedure>(box OBJECT) => BOX</procedure>
    109109
    110 Returns a non-locatable, mutable {{BOX}} with initial value {{OBJECT}}.
     110Returns a mutable {{BOX}} with initial value {{OBJECT}}.
    111111
    112112=== set-box!
     
    124124
    125125
    126 == Examples
     126== Usage
    127127
    128128<enscript language=scheme>
     
    131131</enscript>
    132132
     133
     134== Examples
     135
    133136<enscript language=scheme>
    134137#;1> (define b (box 0))
    135138#;2> b
    136139#&0
    137 #;3> (define (inc! bx) (set-box! bx (+ (unbox bx) 1)))
    138 #;4> (inc! b)
    139 #&1
     140#;3> (define (inc-box! bx) (set! (box-ref bx) (add1 (unbox bx))))
     141#;4> (inc-box! b)
    140142#;5> (unbox b)
    1411431
     
    153155== Bugs and Limitations
    154156
     157The location of a boxed variable is
    155158
    156159== Author
Note: See TracChangeset for help on using the changeset viewer.