SICP学习
- Semantics is what that something means
- Type-checking(before program runs)
- Evaluation(as program runs)
- three things we want to think about for expressions
- Syntax: how we write down this expression
- Valid Types: what types are allowed for subexpressions, and what type this expression returns
- Evaluation: how we run this when it’s part of a program
- Suppose instead that e1 has type int and e2 has type bool. Then, what type would e1 + e2 have?
- A: it doesn’t typecheck, thus it doesn’t have a type. Addition is not defined for adding an int to a bool. Thus, this expression will not typecheck, and has no type.
- shadowing
- We write this and load it.
val x = (2,3) val ans = pow x
And we repl use “fileyouname.sml”;
val x = (2,3) : int * int val ans = 8 : int
null e
evaluates to true if and only if e evaluates to [].- if e evaluates to [v1,v2,…,vn] then
hd e
evaluates to v1- raise exception if e evaluates to []
- if e evaluates to [v1,v2,…,vn] then
tl e
evaluates to [v2,…,vn]- raise exception if e evaluates to []
- Notice result is a list