Tuesday, 28 April 2009

Concept of Programming Language

1. Programming Language 就是 Syntax 和 Semantic的集合

2. 两种重要的Semantic: Denotational Semantic : 把一段语言用另外一种语言来表达它的semantic;一般“另一种语言”就是Mathematic。Operational Semantic:把语言看成是状态的转换,(state*var*value)->state

3.lambda calculus:(lambda x (f x)) 就是 f(x), x是它的parameter.

free variable 和 bind variable (lambda x (f x y))

a-equivalent. (lambda x x) = (lambda y y)

b-equivalent. (lambda x M)N = [N/x]M, 用N 把M里面的所有free的x 都进行替换。

4. Side Effect: 如果f(x,y) 函数体内不会改变x, y的值,那么就称之为没有side effect.

5. Types:

compile time checking:

run time checking:

type checking: 显式的定义type

type inference:在runtime根据参数类型,函数类型决定type



type safe: 如果一个语言允许显式的deallocation内存,那么它必然不是完全的type safe的。

6. Control:

Dynamic Scope: for exception handler, follow control link

Static Scope: for variable declarations, follow access link

7.Parameter Pass:

pass by name:

pass by value:

pass by reference

8. Tail Recursive: 对于递归函数来说,它的结果是可以直接从递归部分得到或者是不需要递归。类似于iteration的感觉。其好处在于,每次进行递归的时候,可以不需要保 存当前的环境 f(x) -> f(x,P) P 是continuation of the current state x.

9. Continuation: 我理解为一个函数,represent the remain computation of a current state of a program.所以每当一个程序的状态发生改变(variable value change, declaration...)都会有一个新的state.

callcc 函数


Control Link: dynamic form

Access Link: static form

11. Total Function & Partial Function

12. L-values :Memory location; R-values :contents

13. Anonymous Function: use function as parameters

14.Object Orientation

dynamic lookup -> code depend on object and message

        different from overloading:

        overloading: compile time

       dynamic lookup: runtime

encapsulation -> you only need to know the interface

inheritance -> relationship between implement

subtyping -> relationship between interface

15. Languages:

OO: Small talk, simula, Self, C++, Java

Functional: ML, Lisp, Haskell

Others: JavaScript, PHP, Python......

No comments:

Post a Comment