• A: Because it abstract out the common pattern. Using higher-order procedures to implement the details. • Q: Dose it any good? • A: It gets more reusable. You can perform different action by call it with different procedures.
procedure? • A: A higher-order procedure, or, higher-order function, or functor, or functional, is a function which: • either takes at least one function, • or returns a function.
and <proc> are free variables! How could we avoid that? (define (gen-sum a b term next) (if (<predicate> a b) 0 (<proc> (term a) (gen-sum (next a) b))))
and <proc> are free variables! How could we avoid that? (define (gen-sum a b term next predicate proc) (if (predicate a b) 0 (proc (term a) (gen-sum (next a) b)))) • A: By parameterize them!
the type of sum-builder? • A: Currying takes care of it! (define (sum-builder predicate proc) (λ (<para-list>) (gen-sum a b term next predicate proc)))
we have to fill in the <para-list>? • A: The unbound variables! (define (sum-builder predicate proc) (λ (a b term next) (gen-sum a b term next predicate proc)))
A: Introduced the environment. A environment is a map which maps a syntax element Ide to a locale L. And we have another map called save which maps a locale L to a pair (E, T). Identifier Locale Value Save Environment (Lvalue) (Rvalue)
• A: A binding associates a name with a value. and a frame is a table of bindings and a pointer to another frame. identifier value identifier value identifier value identifier value pointer identifier value identifier value pointer
a function builder? • A: Yes. We know function builder already. It build a function, then you use that function. Of course, you can build more than one function though the procedure make-counter.
or, even better, make-closure. • What’s a closure? • A closure is a data structure. • Consists of a pointer to the code. • And a pointer to the environment where the lambda be called.
John C.Raynolds • A wisdom, clear, and gentle textbook on fundamental concept of programming languages with a wide range of topics include denotational semantics and the concurrency.