Next: , Previous: Integer enumerations, Up: System features


4.1.7 Cells

Scheme48 also provides a simple mutable cell data type from the cells structure. It uses them internally for local, lexical variables that are assigned, but cells are available still to the rest of the system for general use.

— procedure: make-cell contents –> cell
— procedure: cell? object –> boolean
— procedure: cell-ref cell –> value
— procedure: cell-set! cell value –> unspecified

Make-cell creates a new cell with the given contents. Cell? is the disjoint type predicate for cells. Cell-ref returns the current contents of cell. Cell-set! assigns the contents of cell to value.

Examples:

     (define cell (make-cell 42))
     (cell-ref cell)                         => 42
     (cell? cell)                            => #t
     (cell-set! cell 'frobozz)
     (cell-ref cell)                         => frobozz