[comp.lang.scheme.c] Implicit Forcing

math1205@waikato.ac.nz (09/11/90)

How would one go about making forces implicit in a Scheme implementation?
From R3RS it seems such a thing is permissible and indeed implemented in
some versions. Does any know of such a version?

Would it be necessary to modify all primitive procedures such as car, + to
check for the presence of a promise where by default promises would be
self-evaluating. I suspect most primitive procedure require actual values,
the only ones I can think of that don't are: cons, list, 2nd arg of append,
set! and  user-defined procedure calls.

Also are there any nasty suprises install for somebody implementing the above,
like special cases, incompatiblity with other language features (e.g. garbage
collector, continuations)? Has anyone considered added this feature to
Scheme->C ?

Thanks in advance to replies.
Wayne Schou
MATH1205@waikato.ac.nz

hankd@DYNAMO.ECN.PURDUE.EDU (Hank Dietz) (09/11/90)

Please remove me from this mailing list.  Thank you.

						-hankd

jinx@ALTDORF.AI.MIT.EDU ("Guillermo J. Rozas") (09/12/90)

   Date: 11 Sep 90 01:28:10 GMT
   From: comp.vuw.ac.nz!virtue!math1205@uunet.uu.net
   Organization: University of Waikato, Hamilton, New Zealand
   Sender: info-cscheme-request@altdorf.ai.mit.edu

   How would one go about making forces implicit in a Scheme implementation?
   From R3RS it seems such a thing is permissible and indeed implemented in
   some versions. Does any know of such a version?

MIT Scheme used to, about 8 years ago, before the CScheme
implementation was written.  We decided to do away with that feature
because it wasn't being used and complicated the implementation in
many ways.  Jim Miller's MultiScheme (based on C Scheme) did
essentially the same for futures.  Each future object was programmable
in such a way that the time of forcing and the action on touch (force)
could be controlled.  Implementing traditional and "automatic"
promises on top of that was easy.

   Would it be necessary to modify all primitive procedures such as car, + to
   check for the presence of a promise where by default promises would be
   self-evaluating. I suspect most primitive procedure require actual values,
   the only ones I can think of that don't are: cons, list, 2nd arg of append,
   set! and  user-defined procedure calls.

The worst part is not the primitives, which after all, are supposed to
check their arguments and can have their back-out handler "patch" the
case of promises, but conditionals.  All conditionals (if, cond, or)
must test for promises and force them before deciding on the branch to
take.  Another bad case is function invocation.  Before applying the
value of the operator of a combination, it must be forced into a
procedure, etc.

   Also are there any nasty suprises install for somebody implementing the above,
   like special cases, incompatiblity with other language features (e.g. garbage
   collector, continuations)? Has anyone considered added this feature to
   Scheme->C ?

There are problems with assignment.  Any lazy evaluation method gains
its power by abstracting away from detailed timing.  Assignments and
other side effects are essentially timing markers, and don't mix at
all with lazy evaluation.

As far as special cases are concerned, there are many.  For each
primitive you must decide on what arguments it is strict and on which
it is not.  That is, cons probably does not want to force either
argument, but + probably wants to force both.  There are mixed cases
as well, and the issue becomes murkier for primitives or other
procedures that manipulate aggregates (what is the printer supposed to
do, for example).

In general, you need to force an argument whose bits need to be
examined to determine the result of the primitive, and you probably
don't want to force anything else to accomodate as lazy a style as
possible.