Simpler implementation Andre van Tonder (19 Oct 2006 16:50 UTC)
Re: Simpler implementation Eli Barzilay (20 Oct 2006 07:11 UTC)
Exceptions Eli Barzilay (24 Jul 2007 18:17 UTC)

Exceptions Eli Barzilay 24 Jul 2007 18:00 UTC

I have finally switched the Lazy Scheme implementation in PLT to the
implementation that was described here.  (Close: it deals with
multiple values only in `delay'.)

There is, however, a problem with marking a currently-evaluated
promise.  The straightforward implementation does this:

  > (define e (delay (+ 1 "2")))
  > (force e)
  +: expects type <number> as 2nd argument, given: "2"; other arguments were: 1
  > (force e)
  force: reentrant promise

The same problem exists in existing delay/force implementations
(practically every one that I tried):

  > (define e (delay (list-ref '(1 2 3) (random 6))))
  > (force e)
  > (force a)

A solution to this is straightforward (given some way to capture and
store exceptions), but in many cases (as in mzscheme), catching errors
has some run-time cost.

This is a problem for implementing a lazy language.  Because of this,
I'm considering alternatives, like not marking the current node and
not doing the update-on-every-step thing.  Andre, perhaps you'll think
of a better solution?

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                         Maze is Life!