Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
sav07_lecture_4_skeleton [2007/03/22 20:30] vkuncak |
sav07_lecture_4_skeleton [2007/03/22 20:34] vkuncak |
||
---|---|---|---|
Line 76: | Line 76: | ||
Array bounds checking. | Array bounds checking. | ||
+ | |||
==== Semantics of references ==== | ==== Semantics of references ==== | ||
Objects as references, null as an object. | Objects as references, null as an object. | ||
+ | |||
+ | Program with class declaration | ||
+ | |||
+ | <code java> | ||
+ | class Node { | ||
+ | Node left, right; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | How can we represent fields? | ||
+ | |||
+ | Possible mathematical model: fields as functions from objects to objects. | ||
+ | |||
+ | left : Node => Node | ||
+ | right : Node => Node | ||
+ | |||
+ | What is the meaning of assignment? | ||
+ | |||
+ | x.f = y | ||
+ | |||
+ | <latex> | ||
+ | f[x \mapsto y](z) = \left\{ \begin{array}{lr} | ||
+ | y, & z=x \\ | ||
+ | f(z), & z \neq x | ||
+ | \end{array}\right. | ||
+ | </latex> | ||
+ | |||
+ | left, right - uninterpreted functions (can have any value, depending on the program, unlike arithmetic functions such as +,-,* that have fixed interpretation). | ||
Null checks. | Null checks. |