previous | index | next

RA-Stack Height and Emptiness

     (define height
       (lambda (ra-stack)
	 (vector-ref ra-stack 0)))

     (define empty-ra-stack?
       (lambda (ra-stack)
	 (= 0 (height ra-stack))))
We could have defined empty-ra-stack? as:
     (define empty-ra-stack? ; second version
       (lambda (ra-stack)
	 (= 0 (vector-ref ra-stack 0))))
Q: Why is the first version better?

A: It doesn't expose the implementation choice (vectors).

Data abstraction again: Hide to the extent possible the details of the implementation.


previous | index | next