---
title: "SU-CS143 MAY152025"
source: https://www.jemoka.com/posts/kbhsu_cs143_may152025/
date: 2025-05-15
---

&ldquo;If \(B\) is a subclass of \(A\), then an object of \(B\) can be used wherever \(A\) is expected.&rdquo;
To do this, we will lay out:
the pointer * points to a method table
Other Semantics than structural operational semantics denotational semantics axiomatic semantics Runtime Errors We have to catch some runtime errors:
calling on voids method dispatch problems What to track in context? environment: where in memory a variable is stored? Map&lt;Symbol, void *&gt; store: what is in memory? Map&lt;void *, Value&gt; This means that a judgment is:
\begin{equation} \text{self}, E, S \vdash e: V, S' \end{equation}
that is, &ldquo;given environment \(E\), store \(S\), we have that \(e\) evaluates to \(V\), and \(S\) are side effects.&rdquo;
The reason why environments doesn&rsquo;t change is because we can&rsquo;t pass globals up, so scoping always travels down.
assignments As you would expect:
\begin{equation} \frac{so,E, S \vdash e : v, S_1 | E\qty(id) = I_{id} | S_2=S_1[v / I_{id}]}{so, E, S \vdash id \leftarrow e: v, S_2} \end{equation}
Notice! we have side effects that are CHAINED; if evaluating \(e\) has side effects, we carry them into our evaluation in the side effects \(S \to S_1 \to S_2\).
loops We use recursion!
\begin{equation} \frac{\begin{align}&amp;so, E, S \vdash e_1: true, S_1 \\ &amp;so, E, S_1, \vdash S_2 : v, S_2 \\ &amp;so, E, S_2 \vdash \text{ while } e_1 \text{ loop } e_2 \text{ pool } : void, S_3\end{align}}{so, E, S \vdash \text{ while } e_1 \text{ loop } e_2 \text{ pool } : void, S_3} \end{equation}
how do we allocate new spaces? We can use the syntax
\begin{align} &amp;l_{new} = \text{newloc}\qty(S_1) \\ &amp;so, E[l_{new} / id], S_1[v_1 / l_{new}] \vdash \dots \end{align}
how do we allocate new objects? &hellip;what about self? \begin{equation} \frac{}{\text{so}, E, S \vdash \text{self}: \text{so}, S} \end{equation}
errors to check dispatch on void division by zero substring out of range heap overflow generally we need to exit gracefully
