In this case there are none cis120 spring 2012 1 next

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: empty workspace—the results of the call to loop never need to be used to compute another expression. In contrast, we had (1 + (loop …)) in the recursive version. CIS120 / Spring 2012 42 Tail Call Op@miza@on •  Why does it maoer that ‘loop’ is only called in an empty workspace? •  We can op.mize the abstract stack machine: –  The workspace pushed onto the stack tells us “what to do” when the func@on call returns. –  If the pushed workspace is empty, we will always ‘pop’ immediately aier the func@on call returns. –  Therefore, we do not need to save the ‘empty’ workspace on the stack. –  Moreover, any local variables that were pushed so that the current workspace could evaluate will no longer be needed, so we can eagerly pop them too. •...
View Full Document

Ask a homework question - tutors are online