Concepts and Semantics of Programming Languages 1. Therese Hardin

Чтение книги онлайн.

Читать онлайн книгу Concepts and Semantics of Programming Languages 1 - Therese Hardin страница 17

Concepts and Semantics of Programming Languages 1 - Therese Hardin

Скачать книгу

.

       6) Consider the sequence

image

      Determine the states etat3 = (Env3, Mem3) and etat4 = (Env4, Mem4). Does image

       Exercise 2.2

      The two constructs x + + and + + x:

image

      are added to the language Exp1. In these two new constructs, the identifier x must be a mutable variable. Intuitively, we see that the evaluation of the expression x + + produces the value stored in the location denoted by x and increments the value in the memory by 1. The expression + + x is evaluated differently: the value stored at the location denoted by x is incremented by 1, and this new value is the result of the evaluation.

       1) Define an evaluation function:for expressions in the language Exp1, extended so that expresses the fact that evaluation of the expression e in the state (Env, Mem) transforms this state into a state (Env’, Mem’) and produces the value v.

       2) Let Env = [(x, rx)] and Mem = [(rx, 6)]. Compute:

       3) Show that, for any state (Env, Mem):Now, we extend the language Lang1 by considering the expressions of the extended Def 1 language and adding the construction x+ := e. In informal terms, the execution of this instruction in a state (Env, Mem) consists of first finding the value vx stored at the reference v in Mem, then evaluating the expression e in this state to obtain its value ve and a new state (Env’, Mem’), and finally, assigning to v the result of the addition of ve and vx. If at least one of the two values ve and vx is not an integer, the execution fails.

       4) Redefine the relation →Lang1 for the extended Lang1 language.

       5) Let Env0 = [(x, rx)] and Mem0 = [(rx, 2)]. Determine the state etat1 such that

       6) Do the assignments x := x + +, x := + + x and x+ := 1 produce the same states when executed in the same state?

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

/9j/4AAQSkZJRgABAQEBLAEsAAD/7Sv8UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAC0cAVoAAxsl RxwCAA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