No Title

Administrative Notes

Extra classes on Monday at 11am in 373 Soda.

Strict vs. Lazy Evaluation (Review)

Lazy evaluation (call by name):

Eager evaluation (call by value):

Affects the evaluation of identifies and function definitions. Call by Denotation

Scoping vs. Parameter Passing

The difference between call by denotation and call by name is the scope in which free variables in the actual parameter expression are evaluated.

There are two separable scoping issues:

Usually people are refering to the first of these two when they discuss scoping.

Scoping

Dynamic Scoping

Dynamic scoping used in early Lisps, APL, and SNOBOL4.

Can be very handy for some problems.

(define derivative
   (lambda (f x)
     (/ (- (f (+ x epsilon))
           (f x))
        epsilon)))

(let ((epsilon 0.001))
 (derivative (lambda (x) (* x x)) 5.0))

Execution model seems simple-textual substitution of procedure body. But how simple are the semantics, if we want to think of procedures as mathematical functions?

Recall Funarg Problem (from Lecture 2)

Denotational Semantics of Scoping

Static scoping:

Dynamic scoping:

Environment Diagrams

Environment Diagram Example

Records in FL

Invented to decompose large programs, which do not fit into a flat naming discipline. A hierarchical name space (nested scopes) helps, but it not enough.

         (record (I E)*)

Defines a binding between I's and E's, which make up an environment.

Given a module value, expressed by E, we can get the value of an I by:

          (select E I)

For example,

(let ((pack1 (module (val 2) 
                     (scale (lambda (x) (+ x 10)))))
      (pack2 (module (vim 3) 
                     (scale (lambda (x) (* x 2))))))
   ((select pack1 scale) (select pack2 vim)))

Records in FL

In addition, we can merge records and hide names using:

(override E1 E2) 

(conceal (I*) E)

The override function creates a new records that has all of the fields of E1 and E2, with the names in E2 taking precedence if there are duplicates.

The conceal function creates a record that is just like E, but all of the names in I* are hidden.

What about these contructs is ambiguous?

Denotational Semantics of Records

Records with Sugar (Modules)

(module (I E)*)



(with (I*) E1 E2)



(project (I*) E)



(rename ((I_old I_new)*)



Kathy Yelick
Wed Feb 21 16:03:24 PST 1996