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

Force & Delay

    Date: Tue, 2 Aug 83 14:44:46 EDT

    Do you have any recommendations as far as using Force & Delay? i.e. things
    like whether they compile well, whether there are any bugs, whether they are
    likely to remain permanent features of the language etc.

There's no problem with force & delay; as far as I know, they work fine,
and they are definitely stable features.  They aren't as efficient as
they could be, however; maybe I'll hack the compiler to know more about
them in the future.  As it is, the cost of creating a delay is the cost
of doing one CONS plus the cost of creating a closure, if necessary, for
the expression.  E.g. in

	(LET ((X (FOO)))

the space overhead is two cons cells: one for the delay, and one for the
closure (LAMBDA () (COMPUTE X)), which must close over X.  The time
overhead of creation is one procedure call (the call to MAKE-DELAY), and
that of forcing is two procedure calls (the call to FORCE, and, the
first time the delay is forced, the call to the closure).

This would be less mysterious if the manual explained that DELAY was just a
trivial macro in terms of MAKE-DELAY:


MAKE-DELAY has a definition equivalent to, but somewhat more bummed
than, the following:

		    ((FORCE SELF)
		     (COND ((NOT FORCED?)
			    (SET FORCED? T)))

Future editions of the manual will make this clearer.