SICP Exercise 3.31

Question

The internal procedure accept-action-procedure! defined in make-wire specifies that when a new action procedure is added to a wire, the procedure is immediately run. Explain why this initialization is necessary. In particular, trace through the half-adder example in the paragraphs above and say how the system’s response would differ if we had defined accept-action-procedure! as

(define (accept-action-procedure! proc)
  (set! action-procedures
	(cons proc action-procedures)))

Answer

The initialization is necessary because otherwise, the initial state of every wire will always be 0, which is not necessarily correct. You may consider an inverter, which if it has 0 as its input, should have 1 as its output i.e. 1 should be the initial state of the output. To accomplish this, the method must be run once initially.

This is actually the way digital circuits also work in the real world. An inverter does not only start working when we start doing something to the system, but it will already be delivering an output of 1 even before we start interacting with the system at all.