notes31 - subset language and evaluate it. Thats the job of...

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: subset language and evaluate it. Thats the job of calc-eval . (We use the names calc-eval and calc-apply in this program because STk has primitive procedures called eval and apply , and we dont want to step on those names. The STk procedures have jobs exactly analogous to the ones in calc , though; every interpreter for any Lisp-family language has some form of eval and apply .) Once we get the value from eval , what do we want to do with it? We want to show it to the user by printing it to the display. Thats the job of print . So now you understand why its a read-eval-print loop! Read an expression, evaluate it, and print its value. Finally, the procedure ends with a recursive call to itself, so it loops forever; this is the loop part of the REPL. Notice that read and print are not functional programming; read returns a different value each time its called, and print changes something in the world instead of just returning a value. The body of the REPL has more than one expression; Scheme evaluates the expressions in order, and returns the value of the last...
View Full Document

Ask a homework question - tutors are online