编程语言的一些概念
1. 命令式语言(imperative)和函数式(funcional)语言
2. 静态类型语言和动态类型语言,取决于类型检查时在编译器还是运行期,比如:Python一个符号可以不指定类型,只是一个名字,在运行时可以随意帮上任何类型,然后用这个名字去访问它。
3. 动态语言的缺点,因为缺乏类型,编译器无法检查语法错误,使得程序出错的可能增加,debug困难,比如:在函数中用错了一个名字,Python认为这是一个新定义的名字,不会报语法错误
4. "First-class" Type,一般是针对函数是不是可以作为函数的参数,实例化。
5. Functions are actually a special case of closures: blocks of code that can be called later. The code in a closure has access to things like variables and functions that were available in the scope where the closure was created, even if the closure is in a different scope when it is executed—you saw an example of this already with nested functions. You can write a closure without a name by surrounding code with braces ({}
). Use in
to separate the arguments and return type from the body