本笔记开始写时并未读SICP,而是学习MIT 6.001WU CSE341

  1. Semantics is what that something means
    • Type-checking(before program runs)
    • Evaluation(as program runs)
  2. 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
  3. 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.
  4. shadowing
  5. 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
    
  6. null e evaluates to true if and only if e evaluates to [].
  7. if e evaluates to [v1,v2,…,vn] then hd e evaluates to v1
    • raise exception if e evaluates to []
  8. 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