[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

force and delay

    Date: Wed, 22 Jun 88 14:00:18 EDT
    From: James J. Hunt <jjh@ll-vlsi.arpa>

    Why don't these work with multiple values?

    > (lset foo (delay (return 1 2 3)))
    #{Delayed 1}
    > (receive-values (lambda (x y z) (list x y z)) (force foo))

    ** Error: returned 3 values when 1 was expected -
    **        (#{Continuation 2} 1 2 3)

I hope you have access to the source code.  The answer lies in the fact
that no change was made to the code for FORCE when multiple value
returns were added to T.  That code probably looks something like

    (if forced-yet?
	(let ((value (thunk)))
	  (set the-value value)
	  (set forced-yet? t)

which will clearly lose if the call to thunk returns fewer or more than
one value.  A fix (using RECEIVE-VALUES) which conses is
straightforward, but I would think twice before changing T so that FORCE
conses.  Probably the right thing though, to the extent multiple value
returns are the right thing.  Send us the fix if/when you produce one.