RU beehive logo ITEC dept promo banner
ITEC 380
2008fall
ibarland

homeinfolecturesexamsarchive

lect08c
scope: closures

We saw three different variants on (static) scoping mechanisms last time. Scheme named them differently (let vs. let* vs. letrec), whereas Java uses let* for names of local variables and fields, and letrec for names of methods.

class Foo {
  //int b = 9;

  int foo( int a ) {
    // Try swapping these two next lines; not differing error message.
    a = b;
    int b;
    b = 5;
    
        
    //int c;
    for (int c = 0; c < 3; ++c ) {
        //int c;
        c = 9;
        }
         
    //return c;
    return -99;
    }
See also: a silly main.

Implementing fields. Note that each (pair of) functions has its own closure.

Next time, we'll continue by thinking about how to (essentially) makes subclasses of this class rng.

homeinfolecturesexamsarchive


©2008, Ian Barland, Radford University
Last modified 2008.Oct.29 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme