Week11-Lecture26
Lecture 26 Scheme¶
Reading 3.1 Interpreting Computer Programs¶
This chapter focuses on the third fundamental element of programming: programs themselves. A Python program is just a collection of text. Only through the process of interpretation do we perform any meaningful computation based on that text. A programming language like Python is useful because we can define an interpreter, a program that carries out Python's evaluation and execution procedures. It is no exaggeration to regard this as the most fundamental idea in programming, that an interpreter, which determines the meaning of expressions in a programming language, is just another program.
To appreciate this point is to change our images of ourselves as programmers. We come to see ourselves as designers of languages, rather than only users of languages designed by others.
3.1.1 Programming Languages¶
编程语言有很大的差异。课程介绍scheme语言(an example of a powerful language with a minimal set of features)
本章将介绍解释器。
许多解释器都具有一种优雅的共同结构:两个相互递归的函数。第一个在环境中求值表达式;第二个将函数应用于参数。
Reading 3.2 Functional Programming¶
从底层到高级的语言:
- 物理语言关注的是用单个存储位和基本机器指令来表示数据和控制。
- 机器语言程序员关注的是利用给定的硬件来构建系统和实用程序,以便高效实现资源受限的计算。
- 高级语言构建在机器语言的基底之上,使人们无需关注将数据表示为位集合、将程序表示为基本指令序列等问题。这些语言具有组合与抽象的手段,例如函数定义,这些手段适合于软件系统更大规模的组织。
3.2.1 Expressions¶
基本形式:(操作符 参数1 参数2 ...)
| Scheme | |
|---|---|
不像 Python 的中缀写法 1 + 2,Scheme 把操作符放在最前面,这叫前缀记法。好处是所有运算符和函数调用的写法完全统一。
Homework 07 Scheme¶
(实在是很不习惯这个语法啊,就不写了,了解一下这个语言就好了)