<< Previous exercise (4.27)
| Index |
Next exercise (4.29) >>
(define (g x) (+ x 1))
(define (f g x) (g x))
when call (f g 10), if don't use actual-value which will call force-it, g will be passed as parameter which will be delayed, then g is a thunk, can't be used as function to call 10.
Let me make meteorgan's answer more specific.
'g' will be passed as a parameter which will be delayed literally. It means 'g' is a thunk and (g 10) will be considered as application in the 'eval'. In the procedure apply, the 'g' will be seen as a procedure, with a tag 'thunk', which is not a primitive procedure and compound procedure. So the procedure apply will report an error.
a simpler example
(define (proc operate) operate)
; error: Unknown procedure type -- APPLY (thunk + (...))
((proc +) 1 2)