/*
 *
 *  p r o m i s e . c		-- Promises management
 *
 *
 * Copyright (C) 1993,1994,1995 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
 * 
 *
 * Permission to use, copy, and/or distribute this software and its
 * documentation for any purpose and without fee is hereby granted, provided
 * that both the above copyright notice and this permission notice appear in
 * all copies and derived works.  Fees for distribution or use of this
 * software or derived works may only be charged with express written
 * permission of the copyright holder.  
 * This software is provided ``as is'' without express or implied warranty.
 *
 * This software is a derivative work of other copyrighted softwares; the
 * copyright notices of these softwares are placed in the file COPYRIGHTS
 *
 *
 *            Author: Erick Gallesio [eg@kaolin.unice.fr]
 *    Creation date:  2-Jun-1993 12:27
 * Last file update:  1-Feb-1995 20:02
 *
 *
 */

#include "stk.h"

/*
 * Delay is implemented by syntax_delay in syntax.c
 */

PRIMITIVE STk_force(SCM promise)
{
  SCM z;

  if (NPROMISEP(promise)) return promise;

  if (promise->storage_as.promise.resultknown) 
    /* promise was alraedy evaluated. Simply return expr field */
    return promise->storage_as.promise.expr;

  z = Apply(promise->storage_as.promise.expr, NIL);
  promise->storage_as.promise.expr 	   = z;
  promise->storage_as.promise.resultknown  = 1;
  return z;
}

PRIMITIVE STk_promisep(SCM promise)
{
  return PROMISEP(promise)? Truth: Ntruth;
}
