For Gauche 0.9.5

Next: , Previous: , Up: Library modules - SRFIs   [Contents][Index]

11.19 srfi-111 - Boxes

Module: srfi-111

This module defines the box datatype, which is a simple container that can hold one Scheme object. It can be used as a minimal data storage, or a sort of mutable indirect “pointer”.

Traditionally a pair (with ignoring its cdr) or a single-element vector has been used for this purpose; in modern Scheme you can also define a record type with one mutable field. Nevertheless, a box is very common abstraction to describe various algorithms, and having common interface to it is useful.

The srfi leaves some details to implementations. Here are our choices:

Function: box val

Returns a fresh box object that contains the value val.

Function: box? obj

Returns #t iff obj is a box object.

Function: unbox box

Returns box’s content.

Function: set-box! box val

Mutate box’s content with val. Returns unspecified value.

Next: , Previous: , Up: Library modules - SRFIs   [Contents][Index]