또 구글링.. ㅠㅠ
http://eli.thegreenplace.net/2007/10/08/sicp-section-334/
----
Exercise 3.31
By calling the action procedure, it makes sure that the operation of
the gate is actually defined. Consider the inverter gate again:
(defun inverter (input output)
(flet ((invert-input ()
(let ((new-value
(logical-not
(signal-value input))))
(after-delay
*inverter-delay*
(lambda ()
(setf
(signal-value output)
new-value))))))
(add-action! input #'invert-input)
'ok))
When (inverter x nx) is executed, add-action! is called. It is
expected to call invert-input once, because otherwise the after-delay
call won’t be executed and won’t add the gate operation to the agenda.
What this means is that the initial values of the signals won’t be
propagated through the logic gates.
Exercise 3.32
The first transition from 0 to 1 would bring the gate’s inputs both to
1 momentarily, which would make it switch to 1. But at the same
segment, the transition of the other signal from 1 to 0 would make it
switch back to 0. It can also be simulated using the current queue
implementation, by changing the order of signal assignments. Compare
this:
(setq x (make-wire))
(setq y (make-wire))
(setq z (make-wire))
(and-gate y x z)
(setf (signal-value x) 1)
(setf (signal-value y) 0)
(propagate)
(setf (signal-value x) 0)
(setf (signal-value y) 1)
(propagate)
=> Z 0 new-value = 0
To this (the change is in the order between assignments to x and y
before the 2nd propagate):
(setq x (make-wire))
(setq y (make-wire))
(setq z (make-wire))
(and-gate y x z)
(setf (signal-value x) 1)
(setf (signal-value y) 0)
(propagate)
(setf (signal-value y) 1)
(setf (signal-value x) 0)
(propagate)
=> Z 0 new-value = 0
=> Z 6 new-value = 1
=> Z 6 new-value = 0
In real electronic systems this is called a hazard, and can happen if
the time difference between the change of two inputs is larger than
the propagation delay of the gate, and the intermediate state is
different from the final one.