All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Jaja.Box

java.lang.Object
   |
   +----Jaja.Jaja
           |
           +----Jaja.Value
                   |
                   +----Jaja.Box

public class Box
extends Value
This class implements mutable boxes (or references in ML parlance). A box holds a single value at any time and may be modified to hold another value. Boxes are used to implement mutable variables in Jaja (so they can be shared since the compiler uses flat closures copying the bindings they close.

Normally, in Scheme, a Box is not a first-class value and therefore should not inherit from Value. But for ML and for typing reason this is easier.

A non initialized box holds a null content.


Variable Index

 o content
Only mutated through setBoxContent.

Constructor Index

 o Box()
 o Box(Value)

Method Index

 o getBoxContent()
Read the content of a box.
 o setBoxContent(Value)
Modify the content of a Box.

Variables

 o content
 protected Value content
Only mutated through setBoxContent. Unfortunately this slows down read access which has to pass through a method.

Constructors

 o Box
 public Box()
 o Box
 public Box(Value c)

Methods

 o setBoxContent
 public synchronized Value setBoxContent(Value value)
Modify the content of a Box. Returns the former content.

 o getBoxContent
 public Value getBoxContent()
Read the content of a box. this does not need to be a synchronized method since the JVM warrants an atomic access to 32 bits pointers.


All Packages  Class Hierarchy  This Package  Previous  Next  Index