Skip to main contentCal State San Bernardino / [CNS] / [Comp Sci Dept] / [R J Botting] / [CSci320] [Search ]
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Sessions: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
12.html (HTML) [12.txt(Text)] Fri Jan 12 12:37:19 PST 2007

Contents


    CS320/12 Implementing Subprograms (Chapter 10)

      Prev 11LISPChapter 2 section 4 + LISP handoutlab11 LISP101
      12Implementing subprogramsChapter 10 but not 10.3.4.2lab12 LISP102
      Next 13Functional ProgrammingChapter 15 not section 8lab13 LISP103

      Preparation

      Study the Notes below.

      Sudy Chapter 10.

      Think about the Notes and the reading.

      Answer the chapter's review questions.

      Hand in answers to 3 or more review questions.

      Notes

        (1) You need to describe the activation records for several kinds of language.

        (2) You need to describe the activation records for several kinds of language using the UML.

        (3) Variables declared in a C program can be global - visible to all parts of the program, or local to a file (static external), or be local to a particular block. A subprogram can only be local to a file or global. So, functions are never declared inside another function and so the referencing environment of functions can never contain variables that are local to other functions. This means that the compiler does not need to keep track of them. It lets the linker handle global variables and functions. So C has simpler Activation Records than Algol or Pascal.

        (4) In nearly all modern languages data is stored in two places: the stack and the heap The data on the stack is created (pushed) and deleted(popped) automatically as the blocks and subprograms are entered and exitted, respectively. However, data on the heap is created by special explicit operators like the "new" operator in Java and C++. It continues to exist after the subprogram or block in which it was created terminates. It is accessed indirectly by a pointer. If all the pointers to a piece of heap data are deleted then the data becomes garbage -- it takes up space that can be recycled. Java automatically collects the garbage and lets the program reuse the memory space. C++ does not -- and the programmer must do it themselves.

      Class Work

      [ 12q.html ]

      Lab Work -- More LISP

      [ lab/12.html ]

      Next -- Functional Programming

      [ 13.html ]

    End