lili对《The Scheme Programming Language, 4th Edition》的笔记(1)

The Scheme Programming Language, 4th Edition
  • 书名: The Scheme Programming Language, 4th Edition
  • 作者: R. Kent Dybvig
  • 页数: 504
  • 出版社: The MIT Press
  • 出版年: 2009-7-31
  • 第7页
    Syntactic forms
    let:
    The let syntactic form includes a list of variable-expression pairs, along with a sequence of expressions referred to as the body of the let . The general form of a let expression is
    (let ((var expr) ...) body 1 body 2 ...)
    Lambda:
    (lambda (var ...) body 1 body 2 ...)
    The variables var ... are the formal parameters of the procedure, and the sequence of expressions body 1 body 2 ...is its body.
    OR AND
    (x expr...)
    (or) -->#f
    (and) -->#t
    Cond:
    (cond (test expr) ... (else expr))
    though the else clause may be omitted. This should be done only when there is no possibility that all the tests will fail,as in the new version of sign below.
    对于lambda参数的三种类型
    (define var 0
    (lambda (var 1 ... var n ) ;; N个指定参数型
    e1 e2 ...))
    may be abbreviated
    (define (var 0 var 1 ... var n )
    e1 e2 ...)
    (define var 0
    (lambda var r ;;不定参数型,注意参数没括号 var r是所有输入实参的list
    e1 e2 ...))
    may be abbreviated
    (define (var 0 . var r )
    e1 e2 ...)
    (define var 0
    (lambda (var 1 ... var n . var r ) ;;至少N个参数型 var r是所有n以后输入实参的list
    e1 e2 ...))
    may be abbreviated
    (define (var 0 var 1 ... var n . var r )
    e1 e2 ...)
    Chapter1.
    "tail call" -- A tail call occurs when one procedure directly returns the result of invoking another procedure;
    "tail recursion" -- A tail recursion occurs when a procedure recursively tail-calls itself, directly or indirectly.
    < Scheme Naming convertion >
    Predicate names end in a question mark ( ? ). Predicates are procedures that return a true or false answer, such as eq?, zero?, and string=?.
    The names of most character, string, and vector procedures start with the prefix char-, string-, and vector-,e.g., string-append. (The names of some list procedures start with list-, but most do not.)
    The names of procedures that convert an object of one type into an object of another type are written as type 1->type 2 , e.g., vector->list .
    The names of procedures and syntactic forms that cause side effects end with an exclamation point ( ! ).
    两个不同的list。
    proper lists--The cdr of the last pair in a proper list is the empty list.
    the empty list is a proper list
    improper lists--An improper list is printed in dotted-pair notation, with a period, or dot, preceding the final element of the list.
    list 与 cons操作符的差异:The procedure list is similar to cons , except that it takes an arbitrary number of arguments and always builds aproper list.
    有关let 的镶套时变量的绑定问题有一个原则:对一个变量出现在哪层let的body中就是对应那层绑定的值。p22
    对于术语shadow, scope, lexical scoping的定义在p22.
    关于set!作用;
    赋值,有一个独一无二的作用设置一个过程的内部状态。对于内部状态要隐藏的过程内部,一般不要作为top level. 对于在多个过程中共享一个内部状态可以通过使用set!把共享量和接口过程关联。
    P43
    P43
    可以看到通过在一个赋值过程中set!接口过程把自己内部的变量共享给set!的函数
    lambda-bodies are implicit begins.
    2011-07-28 20:56:08 回应