/* Author: Jeff Dalton * Updated: Wed Mar 14 13:14:07 2001 by Jeff Dalton */ package ix.util.lisp; import java.util.*; import ix.util.*; /** * A class for delaying evaluation.

* * A standard way to construct a Delay is to instantiate an anonymous * class. For instance: * *

 *    new Delay() {
 *        public Object eval() {
 *            ... code that computes the value ...
 *        }
 *    }
 * 
*/ // N.B. Need to use the above style of comment to preserve the indentation // in the pre block. public abstract class Delay { Object value = null; boolean forced_p = false; public Object force() { if (!forced_p) { value = eval(); forced_p = true; } return value; } public abstract Object eval(); }