Lecture 12 Notes

E r h 1 r r 3 t 3 4 3 9 0 3 r

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: will think of Proc as an abstract data type. We consider its interface and specification below. We will also need syntax for procedure creation and calling. This is given by the productions Expression C8H8¨%©¡ B C ¥¢ @ R C 7 ¨B %%¡ ¡ ¦8§¨ ¨'¥ @ §8§¨ ¨'¥ 7 @ Expression Expression 1 %%¡ @ ¨B ¨B %%¡ ¡ ¢ ¨ Expression :: Identifier CV$' &¤&T Expression :: Some vocabulary words: C ¨B %%¡ ¡ §8§¨ @ ¨'¥ In var e , the identifier var is the bound variable or formal parameter and e is the body. In a procedure call e 1 e2 , the expression e1 is the operator and e2 is the operand or actual parameter. We use the word argument to refer to the value of an actual parameter. C ¨B %%¡ ¡ ¦ ¢ ¨ @ 34 3.2.1 The datatype Proc ¡¥"$¡¨'¥ §§©%¤¦8©¨ ¡ ¤ ¨ ¢ V¨ ¡¥"$ ¨'¥ §§%%¡ ¦8§¨ Interface: the constructor and the observer , which tells how to build a procedure value, , which tells how to apply a procedure value. Our next task is to determine what information must be included in a value representing a procedure. To do this, we consider what happens when we write a expression in an arbitrary position in our program. ¨'¥ §8§¨ 55HT )" £ " 8§¥ ¡ $ "'§ ¤ (&( £" §T F £ " 0§¥ £ ¡ 5 5 1 ( ¡ T £ T" 9 ¨B %%¡ ¡ ¢ £ C1 C e¥ @ F C1 @ G @ ¡ £3 ¨'¥ §8§¨ expression must depend in some way on the environConclusion: value of a ment in which the expression is evaluated. ¡¥"$¡¨'¥ ©§%%¤§8§¨ Therefore the constructor must take three arguments: the bound variable, the body, and the environment, and the specification for a expression should be ¨'¥ ¦8©¨ ¡9"£ ¢ R ¡ 4T '' ¢ 35 or ¢ 5 5 ¡  5 3 ¦ ¤ @ ¦   ( £ ¨   ( 5 ¡  (&¦ )©¨   (  ©§¥£  ¨¦¤ R ¡ ¦8©¨ ¨'¥ where is the constructor, like expressed value from a Proc . 00 ©2 var e R 0 270 var e , that builds an $ "' ¤ &§ ¡T FI I S ¥ ¤¡ £ 3 C &B @ ¡ C @ ¨§'8¥§¨ £ S 55 1 B £¡ £3 FI I S C &B @ ¡ C @ ¨¦'8¥§¨ GU¤¡ £ 3 £ S B£ U¤¡ 55...
View Full Document

This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online