JavaScript
Tuesday, October 1, 2024
What questions does your neighbor have?
4 - Exceeding (E)
Student has met and exceeded the learning objective.
3 - Proficient (P)
Student has proficiently met the learning objective.
2 - Approaching (A)
Student is approaching the learning objective.
1 - Novice (N)
Student is far from meeting the learning objective.
0 - Zero (Z)
Student has made no attempt towards the learning objective.
4 - Exceeding (E)
Student demonstrates mastery and shows the ability to apply and transfer learning with depth and complexity.
Student demonstrates synthesis of the underlying concepts. Student can go beyond merely describing the solution to explaining the underlying reasoning and discussing generalizations.
3 - Proficient (P)
Student demonstrates competence.
Student is able to explain the overall solution and can answer specific questions. While the student is capable of explaining their solution, they may not be able to confidently extend their explanation beyond the immediate context.
2 - Approaching (A)
Student demonstrates partial understanding.
Student may able to describe the solution but has difficulty answering specific questions about it. Student has difficulty explaining the reasoning behind their solution.
Level | Percentage Range | Letter Grade |
---|---|---|
Exceeding (E) | 88% – 100% | A |
82% – 88% | A- | |
Proficient (P) | 75% – 82% | B+ |
68% – 75% | B | |
61% – 68% | B- | |
56% – 61% | C+ | |
51% – 56% | C | |
Approaching (A) | 46% – 51% | C- |
42% – 46% | D+ | |
38% – 42% | D | |
34% – 38% | D- |
Goal: Staff-organized 30-minute review session to prepare for the exam.
What is the purpose of a language specification?
What is the difference between syntax and semantics?
How can we describe how to implement a interpreter for all JavaScripty programs?
\[ e \Downarrow v \]
“Expression \(e\) evaluates to value \(v\).”
A set of inference rules defining such an evaluation judgment form is called a big-step operational semantics for expressions \(e\).
\[ \begin{array}{rrrl} \text{expressions} & e& \mathrel{::=}& v\mid e_1 \mathbin{\mathit{bop}} e_2 \\ \text{values} & v& \mathrel{::=}& n \\ \text{binary operators} & \mathit{bop}& \mathrel{::=}& \texttt{+} \\ \text{numbers} & n \end{array} \]
defined trait Expr defined trait Bop defined class Binary defined class N defined object Plus defined function isValue e_oneplustwo: Binary = Binary(bop = Plus, e1 = N(n = 1.0), e2 = N(n = 2.0))
\[ \inferrule[EvalNum]{ }{ ??? } \]
\[ \inferrule[EvalPlus]{ }{ ??? } \]
defined function eval
\[ \begin{array}{rrrl} \text{values} & v& \mathrel{::=}& b \\ \text{booleans} & b \end{array} \]
defined class B defined function isValue e_true: B = B(b = true) e_trueplustwo: Binary = Binary(bop = Plus, e1 = B(b = true), e2 = N(n = 2.0))
\[ \inferrule[EvalVal]{ }{ v \Downarrow v } \]
defined function eval
scala.MatchError: B(true) (of class ammonite.$sess.cmd3$Helper$B) ammonite.$sess.cmd5$Helper.eval(cmd5.sc:6) ammonite.$sess.cmd6$Helper.<init>(cmd6.sc:2) ammonite.$sess.cmd6$.<clinit>(cmd6.sc:7)
defined class DynamicTypeError
defined function eval
TypeError: in expression Binary(Plus,B(true),N(2.0)) ammonite.$sess.cmd9$Helper.eval(cmd9.sc:9) ammonite.$sess.cmd10$Helper.<init>(cmd10.sc:2) ammonite.$sess.cmd10$.<clinit>(cmd10.sc:7)
\(\fbox{$v \rightsquigarrow n$}\)
\(\inferrule[ToNumberNum]{ }{ n \rightsquigarrow n }\)
\(\inferrule[ToNumberTrue]{ }{ \mathbf{true} \rightsquigarrow 1 }\)
\(\inferrule[ToNumberFalse]{ }{ \mathbf{true} \rightsquigarrow 0 }\)
defined function toNumber
\[ \inferrule[EvalVal]{ }{ ??? } \]
\[ \inferrule[EvalPlus]{ }{ ??? } \]
\[ \begin{array}{rrrl} \text{expressions} & e& \mathrel{::=}& x\mid\mathbf{const}\;x\;\texttt{=}\;e_1\texttt{;}\;e_2 \\ \text{variables} & x, y \end{array} \]
defined class Var defined class ConstDecl e_const_i_two_trueplusi: ConstDecl = ConstDecl( x = "i", e1 = N(n = 2.0), e2 = Binary(bop = Plus, e1 = B(b = true), e2 = Var(x = "i")) ) defined type Env empty: Env = Map() defined function lookup defined function extend
\[ \begin{array}{rrrl} \text{value environments} & E, \mathit{env}& \mathrel{::=}& \cdot \mid E[\mathop{}x \mapsto v] \end{array} \]
\[ \inferrule[EvalVar]{ }{ ??? } \]
\[ \inferrule[EvalConstDecl]{ }{ ??? } \]
\(\inferrule[EvalVar]{ \phantom{\Downarrow} }{ E \vdash x \Downarrow E(x) }\)
\(\inferrule[EvalConstDecl]{ E \vdash e_1 \Downarrow v_1 \and E[\mathop{}x \mapsto v_1] \vdash e_2 \Downarrow v_2 }{ E \vdash \mathbf{const}\;x\;\texttt{=}\;e_1\texttt{;}\;e_2 \Downarrow v_2 }\)
\(\inferrule[EvalVal]{ \phantom{\Downarrow} }{ E \vdash v \Downarrow v }\)
\(\inferrule[EvalNeg]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow n_1 }{ E \vdash \mathop{\texttt{-}} e_1 \Downarrow - n_1 }\)
\(\inferrule[EvalNot]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow b_1 }{ E \vdash \mathop{\texttt{!}} e_1 \Downarrow \lnot b_1 }\)
\(\inferrule[EvalArith]{ E \vdash e_1 \Downarrow v_1 \and E \vdash e_2 \Downarrow v_2 \and v_1 \rightsquigarrow n_1 \and v_2 \rightsquigarrow n_2 \and \mathit{bop}\in \left\{ \texttt{+}, \texttt{-}, \texttt{*}, \texttt{/} \right\} }{ E \vdash e_1 \mathbin{\mathit{bop}} e_2 \Downarrow n_1 \mathbin{\mathit{bop}} n_2 }\)
\(\inferrule[EvalAndTrue]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow \mathbf{true} \and E \vdash e_2 \Downarrow v_2 }{ E \vdash e_1 \mathbin{\texttt{\&\&}} e_2 \Downarrow v_2 }\)
\(\inferrule[EvalAndFalse]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow \mathbf{false} }{ E \vdash e_1 \mathbin{\texttt{\&\&}} e_2 \Downarrow v_1 }\)
\(\inferrule[EvalOrTrue]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow \mathbf{true} }{ E \vdash e_1 \mathbin{\texttt{||}} e_2 \Downarrow v_1 }\)
\(\inferrule[EvalOrFalse]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow \mathbf{false} \and E \vdash e_2 \Downarrow v_2 }{ E \vdash e_1 \mathbin{\texttt{||}} e_2 \Downarrow v_2 }\)
\(\inferrule[EvalIfTrue]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow \mathbf{true} \and E \vdash e_2 \Downarrow v_2 }{ E \vdash e_1\;\texttt{?}\;e_2\;\texttt{:}\;e_3 \Downarrow v_2 }\)
\(\inferrule[EvalIfFalse]{ E \vdash e_1 \Downarrow v_1 \and v_1 \rightsquigarrow \mathbf{false} \and E \vdash e_3 \Downarrow v_3 }{ E \vdash e_1\;\texttt{?}\;e_2\;\texttt{:}\;e_3 \Downarrow v_3 }\)
\(\inferrule[EvalEquality]{ E \vdash e_1 \Downarrow v_1 \and E \vdash e_2 \Downarrow v_2 \and \mathit{bop}\in \left\{ \texttt{===}, \texttt{!==} \right\} }{ E \vdash e_1 \mathbin{\mathit{bop}} e_2 \Downarrow v_1 \mathbin{\mathit{bop}} v_2 }\)
\(\inferrule[EvalInequality]{ E \vdash e_1 \Downarrow v_1 \and E \vdash e_2 \Downarrow v_2 \and v_1 \rightsquigarrow n_1 \and v_2 \rightsquigarrow n_2 \and \mathit{bop}\in \left\{ \texttt{<}, \texttt{<=}, \texttt{>}, \texttt{>=} \right\} }{ E \vdash e_1 \mathbin{\mathit{bop}} e_2 \Downarrow n_1 \mathbin{\mathit{bop}} n_2 }\)