Skip to content

Week 12 Notes

  • Lecture 28: Interpreters (08/08/22)

    • The structure of an interpreter with abstraction (giving names to values,…)
      • Evaluation function
        • Base cases:
          • Primitive values (numbers)
          • ((Look up values bound to symbols)) (Extensions)
        • Recursive calls:
          • Eval(operator, operands) of call expressions
          • Apply(procedure, arguments)
          • ((Eval(sub-expressions) of special forms))
      • Apply function
        • Base cases:
          • Built-in primitive procedures
        • Recursive calls:
          • ((Eval(body) of user-defined procedures))
    • Eval requires an environment for symbol lookup
    • Apply creates a new environment each time a user-defined procedure is applied
    • Scheme special forms are identified by the first list element (if, lambda, define, <operator>,…)
    • Special logic forms: if, and, or, cond
      • do_if_form → Eval
    • Parser also converts shorthand into combinations: ‘(1 2 3) → (quote (1 2 3))
    • Procedure definition is shorthand of define with a lambda expression: (define (<name> <formal parameters>) <body>) → (define <name> (lambda (<formal parameters>) <body>))
  • Reading Ch 3.5: Interpreters for Languages with Abstraction (08/08/22)

  • Lab 10: Interpreters (08/08/22)

    • Metacircular evaluation: implement a smaller version of a language using itself
  • Discussion 10: Interpreters (09/08/22)

  • Guerrilla 04: Scheme, Interpreters (09/08/22)

    • Traditional recursion: perform your recursive calls first, then take the return value of the recursive call and calculate the result. In this manner, you don’t get the result of your calculation until you have returned from every recursive call
    • Tail recursion: perform your calculations first, and execute the recursive call, passing the results of your current step to the next recursive step
  • Project 4: Scheme Interpreter (09, 10/08/22)

    • Macros allow the language itself to be extended by the user
  • Reading Ch. 4.3: Declarative Programming (21/08/22)

    • Database: large repositories containing data values, each data value is a record. Similar-structured records are grouped into tables/relations
    • Queries: statements in a query language used to retrieve and transform records
    • SQL: Structured Query Language
    • Unlike the procedural programming paradigm (Python, Scheme) where programmers describe the computational processes directly, a declarative language abstracts away the procedure, instead focusing on the form of the result
    • Commands
      • select [column value] as [column name],…
        • creates a new table, either from scratch or by projecting a table
        • a select statement can specify an input table by using a from clause
        • select [column description] from [existing table name]
      • [line1] union [line2] union [line3];
        • construct multi-line table
      • create table [name] as [select statement];
        • gives a global name to a table
      • where [filtering expression]
        • filters projected rows
      • order by [ordering expression]
        • evaluates ordering expression for each unfiltered row. The resulting values of this expression are used as a sorting criterion for the result table
  • Lecture 29: Declarative Programming (21/08/22)